Twitch SDK (Internal)
Namespaces | Classes | Typedefs | Enumerations | Functions
ttv::json Namespace Reference

Namespaces

 description
 

Classes

struct  ArraySchema
 
struct  BooleanSchema
 
struct  ColorSchema
 
struct  DateSchema
 
struct  DefaultSchemaProvider
 
struct  DefaultSchemaProvider< bool >
 
struct  DefaultSchemaProvider< FloatingPointType, std::enable_if_t< std::is_floating_point< FloatingPointType >::value > >
 
struct  DefaultSchemaProvider< IntegralType, std::enable_if_t< std::is_integral< IntegralType >::value > >
 
struct  DefaultSchemaProvider< std::string >
 
struct  DefaultSchemaProvider< std::vector< ElementType > >
 
struct  DefaultSchemaProvider< ttv::BroadcasterType >
 
struct  DefaultSchemaProvider< ttv::BroadcastPlatform >
 
struct  DefaultSchemaProvider< ttv::ChannelInfo >
 
struct  DefaultSchemaProvider< ttv::chat::BanUserError >
 
struct  DefaultSchemaProvider< ttv::chat::BitsSentEvent >
 
struct  DefaultSchemaProvider< ttv::chat::CreateRoomError >
 
struct  DefaultSchemaProvider< ttv::chat::Emoticon >
 
struct  DefaultSchemaProvider< ttv::chat::GraphQLErrorCode >
 
struct  DefaultSchemaProvider< ttv::chat::HostTargetChange >
 
struct  DefaultSchemaProvider< ttv::chat::RoomMentionInfo >
 
struct  DefaultSchemaProvider< ttv::chat::RoomRole >
 
struct  DefaultSchemaProvider< ttv::chat::SendRoomMessageError >
 
struct  DefaultSchemaProvider< ttv::chat::UnbanUserError >
 
struct  DefaultSchemaProvider< ttv::chat::UpdateRoomError >
 
struct  DefaultSchemaProvider< ttv::chat::UpdateRoomModesError >
 
struct  DefaultSchemaProvider< ttv::PreviewImages >
 
struct  DefaultSchemaProvider< ttv::StreamInfo >
 
struct  DefaultSchemaProvider< ttv::StreamType >
 
struct  DefaultSchemaProvider< ttv::UserInfo >
 
class  EnumMapping
 
struct  EnumSchema
 
class  FastWriter
 Outputs a Value in JSON format without formatting (not human friendly). More...
 
class  Features
 Configuration passed to reader and writer. This configuration object can be used to force the Reader or Writer to behave in a standard conforming way. More...
 
struct  FloatingPointSchema
 
struct  IntegerSchema
 
class  JsonField
 
class  JsonField< ValueType, RequiredType, SchemaType, 1 >
 
struct  ObjectSchema
 
struct  OptionalField
 
class  Path
 Experimental and untested: represents a "path" to access a node. More...
 
class  PathArgument
 Experimental and untested: represents an element of the "path" to access a node. More...
 
class  Reader
 Unserialize a JSON document into a Value. More...
 
struct  RequiredField
 
class  StaticString
 Lightweight wrapper to tag static string. More...
 
struct  StringSchema
 
class  StyledStreamWriter
 Writes a Value in JSON format in a human friendly way, to a stream rather than to a string. More...
 
class  StyledWriter
 Writes a Value in JSON format in a human friendly way. More...
 
class  Value
 Represents a JSON value. More...
 
class  ValueAllocator
 Experimental do not use: Allocator to customize member name and string value memory management done by Value. More...
 
class  ValueConstIterator
 const iterator for object and array value. More...
 
class  ValueIterator
 Iterator for object and array value. More...
 
class  ValueIteratorBase
 base class for Value iterators. More...
 
class  Writer
 Abstract class for writers. More...
 

Typedefs

typedef int32_t Int
 
typedef uint32_t UInt
 
typedef int64_t Int64
 
typedef uint64_t UInt64
 
template<typename ObjectType >
using DefaultSchema = typename DefaultSchemaProvider< ObjectType >::Type
 

