Botcraft 1.21.4
Loading...
Searching...
No Matches
ProtocolCraft::Json::Value Class Reference

Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant directly so we can better control which constructors are allowed. More...

#include <Json.hpp>

Public Member Functions

 Value (std::nullptr_t=nullptr)
 
 Value (std::string_view s)
 
 Value (const std::string &s)
 
 Value (std::string &&s)
 
 Value (const char *s)
 
 Value (const bool b)
 
 Value (const Object &o)
 
 Value (Object &&o)
 
 Value (const Array &a)
 
 Value (Array &&a)
 
 Value (const std::initializer_list< Value > &init)
 
 Value (const NetworkType &o)
 
template<template< typename, typename > class C, typename T , typename A = std::allocator<T>, std::enable_if_t< std::is_convertible_v< T, Value >, bool > = true>
 Value (const C< T, A > &c)
 
template<typename T , size_t N, std::enable_if_t< std::is_convertible_v< T, Value >, bool > = true>
 Value (const std::array< T, N > &v)
 
template<typename T , std::enable_if_t< std::is_convertible_v< T, Value >, bool > = true>
 Value (const std::map< std::string, T > &m)
 
template<typename T , std::enable_if_t< std::is_integral_v< T > &&std::is_unsigned_v< T >, bool > = true>
 Value (const T u)
 
template<typename T , std::enable_if_t<(std::is_integral_v< T > &&std::is_signed_v< T >)||std::is_enum_v< T >, bool > = true>
 Value (const T i)
 
template<typename T , std::enable_if_t< std::is_floating_point_v< T >, bool > = true>
 Value (const T f)
 
template<typename T , std::enable_if_t<!std::is_same_v< T, std::monostate > &&!std::is_same_v< T, Object > &&!std::is_same_v< T, Array > &&!std::is_same_v< T, std::string >, bool > = true>
get () const
 
template<typename T = double, std::enable_if_t< std::is_integral_v< T >||std::is_floating_point_v< T >, bool > = true>
get_number () const
 
template<typename T , std::enable_if_t< std::is_same_v< T, Object >||std::is_same_v< T, Array >||std::is_same_v< T, std::string >, bool > = true>
T & get ()
 
template<typename T , std::enable_if_t< std::is_same_v< T, Object >||std::is_same_v< T, Array >||std::is_same_v< T, std::string >, bool > = true>
const T & get () const
 
Objectget_object ()
 
Arrayget_array ()
 
std::string & get_string ()
 
const Objectget_object () const
 
const Arrayget_array () const
 
const std::string & get_string () const
 
template<typename T >
bool is () const
 
bool is_null () const
 
bool is_string () const
 
bool is_object () const
 
bool is_array () const
 
bool is_bool () const
 
bool is_integer () const
 
bool is_number () const
 
Valueoperator[] (const std::string &s)
 
const Valueoperator[] (const std::string &s) const
 
Valueoperator[] (const size_t i)
 
const Valueoperator[] (const size_t i) const
 
bool contains (const std::string &s) const
 
size_t size () const
 
void push_back (const Value &value)
 
void push_back (Value &&value)
 
std::string Dump (const int indent=-1, const char indent_char=' ') const
 public dump interface
 

Private Member Functions

std::string Dump (const size_t depth_level, const int indent, const char indent_char) const
 private dump interface
 

Private Attributes

Internal::JsonVariant val
 

Friends

std::istream & operator>> (std::istream &is, Value &v)
 

Detailed Description

Main class, basically a JsonVariant with extra utility functions it doesn't inherit JsonVariant directly so we can better control which constructors are allowed.

Definition at line 44 of file Json.hpp.

Constructor & Destructor Documentation

◆ Value() [1/18]

ProtocolCraft::Json::Value::Value ( std::nullptr_t  = nullptr)

Definition at line 24 of file Json.cpp.

◆ Value() [2/18]

ProtocolCraft::Json::Value::Value ( std::string_view  s)

Definition at line 29 of file Json.cpp.

◆ Value() [3/18]

