JSON writer context. More...
#include <writerContext.hpp>
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 |
JSON writer context.
Context is used to store mapping options and serialization buffers
|
delete |
Forbids WriterContext default constructor
|
delete |
Forbids WriterContext copy constructor
| context | the context not to copy |
|
delete |
Forbids WriterContext move constructor
| context | the context not to move |
|
noexcept |
WriterContext constructor
| os | the ouput stream to write in |
| options | the mapping options to use |
|
virtualnoexcept |
WriterContext destructor
Delete buffers
Write begin array ('[') and push first field in context
Write begin array ('{') and push first field in context
| void anch::json::WriterContext::endArray | ( | ) |
Write end array (']') and pop first field from context
| void anch::json::WriterContext::endObject | ( | ) |
Write end array ('}') and pop first field from context
| void anch::json::WriterContext::next | ( | ) |
Write field/value delimiter (',') according to context (first field or not)
| bool anch::json::WriterContext::writeEmptyArray | ( | const std::string & | field | ) |
Write empty collection according to options.
When serialize, it will be serialized as '"<field>":[]'
| field | the field name |
| bool anch::json::WriterContext::writeEmptyObject | ( | const std::string & | field | ) |
Write empty object (map) according to options.
When serialize, it will be serialized as '"<field>":{}'
| field | the field name |
| void anch::json::WriterContext::writeField | ( | const std::string & | field | ) |
Write field and add ':' into output stream.
Call next() to add ',' or not before field
| field | the field |
| bool anch::json::WriterContext::writeNull | ( | const std::string & | field | ) |
Write null value or not according to options
| field | the field name |
true when null value has been serialize, false otherwise | std::ostream& anch::json::WriterContext::output |
The input stream to parse