Enumerations

enum  ValueType : uint8_t {
  nullValue = 0, intValue, uintValue, realValue,
  stringValue, booleanValue, arrayValue, objectValue
}
 Type of the value held by a Value object. More...
 
enum  CommentPlacement { commentBefore = 0, commentAfterOnSameLine, commentAfter, numberOfCommentPlacement }
 

Functions

template<typename ObjectType >
bool ToJson (const ObjectType &object, ttv::json::Value &value)
 
template<typename ObjectType >
bool ToJsonString (const ObjectType &object, std::string &jsonString)
 
template<typename ObjectType >
bool ToObject (const ttv::json::Value &value, ObjectType &object)
 
template<typename ObjectType >
bool ToObject (const std::string &jsonString, ObjectType &object)
 
template<typename ObjectType >
bool ToObject (const char *jsonString, ObjectType &object)
 
template<typename EnumType >
auto make_enum_mapping (const char *string, EnumType value)
 
template<typename SchemaType , typename RequiredType , typename ObjectType >
auto make_field (const char *key, ObjectType &field)
 
template<typename SchemaType , typename RequiredType , typename ObjectType , size_t ArraySize>
auto make_field (const std::array< const char *, ArraySize > &keyPath, ObjectType &field)
 
template<typename RequiredType , typename ObjectType >
auto make_field (const char *key, ObjectType &field)
 
template<typename RequiredType , typename ObjectType , size_t ArraySize>
auto make_field (const std::array< const char *, ArraySize > &keyPath, ObjectType &field)
 
template<typename ObjectType >
auto make_field (const char *key, ObjectType &field)
 
template<typename ObjectType , size_t ArraySize>
auto make_field (const std::array< const char *, ArraySize > &keyPath, ObjectType &field)
 
template<typename ... Args>
std::array< const char *, sizeof...(Args)> MakeKeyPath (Args... args)
 
std::istream & operator>> (std::istream &, Value &)
 Read from 'sin' into 'root'. More...
 
std::string JSON_API valueToString (Int value)
 
std::string JSON_API valueToString (UInt value)
 
std::string JSON_API valueToString (Int64 value)
 
std::string JSON_API valueToString (UInt64 value)
 
std::string JSON_API valueToString (double value)
 
std::string JSON_API valueToString (bool value)
 
std::string JSON_API valueToQuotedString (const char *value)
 
std::ostream & operator<< (std::ostream &, const Value &root)
 Output using the StyledStreamWriter. More...
 

Class Documentation

◆ ttv::json::DefaultSchemaProvider

struct ttv::json::DefaultSchemaProvider

template<typename ObjectType, typename Enable>
struct ttv::json::DefaultSchemaProvider< ObjectType, Enable >

Partial specializations of the DefaultSchemaProvider struct provide the default schema for a given type. These specializations conform to the following concept:

template <typename ObjectType>
struct DefaultSchemaProvider
{
using Type = SchemaType;
};

Where ObjectType is the type to serialize/deserialize, and the SchemaType is the desired schema to use by default for serializing and deserializing objects of ObjectType.

◆ ttv::json::DefaultSchemaProvider< bool >

struct ttv::json::DefaultSchemaProvider< bool >

template<>
struct ttv::json::DefaultSchemaProvider< bool >

Class Members
typedef BooleanSchema Type

◆ ttv::json::DefaultSchemaProvider< FloatingPointType, std::enable_if_t< std::is_floating_point< FloatingPointType >::value > >

struct ttv::json::DefaultSchemaProvider< FloatingPointType, std::enable_if_t< std::is_floating_point< FloatingPointType >::value > >

template<typename FloatingPointType>
struct ttv::json::DefaultSchemaProvider< FloatingPointType, std::enable_if_t< std::is_floating_point< FloatingPointType >::value > >

Class Members
typedef FloatingPointSchema Type

◆ ttv::json::DefaultSchemaProvider< IntegralType, std::enable_if_t< std::is_integral< IntegralType >::value > >

