Botcraft 1.21.4
Loading...
Searching...
No Matches
ProtocolCraft::Json Namespace Reference

Namespaces

namespace  Internal
 

Classes

class  Array
 Real class declaration, just a derived class of std::vector<Value> More...
 
class  Object
 Real class declaration, just a derived class of std::map<std::string, Value> More...
 
class  Value
 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...
 

Functions

Value Parse (std::string_view::const_iterator iter, size_t length, bool no_except=false)
 Parse a string_view from iter for at most length characters.
 
Value Parse (const std::string &s, bool no_except=false)
 Parse a std::string.
 
std::string EscapeChars (const std::string &s)
 
void SkipSpaces (std::string_view::const_iterator &iter, size_t &length)
 
Value NumberFromString (const std::string &s, const bool is_scientific, const bool is_double)
 
Value ParseNumber (std::string_view::const_iterator &iter, size_t &length)
 
Value ParseString (std::string_view::const_iterator &iter, size_t &length)
 
Value ParseObject (std::string_view::const_iterator &iter, size_t &length)
 
Value ParseArray (std::string_view::const_iterator &iter, size_t &length)
 
Value ParseValue (std::string_view::const_iterator &iter, size_t &length)
 
std::istream & operator>> (std::istream &is, Value &v)
 
void ValidateStringNumber (const std::string &s)
 
bool IsValidCodepoint (const unsigned long cp)
 
std::string CodepointToUtf8 (const std::string &hex_chars)
 

Function Documentation

◆ CodepointToUtf8()

std::string ProtocolCraft::Json::CodepointToUtf8 ( const std::string &  hex_chars)

Definition at line 647 of file Json.cpp.

References IsValidCodepoint().

Referenced by ParseString().

◆ EscapeChars()

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

Definition at line 435 of file Json.cpp.

Referenced by ProtocolCraft::Json::Value::Dump().

◆ IsValidCodepoint()

bool ProtocolCraft::Json::IsValidCodepoint ( const unsigned long  cp)

Definition at line 641 of file Json.cpp.

Referenced by CodepointToUtf8().

◆ NumberFromString()

Value ProtocolCraft::Json::NumberFromString ( const std::string &  s,
const bool  is_scientific,
const bool  is_double 
)

Definition at line 555 of file Json.cpp.

References ValidateStringNumber().

Referenced by ParseNumber().

◆ operator>>()

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

Definition at line 222 of file Json.cpp.

◆ Parse() [1/2]

Value ProtocolCraft::Json::Parse ( const std::string &  s,
bool  no_except = false 
)

Parse a std::string.

Parameters
sstring to parse
no_exceptif true, the function will return empty Value instead of throwing an exception in case of unvalid string
Returns
The parsed Value, will throw a std::runtime_error if unvalid

Definition at line 412 of file Json.cpp.

References Parse().

◆ Parse() [2/2]

Value ProtocolCraft::Json::Parse ( std::string_view::const_iterator  iter,
size_t  length,
bool  no_except = false 
)

Parse a string_view from iter for at most length characters.

Parameters
iterstart character
lengthavailable number of characters
no_exceptif true, the function will return empty Value instead of throwing an exception in case of unvalid string
Returns
The parsed Value, will throw a std::runtime_error if unvalid

Definition at line 390 of file Json.cpp.

References ParseValue().

Referenced by Parse(), ProtocolCraft::Chat::ReadImpl(), ProtocolCraft::ClientboundCustomPayloadConfigurationPacket::SerializeParsed(), ProtocolCraft::ServerboundCustomPayloadConfigurationPacket::SerializeParsed(), ProtocolCraft::ClientboundCustomPayloadPacket::SerializeParsed(), ProtocolCraft::ServerboundCustomPayloadPacket::SerializeParsed(), and Botcraft::Authentifier::WebRequest().

◆ ParseArray()

Value ProtocolCraft::Json::ParseArray ( std::string_view::const_iterator &  iter,
size_t &  length 
)

Definition at line 860 of file Json.cpp.

References ParseValue(), and SkipSpaces().

Referenced by ParseValue().

◆ ParseNumber()

Value ProtocolCraft::Json::ParseNumber ( std::string_view::const_iterator &  iter,
size_t &  length 
)

Definition at line 587 of file Json.cpp.

References NumberFromString().

Referenced by ParseValue().

◆ ParseObject()

Value ProtocolCraft::Json::ParseObject ( std::string_view::const_iterator &  iter,
size_t &  length 
)

Definition at line 792 of file Json.cpp.

References ProtocolCraft::Json::Value::get_string(), ParseString(), ParseValue(), and SkipSpaces().

Referenced by ParseValue().

◆ ParseString()

Value ProtocolCraft::Json::ParseString ( std::string_view::const_iterator &  iter,
size_t &  length 
)

Definition at line 684 of file Json.cpp.

References CodepointToUtf8().

Referenced by ParseObject(), and ParseValue().

◆ ParseValue()

Value ProtocolCraft::Json::ParseValue ( std::string_view::const_iterator &  iter,
size_t &  length 
)

Definition at line 916 of file Json.cpp.

References ParseArray(), ParseNumber(), ParseObject(), ParseString(), and SkipSpaces().

Referenced by Parse(), ParseArray(), and ParseObject().

◆ SkipSpaces()

void ProtocolCraft::Json::SkipSpaces ( std::string_view::const_iterator &  iter,
size_t &  length 
)

Definition at line 478 of file Json.cpp.

Referenced by ParseArray(), ParseObject(), and ParseValue().

◆ ValidateStringNumber()

void ProtocolCraft::Json::ValidateStringNumber ( const std::string &  s)

Definition at line 498 of file Json.cpp.

Referenced by NumberFromString().