Reflection for RapidJSON 0.0.16
Reflection for serializing/deserializing with RapidJSON
Loading...
Searching...
No Matches
ReflectiveRapidJSON Namespace Reference

Namespaces

namespace  BinaryReflector
 The BinaryReflector namespace contains BinaryReader and BinaryWriter for automatic binary (de)serialization.
 
namespace  JsonReflector
 The JsonReflector namespace contains helper functions to ease the use of RapidJSON for automatic (de)serialization.
 

Classes

struct  AdaptedBinarySerializable
 The AdaptedBinarySerializable class allows considering 3rd party classes as serializable. More...
 
struct  AdaptedJsonSerializable
 The AdaptedJsonSerializable class allows considering 3rd party classes as serializable. More...
 
struct  BinarySerializable
 The BinarySerializable class provides the CRTP-base for (de)serializable objects. More...
 
struct  JsonDeserializationError
 The JsonDeserializationError struct describes any errors of fromJson() except such caused by invalid JSON. More...
 
struct  JsonDeserializationErrors
 The JsonDeserializationErrors struct can be passed to fromJson() for error handling. More...
 
struct  JsonSerializable
 The JsonSerializable class provides the CRTP-base for (de)serializable objects. More...
 
struct  TreatAsMapOrHash
 The TreatAsMapOrHash class allows treating custom classes as std::map or std::unordered_map. More...
 
struct  TreatAsMultiMapOrHash
 The TreatAsMultiMapOrHash class allows treating custom classes as std::multimap or std::unordered_multimap. More...
 
struct  TreatAsMultiSet
 The TreatAsMultiSet class allows treating custom classes as std::multiset or std::unordered_multiset. More...
 
struct  TreatAsSet
 The TreatAsSet class allows treating custom classes as std::set or std::unordered_set. More...
 
struct  Versioning
 
struct  Versioning< Type, true >
 
struct  VersionNotSupported
 

Typedefs

template<typename Type >
using IsMapOrHash = Traits::Any<Traits::IsSpecializationOf<Type, std::map>, Traits::IsSpecializationOf<Type, std::unordered_map>, TreatAsMapOrHash<Type>>
 
template<typename Type >
using IsMultiMapOrHash
 
template<typename Type >
using IsSet = Traits::Any<Traits::IsSpecializationOf<Type, std::set>, Traits::IsSpecializationOf<Type, std::unordered_set>, TreatAsSet<Type>>
 
template<typename Type >
using IsMultiSet = Traits::Any<Traits::IsSpecializationOf<Type, std::multiset>, Traits::IsSpecializationOf<Type, std::unordered_multiset>, TreatAsMultiSet<Type>>
 
template<typename Type >
using IsArrayOrSet
 
template<typename Type >
using IsArray
 
template<typename Type >
using IsIteratableExceptString
 
template<typename Type >
using IsVariant = Traits::All<Traits::IsSpecializationOf<Type, std::variant>>
 
using BinaryVersion = std::uint64_t
 
using BinaryVersionNotSupported = VersionNotSupported<BinaryVersion>
 

Enumerations

enum class  JsonDeserializationErrorKind : std::uint8_t {
  TypeMismatch , ArraySizeMismatch , ConversionError , UnexpectedDuplicate ,
  InvalidVariantObject , InvalidVariantIndex
}
 The JsonDeserializationErrorKind enum specifies which kind of error happend when populating variables from parsing results. More...
 
enum class  JsonType : std::uint8_t {
  Null , Number , Bool , String ,
  Array , Object
}
 The JsonType enum specifies the JSON data type. More...
 

Functions

 CPP_UTILITIES_TRAITS_DEFINE_TYPE_CHECK (IsVersioned, T::version)
 
template<typename Type , Traits::EnableIf< std::is_base_of< JsonSerializable< Type >, Type > > * = nullptr>
JsonSerializable< Type > & as (Type &serializable)
 Helps to disambiguate when inheritance is used.
 
template<typename Type , Traits::EnableIf< std::is_base_of< JsonSerializable< Type >, Type > > * = nullptr>
const JsonSerializable< Type > & as (const Type &serializable)
 Helps to disambiguate when inheritance is used.
 