struct ttv::json::DefaultSchemaProvider< IntegralType, std::enable_if_t< std::is_integral< IntegralType >::value > >

template<typename IntegralType>
struct ttv::json::DefaultSchemaProvider< IntegralType, std::enable_if_t< std::is_integral< IntegralType >::value > >

Class Members
typedef IntegerSchema Type

◆ ttv::json::DefaultSchemaProvider< std::string >

struct ttv::json::DefaultSchemaProvider< std::string >

template<>
struct ttv::json::DefaultSchemaProvider< std::string >

Class Members
typedef StringSchema Type

◆ ttv::json::DefaultSchemaProvider< std::vector< ElementType > >

struct ttv::json::DefaultSchemaProvider< std::vector< ElementType > >

template<typename ElementType>
struct ttv::json::DefaultSchemaProvider< std::vector< ElementType > >

Class Members
typedef ArraySchema
< DefaultSchema< ElementType >
, ElementType >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::BroadcasterType >

struct ttv::json::DefaultSchemaProvider< ttv::BroadcasterType >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::BroadcasterType >

Class Members
typedef EnumSchema
< BroadcasterType >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::BroadcastPlatform >

struct ttv::json::DefaultSchemaProvider< ttv::BroadcastPlatform >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::BroadcastPlatform >

Class Members
typedef EnumSchema
< BroadcastPlatform >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::ChannelInfo >

struct ttv::json::DefaultSchemaProvider< ttv::ChannelInfo >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::ChannelInfo >

Class Members
typedef ObjectSchema< ChannelInfo > Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::BanUserError >

struct ttv::json::DefaultSchemaProvider< ttv::chat::BanUserError >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::BanUserError >

Class Members
typedef ObjectSchema
< BanUserError >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::BitsSentEvent >

struct ttv::json::DefaultSchemaProvider< ttv::chat::BitsSentEvent >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::BitsSentEvent >

Class Members
typedef ObjectSchema
< PubSubBitsSentEvent >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::CreateRoomError >

struct ttv::json::DefaultSchemaProvider< ttv::chat::CreateRoomError >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::CreateRoomError >

Class Members
typedef ObjectSchema
< CreateRoomError >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::Emoticon >

struct ttv::json::DefaultSchemaProvider< ttv::chat::Emoticon >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::Emoticon >

Class Members
typedef ObjectSchema< Emoticon > Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::GraphQLErrorCode >

struct ttv::json::DefaultSchemaProvider< ttv::chat::GraphQLErrorCode >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::GraphQLErrorCode >

Class Members
typedef EnumSchema
< GraphQLErrorCode >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::HostTargetChange >

struct ttv::json::DefaultSchemaProvider< ttv::chat::HostTargetChange >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::HostTargetChange >

Class Members
typedef ObjectSchema
< PubSubHostTargetChange >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::RoomMentionInfo >

struct ttv::json::DefaultSchemaProvider< ttv::chat::RoomMentionInfo >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::RoomMentionInfo >

Class Members
typedef ObjectSchema
< ChatRoomMentionInfo >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::RoomRole >

struct ttv::json::DefaultSchemaProvider< ttv::chat::RoomRole >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::RoomRole >

Class Members
typedef EnumSchema< ChatRoomRole > Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::SendRoomMessageError >

struct ttv::json::DefaultSchemaProvider< ttv::chat::SendRoomMessageError >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::SendRoomMessageError >

Class Members
typedef ObjectSchema
< SendRoomMessageError >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::UnbanUserError >

struct ttv::json::DefaultSchemaProvider< ttv::chat::UnbanUserError >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::UnbanUserError >

Class Members
typedef ObjectSchema
< UnbanUserError >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::UpdateRoomError >

struct ttv::json::DefaultSchemaProvider< ttv::chat::UpdateRoomError >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::UpdateRoomError >

Class Members
typedef ObjectSchema
< UpdateRoomError >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::chat::UpdateRoomModesError >

struct ttv::json::DefaultSchemaProvider< ttv::chat::UpdateRoomModesError >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::chat::UpdateRoomModesError >

