AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
WriterContext Class Reference

JSON writer context. More...

#include <writerContext.hpp>

Collaboration diagram for WriterContext:

Public Member Functions

 WriterContext ()=delete
 WriterContext (const WriterContext &context)=delete
 WriterContext (WriterContext &&context)=delete
 WriterContext (std::ostream &os, const anch::json::MappingOptions &options) noexcept
virtual ~WriterContext () noexcept
bool writeNull (const std::string &field)
bool writeEmptyArray (const std::string &field)
bool writeEmptyObject (const std::string &field)
void writeField (const std::string &field)
void beginArray ()
void endArray ()
void beginObject ()
void endObject ()
void next ()

Public Attributes

std::ostream & output

Detailed Description

JSON writer context.

Context is used to store mapping options and serialization buffers

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ WriterContext() [1/4]

Forbids WriterContext default constructor

◆ WriterContext() [2/4]

Forbids WriterContext copy constructor

Parameters
contextthe context not to copy

◆ WriterContext() [3/4]

Forbids WriterContext move constructor

Parameters
contextthe context not to move

◆ WriterContext() [4/4]

anch::json::WriterContext::WriterContext ( std::ostream & os,
const anch::json::MappingOptions & options )
noexcept

WriterContext constructor

Parameters
osthe ouput stream to write in
optionsthe mapping options to use

◆ ~WriterContext()

virtual anch::json::WriterContext::~WriterContext ( )
virtualnoexcept

WriterContext destructor
Delete buffers

Member Function Documentation

◆ beginArray()

Write begin array ('[') and push first field in context

◆ beginObject()

Write begin array ('{') and push first field in context

◆ endArray()

Write end array (']') and pop first field from context

◆ endObject()

Write end array ('}') and pop first field from context

◆ next()

Write field/value delimiter (',') according to context (first field or not)

◆ writeEmptyArray()

bool anch::json::WriterContext::writeEmptyArray ( const std::string & field)

Write empty collection according to options.
When serialize, it will be serialized as '"<field>":[]'

Parameters
fieldthe field name

◆ writeEmptyObject()

bool anch::json::WriterContext::writeEmptyObject ( const std::string & field)

Write empty object (map) according to options.
When serialize, it will be serialized as '"<field>":{}'

Parameters
fieldthe field name

◆ writeField()

void anch::json::WriterContext::writeField ( const std::string & field)

Write field and add ':' into output stream.
Call next() to add ',' or not before field

Parameters
fieldthe field

◆ writeNull()

bool anch::json::WriterContext::writeNull ( const std::string & field)

Write null value or not according to options

Parameters
fieldthe field name
Returns
true when null value has been serialize, false otherwise

Member Data Documentation

◆ output

The input stream to parse


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