1 #ifndef REFLECTIVE_RAPIDJSON_JSON_ERROR_HANDLING_H 2 #define REFLECTIVE_RAPIDJSON_JSON_ERROR_HANDLING_H 9 #include <c++utilities/conversion/types.h> 10 #include <c++utilities/misc/traits.h> 12 #include <rapidjson/rapidjson.h> 45 template <
typename Type,
46 Traits::EnableIf<Traits::Not<std::is_same<Type, bool>>, Traits::Any<std::is_integral<Type>, std::is_floating_point<Type>>>...>
52 template <
typename Type, Traits::EnableIfAny<std::is_same<Type,
bool>>...> constexpr
JsonType jsonType()
57 template <
typename Type, Traits::EnableIfAny<Traits::IsString<Type>, Traits::IsCString<Type>>...> constexpr
JsonType jsonType()
62 template <
typename Type,
63 Traits::EnableIf<Traits::IsIteratable<Type>,
64 Traits::Not<Traits::Any<Traits::IsString<Type>, Traits::IsSpecializationOf<Type, std::map>,
65 Traits::IsSpecializationOf<Type, std::unordered_map>>>>...>
71 template <
typename Type,
72 Traits::DisableIfAny<std::is_integral<Type>, std::is_floating_point<Type>, Traits::IsString<Type>, Traits::IsCString<Type>,
73 Traits::All<Traits::IsIteratable<Type>,
74 Traits::Not<Traits::Any<Traits::IsString<Type>, Traits::IsSpecializationOf<Type, std::map>,
75 Traits::IsSpecializationOf<Type, std::unordered_map>>>>>...>
87 case RAPIDJSON_NAMESPACE::kFalseType:
88 case RAPIDJSON_NAMESPACE::kTrueType:
90 case RAPIDJSON_NAMESPACE::kObjectType:
92 case RAPIDJSON_NAMESPACE::kArrayType:
94 case RAPIDJSON_NAMESPACE::kStringType:
96 case RAPIDJSON_NAMESPACE::kNumberType:
124 static constexpr std::size_t
noIndex = std::numeric_limits<std::size_t>::max();
134 , expectedType(expectedType)
135 , actualType(actualType)
154 template <
typename ExpectedType>
void reportTypeMismatch(RAPIDJSON_NAMESPACE::Type presentType);
168 void throwMaybe(
ThrowOn on)
const;
175 : currentRecord(
"[document]")
176 , currentMember(nullptr)
195 inline void JsonDeserializationErrors::throwMaybe(ThrowOn on)
const 197 if (static_cast<byte>(
throwOn) & static_cast<byte>(on)) {
236 #endif // REFLECTIVE_RAPIDJSON_JSON_REFLECTOR_H ThrowOn
The list of fatal error types in form of flags.
JsonDeserializationErrorKind
The JsonDeserializationErrorKind enum specifies which kind of error happend when populating variables...
const char * currentMember
The name of the member (in currentRecord) which is currently being processed.
constexpr JsonType jsonType()
const char * record
The name of the class or struct which was being processed when the error was ascertained.
JsonType
The JsonType enum specifies the JSON data type.
void reportConversionError(JsonType jsonType)
Reports a conversion error.
JsonType actualType
The actual type (might not be relevant for all error kinds).
std::size_t currentIndex
The index in the array which is currently processed.
enum ReflectiveRapidJSON::JsonDeserializationErrors::ThrowOn throwOn
JsonDeserializationErrorKind kind
Which kind of error occured.
void reportTypeMismatch(RAPIDJSON_NAMESPACE::Type presentType)
Reports a type mismatch between.
The JsonDeserializationErrors struct can be passed to fromJson() for error handling.
JsonDeserializationErrors()
Creates an empty JsonDeserializationErrors object with default context and no errors considered fatal...
JsonType expectedType
The expected type (might not be relevant for all error kinds).
static constexpr std::size_t noIndex
Indicates no array was being processed when the error occured.
void reportArraySizeMismatch()
Reports an array size mismatch.
const char * currentRecord
The name of the class or struct which is currently being processed.
The JsonDeserializationError struct describes any errors of fromJson() except such caused by invalid ...
JsonDeserializationError(JsonDeserializationErrorKind kind, JsonType expectedType, JsonType actualType, const char *record, const char *member=nullptr, std::size_t index=noIndex)
Constructs a new JsonDeserializationError.
const char * member
The name of the member which was being processed when the error was ascertained.
std::size_t index
The index in the array which was being processed when the error was ascertained.
constexpr JsonDeserializationErrors::ThrowOn operator|(JsonDeserializationErrors::ThrowOn lhs, JsonDeserializationErrors::ThrowOn rhs)
Combines to ThrowOn values.