ProtocolCraft::Json::Value::Value ( const std::string &  s)

Definition at line 34 of file Json.cpp.

◆ Value() [4/18]

ProtocolCraft::Json::Value::Value ( std::string &&  s)

Definition at line 39 of file Json.cpp.

◆ Value() [5/18]

ProtocolCraft::Json::Value::Value ( const char *  s)

Definition at line 44 of file Json.cpp.

◆ Value() [6/18]

ProtocolCraft::Json::Value::Value ( const bool  b)

Definition at line 49 of file Json.cpp.

◆ Value() [7/18]

ProtocolCraft::Json::Value::Value ( const Object o)

Definition at line 54 of file Json.cpp.

◆ Value() [8/18]

ProtocolCraft::Json::Value::Value ( Object &&  o)

Definition at line 59 of file Json.cpp.

◆ Value() [9/18]

ProtocolCraft::Json::Value::Value ( const Array a)

Definition at line 64 of file Json.cpp.

◆ Value() [10/18]

ProtocolCraft::Json::Value::Value ( Array &&  a)

Definition at line 69 of file Json.cpp.

◆ Value() [11/18]

ProtocolCraft::Json::Value::Value ( const std::initializer_list< Value > &  init)

Definition at line 74 of file Json.cpp.

References val.

◆ Value() [12/18]

ProtocolCraft::Json::Value::Value ( const NetworkType o)

Definition at line 104 of file Json.cpp.

◆ Value() [13/18]

template<template< typename, typename > class C, typename T , typename A , std::enable_if_t< std::is_convertible_v< T, Value >, bool > >
ProtocolCraft::Json::Value::Value ( const C< T, A > &  c)

Definition at line 217 of file Json.hpp.

References push_back().

◆ Value() [14/18]

template<typename T , size_t N, std::enable_if_t< std::is_convertible_v< T, Value >, bool > >
ProtocolCraft::Json::Value::Value ( const std::array< T, N > &  v)

Definition at line 230 of file Json.hpp.

References push_back().

◆ Value() [15/18]

template<typename T , std::enable_if_t< std::is_convertible_v< T, Value >, bool > >
ProtocolCraft::Json::Value::Value ( const std::map< std::string, T > &  m)

Definition at line 242 of file Json.hpp.

References operator[]().

◆ Value() [16/18]

template<typename T , std::enable_if_t< std::is_floating_point_v< T >, bool > >
ProtocolCraft::Json::Value::Value ( const T  u)

Definition at line 254 of file Json.hpp.

◆ Value() [17/18]

template<typename T , std::enable_if_t<(std::is_integral_v< T > &&std::is_signed_v< T >)||std::is_enum_v< T >, bool > = true>
ProtocolCraft::Json::Value::Value ( const T  i)

◆ Value() [18/18]

template<typename T , std::enable_if_t< std::is_floating_point_v< T >, bool > = true>
ProtocolCraft::Json::Value::Value ( const T  f)

Member Function Documentation

◆ contains()

◆ Dump() [1/2]

std::string ProtocolCraft::Json::Value::Dump ( const int  indent = -1,
const char  indent_char = ' ' 
) const

public dump interface

Parameters
indentnumber of char (space) for indentation. If -1, no new line will be added between values
indent_charchar used for indentation
Returns
the string representation of this Value

Definition at line 287 of file Json.cpp.

References Dump().

Referenced by Dump(), Botcraft::Authentifier::GetMCToken(), Botcraft::Authentifier::GetMSAToken(), Botcraft::Authentifier::GetPlayerCertificates(), Botcraft::Authentifier::GetXBLToken(), Botcraft::Authentifier::GetXSTSToken(), Botcraft::ConnectionClient::Handle(), Botcraft::ConnectionClient::Handle(), Botcraft::Authentifier::JoinServer(), Botcraft::Authentifier::MSAAuthDeviceFlow(), and Botcraft::Authentifier::WriteCacheFile().

◆ Dump() [2/2]

std::string ProtocolCraft::Json::Value::Dump ( const size_t  depth_level,
const int  indent,
const char  indent_char 
) const
private

