64 template<
typename T,
typename Exception = CustomExceptions::Inval
idType>
65 std::optional<T>
unCast(
const std::any &classNode,
const bool raiseOnError =
true,
const std::string customErrorMessage =
"")
67 PRETTY_DEBUG <<
"custom error message: '" << customErrorMessage <<
"'" << std::endl;
68 if (classNode.type() !=
typeid(T)) {
70 std::string errMsg =
"The type contained in std::any does not";
71 errMsg +=
" match the expected type, Custom error message: '";
72 errMsg += customErrorMessage;
74 throw Exception(errMsg);
77 <<
" not match the expected type, Custom error message: '"
83 if (!classNode.has_value()) {
85 throw Exception(customErrorMessage +
" : " + classNode.type().name());
88 << std::string(classNode.type().name())
89 <<
"' , Custom error message : '"
96 return std::optional(std::any_cast<T>(classNode));
98 catch (std::bad_any_cast &e) {
100 throw Exception(customErrorMessage + std::string(e.what()));
103 << customErrorMessage
104 <<
"', system error: " << std::string(e.what())
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.
#define PRETTY_DEBUG
Debug log with details and colour.
#define PRETTY_WARNING
Warning log with details and colour.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
std::optional< T > unCast(const std::any &classNode, const bool raiseOnError=true, const std::string customErrorMessage="")
Casts the content of a std::any back to its original type.