GlobalBpiLib  1.0
Configuration Class Reference

Interface between the application and a local stored json file. More...

#include <GlobalBpiLib.hpp>

Static Public Member Functions

static std::string getConfig (std::string jsonFilePath, std::string attribute)
 
static bool setConfig (std::string jsonFilePath, std::string attribute, std::string value)
 
static nlohmann::json readJsonFile (std::string pathToFile)
 
static void writeJsonFile (nlohmann::json json, std::string pathToFile)
 
static bool deleteConfig (std::string pathToFile, std::string attribute)
 

Detailed Description

Interface between the application and a local stored json file.

This class provides trivial mechanisms to read and write key/value pairs from and to json files. Each time a read or write function is called, the application accesses the local file, so that it is possible to modify it at runtime. This class does not provide mechanisms for reading or writing more complex structure than simple key/value pairs.

Member Function Documentation

◆ deleteConfig()

bool Configuration::deleteConfig ( std::string  pathToFile,
std::string  attribute 
)
static

Deletes a json object.

◆ getConfig()

string Configuration::getConfig ( std::string  jsonFilePath,
std::string  attribute 
)
static

Determines the value of the given attribute in the json file.

Reads and returns the value corresponding to the specified attribute from a local JSON file. The location of the JSON file is specified in LocalServiceDefines.h.

Parameters
jsonFilePathPath to the json file.
attributeAttribute of the attribute/value pair of interst.
Returns
Returns the value of the attribute/value specified by the parameter attribute. If the specified attribute does not exist, an empty string will be returned.

◆ readJsonFile()

json Configuration::readJsonFile ( std::string  pathToFile)
static

Reads a local file into a json object.

◆ setConfig()

bool Configuration::setConfig ( std::string  jsonFilePath,
std::string  attribute,
std::string  value 
)
static

(Over)writes the given attribute/value pair.

(Over)writes the attribute/value pair, specified by the parameters, in the local JSON file. The location of the JSON file is specified in LocalServiceDefines.h.

Parameters
jsonFilePathPath to the json file.
attributeAttribute of the attribute/value pair of interst.
valueValue of the attribute/value pair of interst.
Returns

◆ writeJsonFile()

void Configuration::writeJsonFile ( nlohmann::json  json,
std::string  pathToFile 
)
static

Writes a json object to the filesystem.


The documentation for this class was generated from the following files: