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

YAML parser. More...

#include <Yaml.h>

Inheritance diagram for sese::Yaml:
sese::NotInstantiable

Public Member Functions

 Yaml ()=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)
 
static bool streamify (io::OutputStream *output, Value &value)
 

Private Types

using Tokens = std::vector<std::string>
 
using TokensQueue = std::queue<std::tuple<int, Tokens>>
 
using InputStream = io::InputStream
 
using OutputStream = io::OutputStream
 
using Line = std::tuple<int, std::string>
 
using ParseStack = std::stack<std::pair<Value *, int>>
 
using StreamifyStack = std::stack<std::tuple<Value *, unsigned int, unsigned int, bool>>
 
using StreamifyIterStack = std::stack<std::map<std::string, std::shared_ptr<Value>>::iterator>
 

Static Private Member Functions

static Value parseBasic (const std::string &value)
 
static bool parseObject (TokensQueue &tokens_queue, ParseStack &stack)
 
static bool parseArray (TokensQueue &tokens_queue, ParseStack &stack)
 
static bool streamifyObject (OutputStream *output, StreamifyStack &stack, StreamifyIterStack &map_iter_stack)
 
static bool streamifyArray (OutputStream *output, StreamifyStack &stack, StreamifyIterStack &map_iter_stack)
 
static bool streamifyBasic (OutputStream *output, const std::shared_ptr< Value > &value)
 
static int getSpaceCount (const std::string &line) noexcept
 
static Line getLine (InputStream *input) noexcept
 
static Tokens tokenizer (const std::string &line) noexcept
 
static bool writeSpace (OutputStream *output, size_t count) noexcept
 

Detailed Description

YAML parser.

Member Typedef Documentation

◆ InputStream

◆ Line

using sese::Yaml::Line = std::tuple<int, std::string>
private

◆ OutputStream

◆ ParseStack

using sese::Yaml::ParseStack = std::stack<std::pair<Value *, int>>
private

◆ StreamifyIterStack

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

◆ StreamifyStack

using sese::Yaml::StreamifyStack = std::stack<std::tuple<Value *, unsigned int, unsigned int, bool>>
private

◆ Tokens

using sese::Yaml::Tokens = std::vector<std::string>
private

◆ TokensQueue

using sese::Yaml::TokensQueue = std::queue<std::tuple<int, Tokens>>
private

Constructor & Destructor Documentation

◆ Yaml()

sese::Yaml::Yaml ( )
delete

Member Function Documentation

◆ getLine()

std::tuple< int, std::string > Yaml::getLine ( InputStream * input)
staticprivatenoexcept

◆ getSpaceCount()

int Yaml::getSpaceCount ( const std::string & line)
staticprivatenoexcept

Referenced by getLine().

◆ parse()

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

Deserialize yaml object from stream

Parameters
inputInput stream
Returns
If parsing fails, Value::isNull is true

References sese::Value::dict(), getLine(), sese::Value::list(), parseArray(), parseObject(), and tokenizer().

◆ parseArray()

bool Yaml::parseArray ( TokensQueue & tokens_queue,
ParseStack & stack )
staticprivate

◆ parseBasic()

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

References d, and sese::strcmpDoNotCase().

Referenced by parseArray(), and parseObject().

◆ parseObject()

bool Yaml::parseObject ( TokensQueue & tokens_queue,
ParseStack & stack )
staticprivate

◆ streamify()

bool Yaml::streamify ( io::OutputStream * output,
Value & value )
static

Serialize yaml object to stream

Parameters
outputOutput stream
valueyaml object
Returns
If serialization fails, return false

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

◆ streamifyArray()

bool Yaml::streamifyArray ( OutputStream * output,
StreamifyStack & stack,
StreamifyIterStack & map_iter_stack )
staticprivate

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

Referenced by streamify().

◆ streamifyBasic()

bool Yaml::streamifyBasic ( OutputStream * output,
const std::shared_ptr< Value > & value )
staticprivate

References CONST_WRITE, and STRING_WRITE.

Referenced by streamifyArray(), and streamifyObject().

◆ streamifyObject()

bool Yaml::streamifyObject ( OutputStream * output,
StreamifyStack & stack,
StreamifyIterStack & map_iter_stack )
staticprivate

◆ tokenizer()

std::vector< std::string > Yaml::tokenizer ( const std::string & line)
staticprivatenoexcept

◆ writeSpace()

bool Yaml::writeSpace ( OutputStream * output,
size_t count )
staticprivatenoexcept

References count().

Referenced by streamifyArray(), and streamifyObject().


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