18 _loadNodeTypeEquivalence();
24 _loadNodeTypeEquivalence();
37 _loadNodeTypeEquivalence();
45 _loadNodeTypeEquivalence();
53 _loadNodeTypeEquivalence();
90 return _toml[key].type();
97 auto it = _nodeTypeEquivalence.find(nodeType);
98 if (it != _nodeTypeEquivalence.end()) {
111 auto it = _nodeTypeEquivalence.find(type);
112 if (it != _nodeTypeEquivalence.end()) {
121 return _toml.contains(key);
127 std::vector<std::string> keys;
128 for (
const auto &[key, _] : _toml) {
129 keys.push_back(std::string(key));
137 if (
auto table = _toml[key].as_table()) {
146 if (
auto array = _toml[key].as_array()) {
170 _toml = toml::table{ {
"array", copy} };
176 _toml = toml::table{ {key, copy} };
183 PRETTY_INFO <<
"TOML Contents:\n" + _tomlString << std::endl;
204void TOMLLoader::_loadTOML()
208 _toml = toml::parse_file(_tomlPath);
210 catch (
const toml::parse_error &e) {
213 std::ostringstream oss;
215 _tomlString = oss.str();
219void TOMLLoader::_ensureLoaded()
const
226void TOMLLoader::_loadNodeTypeEquivalence()
228 _nodeTypeEquivalence[toml::node_type::none] =
"none";
229 _nodeTypeEquivalence[toml::node_type::date] =
"date";
230 _nodeTypeEquivalence[toml::node_type::time] =
"time";
231 _nodeTypeEquivalence[toml::node_type::table] =
"table";
232 _nodeTypeEquivalence[toml::node_type::array] =
"array";
233 _nodeTypeEquivalence[toml::node_type::string] =
"string";
234 _nodeTypeEquivalence[toml::node_type::integer] =
"integer";
235 _nodeTypeEquivalence[toml::node_type::boolean] =
"boolean";
236 _nodeTypeEquivalence[toml::node_type::date_time] =
"date_time";
237 _nodeTypeEquivalence[toml::node_type::floating_point] =
"floating_point";
#define PRETTY_INFO
Info log with details and colour.
std::ostream & operator<<(std::ostream &os, const TOMLLoader &node)
Overloads the stream insertion operator for TOMLLoader.
Contains the TOMLLoader class for handling loading and navigation of TOML data.
This is the class in charge of informing the user that the toml file they provided is invalid.
This is the class in charge of informing the user that they tried to access a non-existant toml key i...
This is the class in charge of informing the user that they tried to access a non-existant toml insta...
A utility class for parsing, navigating, and managing TOML files and data.
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.