private dump interface

Parameters
depth_leveldepth of this Value in the tree
indentnumber of char (space) for indentation
indent_charchar used for indentation
Returns
the string representation of this Value

Definition at line 292 of file Json.cpp.

References ProtocolCraft::Json::EscapeChars(), and val.

◆ get() [1/3]

template<typename T , std::enable_if_t< std::is_same_v< T, Object >||std::is_same_v< T, Array >||std::is_same_v< T, std::string >, bool > >
T & ProtocolCraft::Json::Value::get ( )

Definition at line 334 of file Json.hpp.

References get(), and val.

◆ get() [2/3]

template<typename T , std::enable_if_t<!std::is_same_v< T, std::monostate > &&!std::is_same_v< T, Object > &&!std::is_same_v< T, Array > &&!std::is_same_v< T, std::string >, bool > >
T ProtocolCraft::Json::Value::get ( ) const

◆ get() [3/3]

template<typename T , std::enable_if_t< std::is_same_v< T, Object >||std::is_same_v< T, Array >||std::is_same_v< T, std::string >, bool > >
const T & ProtocolCraft::Json::Value::get ( ) const

Definition at line 369 of file Json.hpp.

References get(), and val.

◆ get_array() [1/2]

◆ get_array() [2/2]

const Array & ProtocolCraft::Json::Value::get_array ( ) const

Definition at line 129 of file Json.cpp.

◆ get_number()

template<typename T , std::enable_if_t< std::is_integral_v< T >||std::is_floating_point_v< T >, bool > >
T ProtocolCraft::Json::Value::get_number ( ) const

◆ get_object() [1/2]

◆ get_object() [2/2]

const Object & ProtocolCraft::Json::Value::get_object ( ) const

Definition at line 124 of file Json.cpp.

◆ get_string() [1/2]

◆ get_string() [2/2]

const std::string & ProtocolCraft::Json::Value::get_string ( ) const

Definition at line 134 of file Json.cpp.

◆ is()

template<typename T >
bool ProtocolCraft::Json::Value::is ( ) const

Definition at line 401 of file Json.hpp.

References val.

◆ is_array()

◆ is_bool()

bool ProtocolCraft::Json::Value::is_bool ( ) const

Definition at line 159 of file Json.cpp.

Referenced by Botcraft::Blockstate::GetBoolFromCondition().

◆ is_integer()

bool ProtocolCraft::Json::Value::is_integer ( ) const

Definition at line 164 of file Json.cpp.

References val.

◆ is_null()

bool ProtocolCraft::Json::Value::is_null ( ) const

Definition at line 139 of file Json.cpp.

Referenced by Botcraft::Blockstate::Blockstate().

◆ is_number()

bool ProtocolCraft::Json::Value::is_number ( ) const

◆ is_object()

◆ is_string()

◆ operator[]() [1/4]

Value & ProtocolCraft::Json::Value::operator[] ( const size_t  i)

Definition at line 202 of file Json.cpp.

References val.

◆ operator[]() [2/4]

const Value & ProtocolCraft::Json::Value::operator[] ( const size_t  i) const

Definition at line 212 of file Json.cpp.

References val.

◆ operator[]() [3/4]

Value & ProtocolCraft::Json::Value::operator[] ( const std::string &  s)

Definition at line 177 of file Json.cpp.

References val.

Referenced by Value().

◆ operator[]() [4/4]

const Value & ProtocolCraft::Json::Value::operator[] ( const std::string &  s) const

Definition at line 192 of file Json.cpp.

References val.

◆ push_back() [1/2]

◆ push_back() [2/2]

void ProtocolCraft::Json::Value::push_back ( Value &&  value)

Definition at line 272 of file Json.cpp.

References val.

◆ size()

size_t ProtocolCraft::Json::Value::size ( ) const

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream &  is,
Value v 
)
friend

Definition at line 222 of file Json.cpp.

Member Data Documentation

◆ val

Internal::JsonVariant ProtocolCraft::Json::Value::val
private

The documentation for this class was generated from the following files: