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

JSON writer context. More...

#include <writerContext.hpp>

Collaboration diagram for anch::json::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]

anch::json::WriterContext::WriterContext ( )
delete

Forbids WriterContext default constructor

◆ WriterContext() [2/4]

anch::json::WriterContext::WriterContext ( const WriterContext & context)
delete

Forbids WriterContext copy constructor

Parameters
contextthe context not to copy
Here is the call graph for this function:

◆ WriterContext() [3/4]

anch::json::WriterContext::WriterContext ( WriterContext && context)
delete

Forbids WriterContext move constructor

Parameters
contextthe context not to move
Here is the call graph for this function:

◆ 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()

void anch::json::WriterContext::beginArray ( )

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

Here is the call graph for this function:

◆ beginObject()

void anch::json::WriterContext::beginObject ( )

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

Here is the call graph for this function:

◆ endArray()

void anch::json::WriterContext::endArray ( )

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

Here is the call graph for this function:

◆ endObject()

void anch::json::WriterContext::endObject ( )

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

Here is the call graph for this function:

◆ next()

void anch::json::WriterContext::next ( )

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

Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

Member Data Documentation

◆ output

std::ostream& anch::json::WriterContext::output

The input stream to parse


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