Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::config::ConfigFileJson Class Referencefinal

Json representation of config. More...

#include <ConfigFileJson.hpp>

Inheritance diagram for util::config::ConfigFileJson:
Collaboration diagram for util::config::ConfigFileJson:

Public Member Functions

 ConfigFileJson (boost::json::object jsonObj)
 Construct a new ConfigJson object and stores the values from user's config into a json object.
 
Value getValue (std::string_view key) const override
 Retrieves a configuration value by its key.
 
std::vector< Value > getArray (std::string_view key) const override
 Retrieves an array of configuration values by its key.
 
bool containsKey (std::string_view key) const override
 Checks if the configuration contains a specific key.
 
boost::json::object const & inner () const
 Get the inner representation of json file.
 
- Public Member Functions inherited from util::config::ConfigFileInterface

Static Public Member Functions

static std::expected< ConfigFileJson, ErrormakeConfigFileJson (std::filesystem::path const &configFilePath)
 Creates a new ConfigFileJson by parsing the provided JSON file and stores the values in the object.
 

Detailed Description

Json representation of config.

Constructor & Destructor Documentation

◆ ConfigFileJson()

util::config::ConfigFileJson::ConfigFileJson ( boost::json::object jsonObj)

Construct a new ConfigJson object and stores the values from user's config into a json object.

Parameters
jsonObjthe Json object to parse; represents user's config

Member Function Documentation

◆ containsKey()

bool util::config::ConfigFileJson::containsKey ( std::string_view key) const
nodiscardoverridevirtual

Checks if the configuration contains a specific key.

Parameters
keyThe key to check for.
Returns
True if the key exists, false otherwise.

Implements util::config::ConfigFileInterface.

◆ getArray()

std::vector< Value > util::config::ConfigFileJson::getArray ( std::string_view key) const
nodiscardoverridevirtual

Retrieves an array of configuration values by its key.

Parameters
keyThe key of the configuration array to retrieve.
Returns
A vector of variants holding the config values specified by user.

Implements util::config::ConfigFileInterface.

◆ getValue()

Value util::config::ConfigFileJson::getValue ( std::string_view key) const
nodiscardoverridevirtual

Retrieves a configuration value by its key.

Parameters
keyThe key of the configuration value to retrieve.
Returns
A variant containing the same type corresponding to the extracted value.

Implements util::config::ConfigFileInterface.

◆ inner()

boost::json::object const & util::config::ConfigFileJson::inner ( ) const
nodiscard

Get the inner representation of json file.

Note
This method is mostly used for testing purposes.
Returns
The inner representation of json file.

◆ makeConfigFileJson()

std::expected< ConfigFileJson, Error > util::config::ConfigFileJson::makeConfigFileJson ( std::filesystem::path const & configFilePath)
staticnodiscard

Creates a new ConfigFileJson by parsing the provided JSON file and stores the values in the object.

Parameters
configFilePathThe path to the JSON file to be parsed.
Returns
A ConfigFileJson object if parsing user file is successful. Error otherwise

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