Reflection for RapidJSON  0.0.15
Reflection for serializing/deserializing with RapidJSON
Public Types | Public Member Functions | Public Attributes | List of all members
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  ThrowOn : std::uint8_t {
  ThrowOn::None = 0, ThrowOn::TypeMismatch = 0x1, ThrowOn::ArraySizeMismatch = 0x2, ThrowOn::ConversionError = 0x4,
  ThrowOn::UnexpectedDuplicate = 0x8, ThrowOn::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. More...
 
template<typename ExpectedType >
void reportTypeMismatch (RAPIDJSON_NAMESPACE::Type presentType)
 Reports a type mismatch between. More...
 
void reportArraySizeMismatch ()
 Reports an array size mismatch. More...
 
void reportConversionError (JsonType jsonType)
 Reports a conversion error. More...
 
void reportUnexpectedDuplicate (JsonType jsonType)
 Reports an unexpected duplicate. More...
 

Public Attributes

const char * currentRecord
 The name of the class or struct which is currently being processed. More...
 
const char * currentMember
 The name of the member (in currentRecord) which is currently being processed. More...
 
std::size_t currentIndex
 The index in the array which is currently processed. More...
 
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 169 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 185 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 228 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 239 of file errorhandling.h.

◆ reportTypeMismatch()

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

Reports a type mismatch between.

Template Parameters
ExpectedTypeand presentType within the current context.

Definition at line 216 of file errorhandling.h.

◆ 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 250 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 167 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 165 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 163 of file errorhandling.h.

◆ throwOn

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

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