Class Members
typedef ObjectSchema
< UpdateRoomModesError >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::PreviewImages >

struct ttv::json::DefaultSchemaProvider< ttv::PreviewImages >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::PreviewImages >

Class Members
typedef ObjectSchema
< PreviewImages >
Type

◆ ttv::json::DefaultSchemaProvider< ttv::StreamInfo >

struct ttv::json::DefaultSchemaProvider< ttv::StreamInfo >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::StreamInfo >

Class Members
typedef ObjectSchema< StreamInfo > Type

◆ ttv::json::DefaultSchemaProvider< ttv::StreamType >

struct ttv::json::DefaultSchemaProvider< ttv::StreamType >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::StreamType >

Class Members
typedef EnumSchema< StreamType > Type

◆ ttv::json::DefaultSchemaProvider< ttv::UserInfo >

struct ttv::json::DefaultSchemaProvider< ttv::UserInfo >

template<>
struct ttv::json::DefaultSchemaProvider< ttv::UserInfo >

Class Members
typedef ObjectSchema< UserInfo > Type

Typedef Documentation

◆ DefaultSchema

template<typename ObjectType >
using ttv::json::DefaultSchema = typedef typename DefaultSchemaProvider<ObjectType>::Type

A convenience alias to make for easier syntax when getting the DefaultSchema for a type.

◆ Int

typedef int32_t ttv::json::Int

◆ Int64

typedef int64_t ttv::json::Int64

◆ UInt

typedef uint32_t ttv::json::UInt

◆ UInt64

typedef uint64_t ttv::json::UInt64

Enumeration Type Documentation

◆ CommentPlacement

Enumerator
commentBefore 

a comment placed on the line before a value

commentAfterOnSameLine 

a comment just after a value on the same line

commentAfter 

a comment on the line after a value (only make sense for root value)

numberOfCommentPlacement 

◆ ValueType

enum ttv::json::ValueType : uint8_t

Type of the value held by a Value object.

Enumerator
nullValue 

'null' value

intValue 

signed integer value

uintValue 

unsigned integer value

realValue 

double value

stringValue 

UTF-8 string value.

booleanValue 

bool value

arrayValue 

array value (ordered list)

objectValue 

object value (collection of name/value pairs).

Function Documentation

◆ make_enum_mapping()

template<typename EnumType >
auto ttv::json::make_enum_mapping ( const char *  string,
EnumType  value 
)

Create an EnumMapping between a string value expected in JSON and the corresponding enumeration value.

Parameters
stringThe expected string to find in JSON.
valueThe corresponding enumeration value.

◆ make_field() [1/6]

template<typename SchemaType , typename RequiredType , typename ObjectType >
auto ttv::json::make_field ( const char *  key,
ObjectType &  field 
)

Create a JSONField explicitly defining the schema to use and whether the field is required.

Template Parameters
RequiredTypeUsed to specify if parsing should be aborted if this field fails to parse. Should be of type RequiredField or OptionalField.
SchemaTypeThe scheme used to serialize or deserialize.
ObjectTypeThe C++ object type to bind to (automatically inferred from arguments).

◆ make_field() [2/6]

template<typename SchemaType , typename RequiredType , typename ObjectType , size_t ArraySize>
auto ttv::json::make_field ( const std::array< const char *, ArraySize > &  keyPath,
ObjectType &  field 
)

◆ make_field() [3/6]

template<typename RequiredType , typename ObjectType >
auto ttv::json::make_field ( const char *  key,
ObjectType &  field 
)

Create a JSONField with the default schema and explicitly define whether it is required.

Template Parameters
RequiredUsed to specify if parsing should be aborted if this field fails to parse.
ObjectTypeThe C++ object type to bind to (automatically inferred from arguments).

◆ make_field() [4/6]

template<typename RequiredType , typename ObjectType , size_t ArraySize>
auto ttv::json::make_field ( const std::array< const char *, ArraySize > &  keyPath,
ObjectType &  field 
)

◆ make_field() [5/6]

