YggdrasilWM
0.1.1
A tiny window manager coded in C++
|
Handle file I/O and JSON parsing for the configuration file. If no path is provided, it will search for the configuration file in the default paths. More...
#include <ConfigFileHandler.hpp>
Public Member Functions | |
ConfigFileHandler () | |
Construct a new ConfigFileHandler object without a path. More... | |
ConfigFileHandler (const std::string &configPath) | |
~ConfigFileHandler () | |
void | readConfig () |
Read the configuration file Store the JSon root object in Json::Value root_ Throws exceptions in case of file i/o error Catch Parsing Errors and log them with Logger Object. More... | |
void | writeConfig (const Json::Value &root) |
Write the configuration file Store the JSon root object in the configPath file Throws exceptions in case of file i/o error. More... | |
const Json::Value & | getRoot () |
Get the root JSON object. More... | |
std::string | getConfigPath () |
Static Private Member Functions | |
static std::string | findConfigFile () |
Find the configuration file in the default paths. More... | |
static bool | fileExists (const std::string &path) |
Check if a file exists by trying to open it. More... | |
static std::string | expandEnvironmentVariables (const std::string &path) |
Expand environment variables in a path. More... | |
Private Attributes | |
std::string | configPath_ |
Json::Value | root_ |
Static Private Attributes | |
static const std::vector< std::string > | defaultPaths |
Handle file I/O and JSON parsing for the configuration file. If no path is provided, it will search for the configuration file in the default paths.
ConfigFileHandler::ConfigFileHandler | ( | ) |
Construct a new ConfigFileHandler object without a path.
References configPath_, findConfigFile(), Logger::GetInstance(), L_INFO, and Logger::Log().
|
explicit |
References configPath_, fileExists(), findConfigFile(), Logger::GetInstance(), L_INFO, and Logger::Log().
|
staticprivate |
Expand environment variables in a path.
path |
Referenced by findConfigFile().
|
staticprivate |
Check if a file exists by trying to open it.
path |
Referenced by ConfigFileHandler(), and findConfigFile().
|
staticprivate |
Find the configuration file in the default paths.
References defaultPaths, expandEnvironmentVariables(), and fileExists().
Referenced by ConfigFileHandler().
std::string ConfigFileHandler::getConfigPath | ( | ) |
References configPath_.
Json::Value ConfigFileHandler::getRoot | ( | ) |
void ConfigFileHandler::readConfig | ( | ) |
Read the configuration file Store the JSon root object in Json::Value root_ Throws exceptions in case of file i/o error Catch Parsing Errors and log them with Logger Object.
References configPath_, Logger::GetInstance(), L_ERROR, Logger::Log(), and root_.
void ConfigFileHandler::writeConfig | ( | const Json::Value & | config | ) |
Write the configuration file Store the JSon root object in the configPath file Throws exceptions in case of file i/o error.
config | The root JSON object to write |
References configPath_, Logger::GetInstance(), L_ERROR, and Logger::Log().
|
private |
Referenced by ConfigFileHandler(), getConfigPath(), readConfig(), and writeConfig().
|
staticprivate |
Referenced by findConfigFile().
|
private |
Referenced by getRoot(), and readConfig().