template<typename Type , Traits::EnableIf< Traits::Not< std::is_same< Type, bool > >, Traits::Any< std::is_integral< Type >, std::is_floating_point< Type > > > * = nullptr>
constexpr JsonType jsonType ()
 
constexpr JsonType jsonType (RAPIDJSON_NAMESPACE::Type type)
 Maps the type info provided by RapidJSON to JsonType.
 
constexpr JsonDeserializationErrors::ThrowOn operator| (JsonDeserializationErrors::ThrowOn lhs, JsonDeserializationErrors::ThrowOn rhs)
 Combines to ThrowOn values.
 
std::string_view jsonTypeToString (JsonType jsonType)
 
std::string formatJsonDeserializationError (const JsonDeserializationError &error)
 
 REFLECTIVE_RAPIDJSON_TREAT_AS_MAP_OR_HASH (Foo)
 
 REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_MAP_OR_HASH (Foo)
 
 REFLECTIVE_RAPIDJSON_TREAT_AS_SET (Bar)
 
 REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_SET (Foo)
 

Typedef Documentation

◆ BinaryVersion

using ReflectiveRapidJSON::BinaryVersion = std::uint64_t

Definition at line 38 of file reflector.h.

◆ BinaryVersionNotSupported

◆ IsArray

template<typename Type >
using ReflectiveRapidJSON::IsArray
Initial value:
Traits::All<Traits::IsIteratable<Type>, Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string>>,
Traits::Not<IsMapOrHash<Type>>, Traits::Not<IsMultiMapOrHash<Type>>, Traits::Not<IsSet<Type>>, Traits::Not<IsMultiSet<Type>>>

Definition at line 52 of file traits.h.

◆ IsArrayOrSet

template<typename Type >
using ReflectiveRapidJSON::IsArrayOrSet
Initial value:
Traits::Any<
Traits::All<Traits::IsIteratable<Type>, Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string>>,
Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string_view>>, Traits::Not<IsMapOrHash<Type>>, Traits::Not<IsMultiMapOrHash<Type>>>,
TreatAsSet<Type>, TreatAsMultiSet<Type>>

Definition at line 47 of file traits.h.

◆ IsIteratableExceptString

template<typename Type >
using ReflectiveRapidJSON::IsIteratableExceptString
Initial value:
Traits::All<Traits::IsIteratable<Type>, Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string>>,
Traits::Not<Traits::IsSpecializationOf<Type, std::basic_string>>>

Definition at line 55 of file traits.h.

◆ IsMapOrHash

template<typename Type >
using ReflectiveRapidJSON::IsMapOrHash = Traits::Any<Traits::IsSpecializationOf<Type, std::map>, Traits::IsSpecializationOf<Type, std::unordered_map>, TreatAsMapOrHash<Type>>

Definition at line 38 of file traits.h.

◆ IsMultiMapOrHash

template<typename Type >
using ReflectiveRapidJSON::IsMultiMapOrHash
Initial value:
Traits::Any<Traits::IsSpecializationOf<Type, std::multimap>, Traits::IsSpecializationOf<Type, std::unordered_multimap>,
TreatAsMultiMapOrHash<Type>>

Definition at line 40 of file traits.h.

◆ IsMultiSet

template<typename Type >
using ReflectiveRapidJSON::IsMultiSet = Traits::Any<Traits::IsSpecializationOf<Type, std::multiset>, Traits::IsSpecializationOf<Type, std::unordered_multiset>, TreatAsMultiSet<Type>>

Definition at line 45 of file traits.h.

◆ IsSet

template<typename Type >
using ReflectiveRapidJSON::IsSet = Traits::Any<Traits::IsSpecializationOf<Type, std::set>, Traits::IsSpecializationOf<Type, std::unordered_set>, TreatAsSet<Type>>

Definition at line 43 of file traits.h.

◆ IsVariant

template<typename Type >
using ReflectiveRapidJSON::IsVariant = Traits::All<Traits::IsSpecializationOf<Type, std::variant>>

Definition at line 57 of file traits.h.

Enumeration Type Documentation

◆ JsonDeserializationErrorKind

enum class ReflectiveRapidJSON::JsonDeserializationErrorKind : std::uint8_t
strong

The JsonDeserializationErrorKind enum specifies which kind of error happend when populating variables from parsing results.

Enumerator
TypeMismatch 

The expected type does not match the type actually present in the JSON document.

ArraySizeMismatch 

The expected array size does not match the actual size of the JSON array. A fixed size is expected when deserializing an std::tuple.

ConversionError 

The expected type matches the type present in the JSON document, but further conversion of the value failed.

UnexpectedDuplicate 

The expected type matches the type present in the JSON document, but the value can not be added to the container because it is already present and duplicates are not allowed.

InvalidVariantObject 

The present object is supposed to represent an std::variant but lacks the index or data member.

InvalidVariantIndex 

The present variant index is not a number of outside of the expected range.

Definition at line 24 of file errorhandling.h.

◆ JsonType

enum class ReflectiveRapidJSON::JsonType : std::uint8_t
strong

The JsonType enum specifies the JSON data type.

Remarks
This is currently only used for error handling to propagate expected and actual types in case of a mismatch.
Enumerator
Null 
Number 
Bool 
String 
Array 
Object 

Definition at line 37 of file errorhandling.h.

Function Documentation

◆ as() [1/2]

template<typename Type , Traits::EnableIf< std::is_base_of< JsonSerializable< Type >, Type > > * = nullptr>
const JsonSerializable< Type > & ReflectiveRapidJSON::as ( const Type & serializable)

Helps to disambiguate when inheritance is used.

Definition at line 110 of file serializable.h.

◆ as() [2/2]

template<typename Type , Traits::EnableIf< std::is_base_of< JsonSerializable< Type >, Type > > * = nullptr>
JsonSerializable< Type > & ReflectiveRapidJSON::as ( Type & serializable)

Helps to disambiguate when inheritance is used.

Definition at line 101 of file serializable.h.

◆ CPP_UTILITIES_TRAITS_DEFINE_TYPE_CHECK()

ReflectiveRapidJSON::CPP_UTILITIES_TRAITS_DEFINE_TYPE_CHECK ( IsVersioned ,
T::version  )

◆ formatJsonDeserializationError()

std::string ReflectiveRapidJSON::formatJsonDeserializationError ( const JsonDeserializationError & error)
inline

Definition at line 37 of file errorformatting.h.

◆ jsonType() [1/2]

template<typename Type , Traits::EnableIf< Traits::Not< std::is_same< Type, bool > >, Traits::Any< std::is_integral< Type >, std::is_floating_point< Type > > > * = nullptr>
JsonType ReflectiveRapidJSON::jsonType ( )
constexpr

Definition at line 50 of file errorhandling.h.

◆ jsonType() [2/2]

JsonType ReflectiveRapidJSON::jsonType ( RAPIDJSON_NAMESPACE::Type type)
constexpr

Maps the type info provided by RapidJSON to JsonType.

Definition at line 87 of file errorhandling.h.

◆ jsonTypeToString()

std::string_view ReflectiveRapidJSON::jsonTypeToString ( JsonType jsonType)
inline

Definition at line 17 of file errorformatting.h.

◆ operator|()

Combines to ThrowOn values.

Definition at line 197 of file errorhandling.h.

◆ REFLECTIVE_RAPIDJSON_TREAT_AS_MAP_OR_HASH()

ReflectiveRapidJSON::REFLECTIVE_RAPIDJSON_TREAT_AS_MAP_OR_HASH ( Foo )

◆ REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_MAP_OR_HASH()

ReflectiveRapidJSON::REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_MAP_OR_HASH ( Foo )

◆ REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_SET()

ReflectiveRapidJSON::REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_SET ( Foo )

◆ REFLECTIVE_RAPIDJSON_TREAT_AS_SET()

ReflectiveRapidJSON::REFLECTIVE_RAPIDJSON_TREAT_AS_SET ( Bar )