14#include <cjson/cJSON.h>
45 std::string
getString(
const std::string& key,
const std::string& defaultValue =
"");
53 int getInt(
const std::string& key,
int defaultValue = 0);
61 bool getBool(
const std::string& key,
bool defaultValue =
false);
69 std::string
getNestedString(
const std::string& path,
const std::string& defaultValue =
"");
77 int getNestedInt(
const std::string& path,
int defaultValue = 0);
85 bool getNestedBool(
const std::string& path,
bool defaultValue =
false);
98 void setString(
const std::string& key,
const std::string& value);
105 void setInt(
const std::string& key,
int value);
112 void setBool(
const std::string& key,
bool value);
Manages configuration settings stored in a JSON file.
Definition ConfigManager.hpp:20
cJSON * root
The root JSON object representing the configuration.
Definition ConfigManager.hpp:116
void setBool(const std::string &key, bool value)
Sets a boolean value in the configuration.
Definition ConfigManager.cpp:199
std::string getNestedString(const std::string &path, const std::string &defaultValue="")
Retrieves a nested string value from the configuration.
Definition ConfigManager.cpp:154
bool getNestedBool(const std::string &path, bool defaultValue=false)
Retrieves a nested boolean value from the configuration.
Definition ConfigManager.cpp:172
bool loadConfig()
Loads the configuration from the JSON file.
Definition ConfigManager.cpp:37
bool saveConfig()
Saves the current configuration to the JSON file.
Definition ConfigManager.cpp:65
cJSON * getNestedItem(const std::string &path)
Retrieves a nested JSON item from the configuration.
Definition ConfigManager.cpp:132
std::string getString(const std::string &key, const std::string &defaultValue="")
Retrieves a string value from the configuration.
Definition ConfigManager.cpp:93
~ConfigManager()
Destructs the ConfigManager object.
Definition ConfigManager.cpp:26
bool getBool(const std::string &key, bool defaultValue=false)
Retrieves a boolean value from the configuration.
Definition ConfigManager.cpp:119
void setString(const std::string &key, const std::string &value)
Sets a string value in the configuration.
Definition ConfigManager.cpp:181
int getInt(const std::string &key, int defaultValue=0)
Retrieves an integer value from the configuration.
Definition ConfigManager.cpp:106
void setInt(const std::string &key, int value)
Sets an integer value in the configuration.
Definition ConfigManager.cpp:190
std::string configFilePath
The path to the configuration file.
Definition ConfigManager.hpp:115
void cleanupJSON()
Cleans up the JSON object.
Definition ConfigManager.cpp:30
int getNestedInt(const std::string &path, int defaultValue=0)
Retrieves a nested integer value from the configuration.
Definition ConfigManager.cpp:163