Skip to content

ConfigCat SDK for C++. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.

License

Notifications You must be signed in to change notification settings

configcat/cpp-sdk

Repository files navigation

Build codecov

ConfigCat SDK for C++

https://configcat.com

ConfigCat SDK for C++ provides easy integration for your application to ConfigCat.

C++ Standard Minimum Level: C++17.

ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.

ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.

Getting started

1. Install the ConfigCat SDK

With Vcpkg

  • On Windows:

    git clone https://github.com/microsoft/vcpkg
    .\vcpkg\bootstrap-vcpkg.bat
    .\vcpkg\vcpkg install configcat

    In order to use vcpkg with Visual Studio, run the following command (may require administrator elevation):

    .\vcpkg\vcpkg integrate install

    After this, you can create a New non-CMake Project (or open an existing one). All installed libraries are immediately ready to be #include'd and used in your project without additional configuration.

  • On Linux/Mac:

    git clone https://github.com/microsoft/vcpkg
    ./vcpkg/bootstrap-vcpkg.sh
    ./vcpkg/vcpkg install configcat

In order to use vcpkg with CMake, you can use the toolchain file:

cmake -B [build directory] -S . "-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake"
cmake --build [build directory]

We recommend that you use the vcpkg.json manifest file to add the dependencies to your project. You can find an example manifest file here.

2. Go to the ConfigCat Dashboard to get your SDK Key

SDK-KEY

3. Include configcat.h header in your application code

#include <configcat/configcat.h>

using namespace configcat;

4. Create a ConfigCat client instance

auto client = ConfigCatClient::get("#YOUR-SDK-KEY#");

5. Get your setting value

bool isMyAwesomeFeatureEnabled = client->getValue("isMyAwesomeFeatureEnabled", false);
if (isMyAwesomeFeatureEnabled) {
    doTheNewThing();
} else {
    doTheOldThing();
}

6. Close the client on application exit

ConfigCatClient::closeAll();

Getting user-specific setting values with Targeting

Using this feature, you will be able to get different setting values for different users in your application by passing a User Object to the getValue() function.

Read more about Targeting here.

User Object

Percentage and targeted rollouts are calculated by the user object passed to the configuration requests. The user object must be created with a mandatory identifier parameter which uniquely identifies each user:

auto user = ConfigCatUser::create("#USER-IDENTIFIER#");

bool isMyAwesomeFeatureEnabled = client->getValue("isMyAwesomeFeatureEnabled", false, user);
if (isMyAwesomeFeatureEnabled) {
    doTheNewThing();
} else {
    doTheOldThing();
}

Sample/Demo apps

Polling Modes

The ConfigCat SDK supports three different polling mechanisms to acquire the setting values from ConfigCat. After the latest setting values are downloaded, they are stored in an internal cache . After that, all requests are served from the cache. Read more about Polling Modes and how to use them at ConfigCat C++ Docs.

Support

If you need help using this SDK, feel free to contact the ConfigCat Staff at https://configcat.com. We're happy to help.

Contributing

Contributions are welcome. For more info please read the Contribution Guideline.

About ConfigCat

External Libraries

ConfigCat C++ SDK uses these wonderful libraries: hash-library, libcurl, nlohmann-json, z4kn4fein-semver.

About

ConfigCat SDK for C++. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published