ChessPlusPlus  WIP
cplusplus.com Community Project
chesspp::config::Configuration Class Reference

Holds configuration settings that affect the behavior of the game. More...

#include <Configuration.hpp>

Inheritance diagram for chesspp::config::Configuration:
chesspp::config::BoardConfig chesspp::config::ResourcesConfig

Public Member Functions

 Configuration (std::string const &configFile) noexcept(false)
 Loads the configuration from the given file path. More...
 
virtual ~Configuration ()=default
 
template<typename... Path>
auto setting (Path const &...path) -> decltype(reader.navigate(path...))
 Access values in the configuration. More...
 

Static Protected Member Functions

static std::string executablePath ()
 Get the path to the directory the executable is in. More...
 

Protected Attributes

std::string res_path
 Stores the path to the directory where configuration paths are relative to. More...
 
util::JsonReader reader
 The chessp::util::JsonReader for reading the configuration values. More...
 

Detailed Description

Holds configuration settings that affect the behavior of the game.

Configuration files are in JSON format - http://www.json.org/

Constructor & Destructor Documentation

chesspp::config::Configuration::Configuration ( std::string const &  configFile)
inlinenoexcept

Loads the configuration from the given file path.

Parameters
configFilethe relative path to the configuration file. Must end in .json
Exceptions
chesspp::Exceptionif the path does not end in .json
virtual chesspp::config::Configuration::~Configuration ( )
virtualdefault

Member Function Documentation

std::string chesspp::config::Configuration::executablePath ( )
staticprotected

Get the path to the directory the executable is in.

Returns
Path to the directory the executable is in.
template<typename... Path>
auto chesspp::config::Configuration::setting ( Path const &...  path) -> decltype(reader.navigate(path...))
inline

Access values in the configuration.

Parameters
pathThe path to the value as multiple parameters, e.g. "a", 1, "c"
Returns
The requested chesspp::util::JsonReader::NestedValue

Member Data Documentation

util::JsonReader chesspp::config::Configuration::reader
protected

The chessp::util::JsonReader for reading the configuration values.

std::string chesspp::config::Configuration::res_path
protected

Stores the path to the directory where configuration paths are relative to.

This may not be the same as the directory containing the executable.


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