Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::Json Class Referencefinal

JSON parser. More...

#include <Json.h>

Inheritance diagram for sese::Json:
sese::NotInstantiable

Public Member Functions

 Json ()=delete
 
- Public Member Functions inherited from sese::NotInstantiable
 NotInstantiable ()=delete
 
virtual ~NotInstantiable ()=default
 
 NotInstantiable (const NotInstantiable &)=delete
 
NotInstantiableoperator= (const NotInstantiable &)=delete
 

Static Public Member Functions

static Value parse (io::InputStream *input)
 Deserialize a JSON object from the stream.
 
static bool streamify (io::OutputStream *out, Value &value)
 Serialize a JSON object to the stream.
 
static Value simdParse (io::InputStream *input)
 Deserialize a JSON object from the stream using SIMD.
 

Private Types

using Tokens = std::queue<std::string>
 
using ParseStack = std::stack<Value *>
 
using StreamifyStack = std::stack<std::pair<Value *, unsigned int>>
 
using StreamifyIterStack = std::stack<std::map<std::string, std::shared_ptr<Value>>::iterator>
 

Static Private Member Functions

static Value parse (Tokens &tokens)
 
static bool parseObject (Tokens &tokens, ParseStack &stack)
 
static bool parseArray (Tokens &tokens, ParseStack &stack)
 
static Value parseBasic (const std::string &value)
 
static bool streamifyObject (io::OutputStream *out, StreamifyStack &stack, StreamifyIterStack &map_iter_stack)
 
static bool streamifyArray (io::OutputStream *out, StreamifyStack &stack, StreamifyIterStack &map_iter_stack)
 
static bool streamifyBasic (io::OutputStream *out, const std::shared_ptr< Value > &value)
 
static bool tokenizer (io::InputStream *input_stream, Tokens &tokens) noexcept
 
static Value parse (const simdjson::dom::element &json)
 

Detailed Description

JSON parser.

Member Typedef Documentation

◆ ParseStack

using sese::Json::ParseStack = std::stack<Value *>
private

◆ StreamifyIterStack

using sese::Json::StreamifyIterStack = std::stack<std::map<std::string, std::shared_ptr<Value>>::iterator>
private

◆ StreamifyStack

using sese::Json::StreamifyStack = std::stack<std::pair<Value *, unsigned int>>
private

◆ Tokens

using sese::Json::Tokens = std::queue<std::string>
private

Constructor & Destructor Documentation

◆ Json()

sese::Json::Json ( )
delete

Member Function Documentation

◆ parse() [1/3]

sese::Value Json::parse ( const simdjson::dom::element & json)
staticprivate

◆ parse() [2/3]

Value Json::parse ( io::InputStream * input)
static

Deserialize a JSON object from the stream.

Parameters
inputThe input stream
Returns
If parsing fails, Value::isNull will be true

References parse(), and tokenizer().

◆ parse() [3/3]

Value Json::parse ( Tokens & tokens)
staticprivate

◆ parseArray()

bool Json::parseArray ( Tokens & tokens,
ParseStack & stack )
staticprivate

◆ parseBasic()

Value Json::parseBasic ( const std::string & value)
staticprivate

Referenced by parseArray(), and parseObject().

◆ parseObject()

bool Json::parseObject ( Tokens & tokens,
ParseStack & stack )
staticprivate

◆ simdParse()

sese::Value Json::simdParse ( io::InputStream * input)
static

Deserialize a JSON object from the stream using SIMD.

Parameters
inputThe input stream
Returns
If parsing fails, Value::isNull will be true

References sese::text::AbstractStringBuffer::append(), sese::text::AbstractStringBuffer::buf(), sese::text::AbstractStringBuffer::length(), parse(), read(), and sese::io::InputStream::read().

◆ streamify()

bool Json::streamify ( io::OutputStream * out,
Value & value )
static

Serialize a JSON object to the stream.

Parameters
outThe output stream
valueThe JSON object
Returns
If serialization fails, false will be returned

References sese::Value::Dict::begin(), sese::Value::getDict(), sese::Value::isDict(), streamifyArray(), and streamifyObject().

◆ streamifyArray()

bool Json::streamifyArray ( io::OutputStream * out,
StreamifyStack & stack,
StreamifyIterStack & map_iter_stack )
staticprivate

References CONST_WRITE, count(), and streamifyBasic().

Referenced by streamify().

◆ streamifyBasic()

bool Json::streamifyBasic ( io::OutputStream * out,
const std::shared_ptr< Value > & value )
staticprivate

References CONST_WRITE, and STRING_WRITE.

Referenced by streamifyArray(), and streamifyObject().

◆ streamifyObject()

bool Json::streamifyObject ( io::OutputStream * out,
StreamifyStack & stack,
StreamifyIterStack & map_iter_stack )
staticprivate

References CONST_WRITE, count(), streamifyBasic(), and STRING_WRITE.

Referenced by streamify().

◆ tokenizer()


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