Twitch SDK (Internal)
Static Public Member Functions | Static Private Member Functions | List of all members
ttv::json::EnumSchema< EnumDescription > Struct Template Reference

#include <jsonserialization.h>

Static Public Member Functions

template<typename EnumType >
static bool Parse (const ttv::json::Value &value, EnumType &output)
 
template<typename EnumType >
static bool Emit (EnumType input, ttv::json::Value &value)
 

Static Private Member Functions

template<typename MapTuple , typename EnumType >
static bool FindEnumMatch (const MapTuple &tuple, const ttv::json::Value &value, EnumType &output)
 
template<int index, typename MapTuple , typename EnumType >
static std::enable_if_t<(index< std::tuple_size< MapTuple >::value), bool > FindEnumMatchFromIndex (const MapTuple &tuple, const ttv::json::Value &value, EnumType &output)
 
template<int index, typename MapTuple , typename EnumType >
static std::enable_if_t<(index >=std::tuple_size< MapTuple >::value), bool > FindEnumMatchFromIndex (const MapTuple &, const ttv::json::Value &, EnumType &output)
 
template<typename Description , typename EnumType , typename = decltype(Description::GetFallbackValue())>
static bool ApplyDefault (EnumType &output, int)
 
template<typename Description , typename EnumType >
static bool ApplyDefault (EnumType &, long)
 
template<typename MapTuple , typename EnumType >
static bool FindStringMatch (const MapTuple &tuple, EnumType input, ttv::json::Value &value)
 
template<int index, typename MapTuple , typename EnumType >
static std::enable_if_t<(index< std::tuple_size< MapTuple >::value), bool > FindStringMatchFromIndex (const MapTuple &tuple, EnumType input, ttv::json::Value &value)
 
template<int index, typename MapTuple , typename EnumType >
static std::enable_if_t<(index >=std::tuple_size< MapTuple >::value), bool > FindStringMatchFromIndex (const MapTuple &, EnumType, ttv::json::Value &)
 

Detailed Description

template<typename EnumDescription>
struct ttv::json::EnumSchema< EnumDescription >

Enum Schema

The EnumSchema is a reusable schema that takes in an EnumDescription type, which conforms to the following concept:

struct EnumDescription
{
static auto EnumMap() const;
static auto GetDefaultValue() const; // Optional
};

The implementation of the static method "EnumField" should return a tuple of "EnumMapping" objects that map the expected strings from the JSON and how they map to individual enumeration values.

The implementation of the static method "GetDefaultValue" is optional. If it is implemented, it will be used when a string is found that does not match any specified in the EnumMap, and parsing will will succeed. If it is not implemented, parsing will fail if the string is not found in the EnumMap.

Member Function Documentation

◆ ApplyDefault() [1/2]

template<typename EnumDescription >
template<typename Description , typename EnumType , typename = decltype(Description::GetFallbackValue())>
static bool ttv::json::EnumSchema< EnumDescription >::ApplyDefault ( EnumType &  output,
int   
)
inlinestaticprivate

◆ ApplyDefault() [2/2]

template<typename EnumDescription >
template<typename Description , typename EnumType >
static bool ttv::json::EnumSchema< EnumDescription >::ApplyDefault ( EnumType &  ,
long   
)
inlinestaticprivate

◆ Emit()

template<typename EnumDescription >
template<typename EnumType >
static bool ttv::json::EnumSchema< EnumDescription >::Emit ( EnumType  input,
ttv::json::Value value 
)
inlinestatic

◆ FindEnumMatch()

template<typename EnumDescription >
template<typename MapTuple , typename EnumType >
static bool ttv::json::EnumSchema< EnumDescription >::FindEnumMatch ( const MapTuple &  tuple,
const ttv::json::Value value,
EnumType &  output 
)
inlinestaticprivate

◆ FindEnumMatchFromIndex() [1/2]

template<typename EnumDescription >
template<int index, typename MapTuple , typename EnumType >
static std::enable_if_t<(index < std::tuple_size<MapTuple>::value), bool> ttv::json::EnumSchema< EnumDescription >::FindEnumMatchFromIndex ( const MapTuple &  tuple,
const ttv::json::Value value,
EnumType &  output 
)
inlinestaticprivate

◆ FindEnumMatchFromIndex() [2/2]

template<typename EnumDescription >
template<int index, typename MapTuple , typename EnumType >
static std::enable_if_t<(index >= std::tuple_size<MapTuple>::value), bool> ttv::json::EnumSchema< EnumDescription >::FindEnumMatchFromIndex ( const MapTuple &  ,
const ttv::json::Value ,
EnumType &  output 
)
inlinestaticprivate

◆ FindStringMatch()

template<typename EnumDescription >
template<typename MapTuple , typename EnumType >
static bool ttv::json::EnumSchema< EnumDescription >::FindStringMatch ( const MapTuple &  tuple,
EnumType  input,
ttv::json::Value value 
)
inlinestaticprivate

◆ FindStringMatchFromIndex() [1/2]

template<typename EnumDescription >
template<int index, typename MapTuple , typename EnumType >
static std::enable_if_t<(index < std::tuple_size<MapTuple>::value), bool> ttv::json::EnumSchema< EnumDescription >::FindStringMatchFromIndex ( const MapTuple &  tuple,
EnumType  input,
ttv::json::Value value 
)
inlinestaticprivate

◆ FindStringMatchFromIndex() [2/2]

template<typename EnumDescription >
template<int index, typename MapTuple , typename EnumType >
static std::enable_if_t<(index >= std::tuple_size<MapTuple>::value), bool> ttv::json::EnumSchema< EnumDescription >::FindStringMatchFromIndex ( const MapTuple &  ,
EnumType  ,
ttv::json::Value  
)
inlinestaticprivate

◆ Parse()

template<typename EnumDescription >
template<typename EnumType >
static bool ttv::json::EnumSchema< EnumDescription >::Parse ( const ttv::json::Value value,
EnumType &  output 
)
inlinestatic

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