template<typename ObjectType >
auto ttv::json::make_field ( const char *  key,
ObjectType &  field 
)

Create a JSONField with the default schema that is not required.

Template Parameters
ObjectTypeThe C++ object type to bind to (automatically inferred from arguments).

◆ make_field() [6/6]

template<typename ObjectType , size_t ArraySize>
auto ttv::json::make_field ( const std::array< const char *, ArraySize > &  keyPath,
ObjectType &  field 
)

◆ MakeKeyPath()

template<typename ... Args>
std::array< const char *, sizeof...(Args)> ttv::json::MakeKeyPath ( Args...  args)

Helper function to create an array of proper size based on the number of key path values passed in.

◆ operator<<()

std::ostream& ttv::json::operator<< ( std::ostream &  ,
const Value root 
)

Output using the StyledStreamWriter.

See also
json::operator>>()

◆ operator>>()

std::istream& ttv::json::operator>> ( std::istream &  ,
Value  
)

Read from 'sin' into 'root'.

Always keep comments from the input JSON.

This can be used to read a file into a particular sub-object. For example:

json::Value root;
cin >> root["dir"]["file"];
cout << root;

Result:

{
"dir": {
    "file": {
    // The input stream JSON would be nested here.
    }
}
}
Exceptions
std::exceptionon parse error.
See also
json::operator<<()

◆ ToJson()

template<typename ObjectType >
bool ttv::json::ToJson ( const ObjectType &  object,
ttv::json::Value value 
)

Public convenience functions for serializing and unserializing objects using the default schema for the passed-in object. Translates an object into JSON using its default schema.

Parameters
[in]objectThe input object to serialize into JSON.
[out]valueThe output JSON value, or a null value if parsing failed.
Returns
Whether parsing succeeded.

◆ ToJsonString()

template<typename ObjectType >
bool ttv::json::ToJsonString ( const ObjectType &  object,
std::string &  jsonString 
)

Translates an object into a JSON string using the default schema.

Parameters
[in]objectThe input object to serialize into JSON.
[out]jsonStringThe output JSON string. This value is not modified if parsing fails.
Returns
Whether parsing succeed.

◆ ToObject() [1/3]

template<typename ObjectType >
bool ttv::json::ToObject ( const ttv::json::Value value,
ObjectType &  object 
)

Deserializes JSON into an object using the object's default schema.

Parameters
[in]valueThe JSON value to deserialize.
[out]objectThe deserialized object, or a default constructed object if the parsing fails.
Returns
Whether parsing succeeded.

◆ ToObject() [2/3]

template<typename ObjectType >
bool ttv::json::ToObject ( const std::string &  jsonString,
ObjectType &  object 
)

Deserializes JSON into an object using the object's default schema.

Parameters
[in]jsonStringThe JSON string to deserialize.
[out]objectThe deserialized object, or a default constructed object if the parsing fails.
Returns
Whether parsing succeeded.

◆ ToObject() [3/3]

template<typename ObjectType >
bool ttv::json::ToObject ( const char *  jsonString,
ObjectType &  object 
)

Deserializes JSON into an object using the object's default schema.

Parameters
[in]jsonStringThe null-terminated JSON string to deserialize.
[out]objectThe deserialized object, or a default constructed object if the parsing fails.
Returns
Whether parsing succeeded.

◆ valueToQuotedString()

std::string JSON_API ttv::json::valueToQuotedString ( const char *  value)

◆ valueToString() [1/6]

std::string JSON_API ttv::json::valueToString ( Int  value)

◆ valueToString() [2/6]

std::string JSON_API ttv::json::valueToString ( UInt  value)

◆ valueToString() [3/6]

std::string JSON_API ttv::json::valueToString ( Int64  value)

◆ valueToString() [4/6]

std::string JSON_API ttv::json::valueToString ( UInt64  value)

◆ valueToString() [5/6]

std::string JSON_API ttv::json::valueToString ( double  value)

◆ valueToString() [6/6]

std::string JSON_API ttv::json::valueToString ( bool  value)