Reflection for RapidJSON 0.0.16
Reflection for serializing/deserializing with RapidJSON
Loading...
Searching...
No Matches
ReflectiveRapidJSON::JsonDeserializationErrors Struct Reference

The JsonDeserializationErrors struct can be passed to fromJson() for error handling. More...

#include <errorhandling.h>

Inheritance diagram for ReflectiveRapidJSON::JsonDeserializationErrors:
[legend]
Collaboration diagram for ReflectiveRapidJSON::JsonDeserializationErrors:
[legend]

Public Types

enum class  ThrowOn : std::uint8_t {
  None = 0 , TypeMismatch = 0x1 , ArraySizeMismatch = 0x2 , ConversionError = 0x4 ,
  UnexpectedDuplicate = 0x8 , All = 0xFF
}
 The list of fatal error types in form of flags. More...
 

Public Member Functions

 JsonDeserializationErrors ()
 Creates an empty JsonDeserializationErrors object with default context and no errors considered fatal.
 
template<typename ExpectedType >
void reportTypeMismatch (RAPIDJSON_NAMESPACE::Type presentType)
 Reports a type mismatch between.
 
template<RAPIDJSON_NAMESPACE::Type expectedType>
void reportTypeMismatch (RAPIDJSON_NAMESPACE::Type presentType)
 
void reportArraySizeMismatch ()
 Reports an array size mismatch.
 
void reportConversionError (JsonType jsonType)
 Reports a conversion error.
 
void reportUnexpectedDuplicate (JsonType jsonType)
 Reports an unexpected duplicate.
 

Public Attributes

const char * currentRecord
 The name of the class or struct which is currently being processed.
 
const char * currentMember
 The name of the member (in currentRecord) which is currently being processed.
 
std::size_t currentIndex
 The index in the array which is currently processed.
 
enum ReflectiveRapidJSON::JsonDeserializationErrors::ThrowOn throwOn
 

Detailed Description

The JsonDeserializationErrors struct can be passed to fromJson() for error handling.

When passed to fromJson() and an error occurs, a JsonDeserializationError is added to this object. If throwOn is set, the JsonDeserializationError is additionally thrown making the error fatal.

Remarks
Errors due to invalid JSON always lead to a RAPIDJSON_NAMESPACE::ParseResult object being thrown. So this only concerns errors listed in JsonDeserializationErrorKind.

Definition at line 154 of file errorhandling.h.

Member Enumeration Documentation

◆ ThrowOn

The list of fatal error types in form of flags.

Enumerator
None 
TypeMismatch 
ArraySizeMismatch 
ConversionError 
UnexpectedDuplicate 
All 

Definition at line 170 of file errorhandling.h.

Constructor & Destructor Documentation

◆ JsonDeserializationErrors()

ReflectiveRapidJSON::JsonDeserializationErrors::JsonDeserializationErrors ( )
inline

Creates an empty JsonDeserializationErrors object with default context and no errors considered fatal.

Definition at line 186 of file errorhandling.h.

Member Function Documentation

◆ reportArraySizeMismatch()

void ReflectiveRapidJSON::JsonDeserializationErrors::reportArraySizeMismatch ( )
inline

Reports an array size mismatch.

Todo
Allow specifying expected and actual size.
Remarks
This can happen when mapping a JSON array to a C++ tuple.

Definition at line 239 of file errorhandling.h.

◆ reportConversionError()

void ReflectiveRapidJSON::JsonDeserializationErrors::reportConversionError ( JsonType jsonType)
inline

Reports a conversion error.

An error of that kind occurs when the JSON type matched the expected type, but further conversion of the value has failed.

Todo
Allow specifying the error message.
Remarks
This can happen when doing custom mapping (eg. when interpreting a JSON string as time value).

Definition at line 250 of file errorhandling.h.

◆ reportTypeMismatch() [1/2]

template<RAPIDJSON_NAMESPACE::Type expectedType>
void ReflectiveRapidJSON::JsonDeserializationErrors::reportTypeMismatch ( RAPIDJSON_NAMESPACE::Type presentType)
inline

Reports a type mismatch between.

Template Parameters
ExpectedTypeand presentType within the current context.
expectedTypeand presentType within the current context.

Definition at line 217 of file errorhandling.h.

◆ reportTypeMismatch() [2/2]

template<RAPIDJSON_NAMESPACE::Type expectedType>
void ReflectiveRapidJSON::JsonDeserializationErrors::reportTypeMismatch ( RAPIDJSON_NAMESPACE::Type presentType)

◆ reportUnexpectedDuplicate()

void ReflectiveRapidJSON::JsonDeserializationErrors::reportUnexpectedDuplicate ( JsonType jsonType)
inline

Reports an unexpected duplicate.

An error of that kind occurs when the JSON type matched the expected type, but the value can not be inserted in the container because it is already present and duplicates are not allowed.

Todo
Allow specifying the error message.
Remarks
This can happen when doing custom mapping (eg. when interpreting a JSON string as time value).

Definition at line 261 of file errorhandling.h.

Member Data Documentation

◆ currentIndex

std::size_t ReflectiveRapidJSON::JsonDeserializationErrors::currentIndex

The index in the array which is currently processed.

Definition at line 168 of file errorhandling.h.

◆ currentMember

const char* ReflectiveRapidJSON::JsonDeserializationErrors::currentMember

The name of the member (in currentRecord) which is currently being processed.

Definition at line 166 of file errorhandling.h.

◆ currentRecord

const char* ReflectiveRapidJSON::JsonDeserializationErrors::currentRecord

The name of the class or struct which is currently being processed.

Definition at line 164 of file errorhandling.h.

◆ throwOn

enum ReflectiveRapidJSON::JsonDeserializationErrors::ThrowOn ReflectiveRapidJSON::JsonDeserializationErrors::throwOn

The documentation for this struct was generated from the following file: