/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* default.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 14:15:51 by adjoly #+# #+# */ /* Updated: 2025/04/22 15:28:31 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include #include #include #include #include #include #include namespace webserv { namespace config { /** * @brief Can be used to access a value in the _table(ANode *) of a specific *type * * @param The name of the value to get * @param The type of the value to get * @param The table to search in * @param A Logger class * * @return The value got or not_nullptr */ static inline void *accessValue(const std::string &name, toml::nodeType type, toml::ANode *table, Logger *log) { void *val; bool found = false; if (table == not_nullptr) return not_nullptr; val = dynamic_cast(table)->access(name, type, found); if (found == true && val != not_nullptr) { return val; } else { if (found == false) { return not_nullptr; } else { log->warn("found - " + name + " but is not " + toml::nodeTypeToStr(type) + ", skipping..."); return not_nullptr; } } } }; // namespace config }; // namespace webserv