19#include <unordered_map>
20#include <toml++/toml.hpp>
55 TOMLLoader(
const toml::table &tomlTable,
const std::string &tomlPath);
62 TOMLLoader(
const toml::array &tomlArray,
const std::string &tomlPath);
70 TOMLLoader(
const toml::array &tomlArray,
const std::string &key,
const std::string &tomlPath);
115 template <
typename T>
119 if (
auto value = _toml[key].value<T>()) {
130 const toml::node_type
getValueType(
const std::string &key)
const;
158 const bool hasKey(
const std::string &key)
const;
164 std::vector<std::string>
getKeys()
const;
172 toml::table
getTable(
const std::string &key)
const;
180 toml::array
getArray(
const std::string &key)
const;
192 void update(
const toml::table ©);
198 void update(
const toml::array ©);
205 void update(
const toml::array ©,
const std::string &key);
243 void _ensureLoaded()
const;
248 void _loadNodeTypeEquivalence();
251 bool _tomlLoaded =
false;
252 std::string _tomlPath =
"";
253 std::string _tomlString =
"";
254 std::unordered_map<toml::node_type, std::string> _nodeTypeEquivalence;
File in charge of containing the custom errors that are going to be used for custom description error...
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
std::ostream & operator<<(std::ostream &os, const TOMLLoader &node)
Overloads the stream insertion operator for TOMLLoader.
This is the class in charge of informing the user that they tried to access a non-existant toml key i...
A utility class for parsing, navigating, and managing TOML files and data.
~TOMLLoader()=default
Default destructor.
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 getTOMLString() const
Retrieves the TOML data as a string.
void update(const TOMLLoader ©)
Updates the current loader with another loader's data.
const toml::table getRawTOML() const
Retrieves the raw TOML table.
TOMLLoader & operator=(const TOMLLoader ©)
Copy assignment operator.
TOMLLoader()
Default constructor.
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.
toml::table getTable(const std::string &key) const
Retrieves a TOML table for a specific key.
const bool hasKey(const std::string &key) const
Checks if a specific key exists in the TOML data.
void setTOMLPath(const std::string &tomlPath)
Sets the path of the TOML file to load.
void printTOML() const
Prints the TOML data to the debug stream.
std::vector< std::string > getKeys() const
Retrieves all keys from the TOML table.
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).
toml::array getArray(const std::string &key) const
Retrieves a TOML array for a specific key.
T getValue(const std::string &key) const
Retrieves a value of type T from the TOML table.