![]() |
R-Type
2
Doom but in better
|
A utility class for parsing, navigating, and managing TOML files and data. More...
#include <TOMLLoader.hpp>
Public Member Functions | |
TOMLLoader () | |
Default constructor. | |
TOMLLoader (const std::string &tomlPath) | |
Constructor that initializes the loader with a TOML file path. | |
TOMLLoader (const TOMLLoader &tomlInstance) | |
Copy constructor. | |
TOMLLoader (const toml::table &tomlTable, const std::string &tomlPath) | |
Constructor that initializes the loader with a TOML table. | |
TOMLLoader (const toml::array &tomlArray, const std::string &tomlPath) | |
Constructor that initializes the loader with a TOML array. | |
TOMLLoader (const toml::array &tomlArray, const std::string &key, const std::string &tomlPath) | |
Constructor that initializes the loader with a TOML array under a specific key. | |
~TOMLLoader ()=default | |
Default destructor. | |
void | setTOMLPath (const std::string &tomlPath) |
Sets the path of the TOML file to load. | |
const bool | isTOMLLoaded () const |
Checks if the TOML file is successfully loaded. | |
const std::string | getTOMLPath () const |
Retrieves the path of the loaded TOML file. | |
const std::string | getTOMLString () const |
Retrieves the TOML data as a string. | |
const toml::table | getRawTOML () const |
Retrieves the raw TOML table. | |
template<typename T > | |
T | getValue (const std::string &key) const |
Retrieves a value of type T from the TOML table. | |
const toml::node_type | getValueType (const std::string &key) const |
Retrieves the type of a value for a specific key as a TOML node type. | |
const std::string | getValueTypeAsString (const std::string &key) const |
Retrieves the type of a value for a specific key as a string. | |
const std::string | getTypeAsString (const std::string &key) const |
Retrieves the type of a value for a specific key as a string (alias). | |
const std::string | getTypeAsString (const toml::node_type &type) const |
Converts a TOML node type to a string representation. | |
const bool | hasKey (const std::string &key) const |
Checks if a specific key exists in the TOML data. | |
std::vector< std::string > | getKeys () const |
Retrieves all keys from the TOML table. | |
toml::table | getTable (const std::string &key) const |
Retrieves a TOML table for a specific key. | |
toml::array | getArray (const std::string &key) const |
Retrieves a TOML array for a specific key. | |
void | update (const TOMLLoader ©) |
Updates the current loader with another loader's data. | |
void | update (const toml::table ©) |
Updates the current loader with a TOML table. | |
void | update (const toml::array ©) |
Updates the current loader with a TOML array. | |
void | update (const toml::array ©, const std::string &key) |
Updates the current loader with a TOML array under a specific key. | |
void | printTOML () const |
Prints the TOML data to the debug stream. | |
TOMLLoader & | operator= (const TOMLLoader ©) |
Copy assignment operator. | |
TOMLLoader & | operator= (const toml::table ©) |
Assignment operator for TOML tables. | |
TOMLLoader & | operator= (const toml::array ©) |
Assignment operator for TOML arrays. | |
A utility class for parsing, navigating, and managing TOML files and data.
Definition at line 31 of file TOMLLoader.hpp.
TOMLLoader::TOMLLoader | ( | ) |
Default constructor.
Definition at line 16 of file TOMLLoader.cpp.
TOMLLoader::TOMLLoader | ( | const std::string & | tomlPath | ) |
Constructor that initializes the loader with a TOML file path.
tomlPath | The path to the TOML file to be loaded. |
Definition at line 21 of file TOMLLoader.cpp.
TOMLLoader::TOMLLoader | ( | const TOMLLoader & | tomlInstance | ) |
Copy constructor.
tomlInstance | The instance to copy. |
Definition at line 27 of file TOMLLoader.cpp.
TOMLLoader::TOMLLoader | ( | const toml::table & | tomlTable, |
const std::string & | tomlPath ) |
Constructor that initializes the loader with a TOML table.
tomlTable | A TOML table. |
tomlPath | The path to the TOML file. |
Definition at line 32 of file TOMLLoader.cpp.
TOMLLoader::TOMLLoader | ( | const toml::array & | tomlArray, |
const std::string & | tomlPath ) |
Constructor that initializes the loader with a TOML array.
tomlArray | A TOML array. |
tomlPath | The path to the TOML file. |
Definition at line 40 of file TOMLLoader.cpp.
TOMLLoader::TOMLLoader | ( | const toml::array & | tomlArray, |
const std::string & | key, | ||
const std::string & | tomlPath ) |
Constructor that initializes the loader with a TOML array under a specific key.
tomlArray | A TOML array. |
key | The key associated with the array. |
tomlPath | The path to the TOML file. |
Definition at line 48 of file TOMLLoader.cpp.
|
default |
Default destructor.
toml::array TOMLLoader::getArray | ( | const std::string & | key | ) | const |
Retrieves a TOML array for a specific key.
key | The key to retrieve. |
CustomExceptions::NoTOMLKey | if the key does not exist or is not an array. |
Definition at line 143 of file TOMLLoader.cpp.
std::vector< std::string > TOMLLoader::getKeys | ( | ) | const |
Retrieves all keys from the TOML table.
Definition at line 124 of file TOMLLoader.cpp.
const toml::table TOMLLoader::getRawTOML | ( | ) | const |
Retrieves the raw TOML table.
Definition at line 78 of file TOMLLoader.cpp.
toml::table TOMLLoader::getTable | ( | const std::string & | key | ) | const |
Retrieves a TOML table for a specific key.
key | The key to retrieve. |
CustomExceptions::NoTOMLKey | if the key does not exist or is not a table. |
Definition at line 134 of file TOMLLoader.cpp.
const std::string TOMLLoader::getTOMLPath | ( | ) | const |
Retrieves the path of the loaded TOML file.
Definition at line 67 of file TOMLLoader.cpp.
const std::string TOMLLoader::getTOMLString | ( | ) | const |
Retrieves the TOML data as a string.
Definition at line 72 of file TOMLLoader.cpp.
const std::string TOMLLoader::getTypeAsString | ( | const std::string & | key | ) | const |
Retrieves the type of a value for a specific key as a string (alias).
key | The key to query. |
Definition at line 104 of file TOMLLoader.cpp.
const std::string TOMLLoader::getTypeAsString | ( | const toml::node_type & | type | ) | const |
Converts a TOML node type to a string representation.
type | The TOML node type. |
Definition at line 109 of file TOMLLoader.cpp.
|
inline |
Retrieves a value of type T
from the TOML table.
T | The type of the value to retrieve. |
key | The key of the value to retrieve. |
T
. CustomExceptions::NoTOMLKey | if the key is not found or the value cannot be converted. |
Definition at line 116 of file TOMLLoader.hpp.
const toml::node_type TOMLLoader::getValueType | ( | const std::string & | key | ) | const |
Retrieves the type of a value for a specific key as a TOML node type.
key | The key to query. |
Definition at line 84 of file TOMLLoader.cpp.
const std::string TOMLLoader::getValueTypeAsString | ( | const std::string & | key | ) | const |
Retrieves the type of a value for a specific key as a string.
key | The key to query. |
Definition at line 93 of file TOMLLoader.cpp.
const bool TOMLLoader::hasKey | ( | const std::string & | key | ) | const |
Checks if a specific key exists in the TOML data.
key | The key to check. |
Definition at line 118 of file TOMLLoader.cpp.
const bool TOMLLoader::isTOMLLoaded | ( | ) | const |
Checks if the TOML file is successfully loaded.
Definition at line 62 of file TOMLLoader.cpp.
TOMLLoader & TOMLLoader::operator= | ( | const toml::array & | copy | ) |
Assignment operator for TOML arrays.
copy | The TOML array to assign. |
Definition at line 198 of file TOMLLoader.cpp.
TOMLLoader & TOMLLoader::operator= | ( | const toml::table & | copy | ) |
Assignment operator for TOML tables.
copy | The TOML table to assign. |
Definition at line 192 of file TOMLLoader.cpp.
TOMLLoader & TOMLLoader::operator= | ( | const TOMLLoader & | copy | ) |
Copy assignment operator.
copy | The loader to copy. |
Definition at line 186 of file TOMLLoader.cpp.
void TOMLLoader::printTOML | ( | ) | const |
Prints the TOML data to the debug stream.
Definition at line 180 of file TOMLLoader.cpp.
void TOMLLoader::setTOMLPath | ( | const std::string & | tomlPath | ) |
Sets the path of the TOML file to load.
tomlPath | The file path to set. |
Definition at line 56 of file TOMLLoader.cpp.
void TOMLLoader::update | ( | const toml::array & | copy | ) |
Updates the current loader with a TOML array.
copy | The TOML array to copy data from. |
Definition at line 168 of file TOMLLoader.cpp.
void TOMLLoader::update | ( | const toml::array & | copy, |
const std::string & | key ) |
Updates the current loader with a TOML array under a specific key.
copy | The TOML array to copy data from. |
key | The key associated with the array. |
Definition at line 174 of file TOMLLoader.cpp.
void TOMLLoader::update | ( | const toml::table & | copy | ) |
Updates the current loader with a TOML table.
copy | The TOML table to copy data from. |
Definition at line 162 of file TOMLLoader.cpp.
void TOMLLoader::update | ( | const TOMLLoader & | copy | ) |
Updates the current loader with another loader's data.
copy | The other loader to copy data from. |
Definition at line 152 of file TOMLLoader.cpp.