JSON Voorhees
Killer JSON for C++
jsonv::encoder Class Referenceabstract

An encoder is responsible for writing values to some form of output. More...

#include <jsonv/encode.hpp>

+ Inheritance diagram for jsonv::encoder:

Public Member Functions

void encode (const jsonv::value &source)
 Encode some source value into this encoder. More...
 

Protected Member Functions

virtual void write_null ()=0
 Write the null value. More...
 
virtual void write_object_begin ()=0
 Write the opening of an object value. More...
 
virtual void write_object_end ()=0
 Write the closing of an object value. More...
 
virtual void write_object_key (string_view key)=0
 Write the key for an object, including the separator. More...
 
virtual void write_object_delimiter ()=0
 Write the delimiter between two entries in an object. More...
 
virtual void write_array_begin ()=0
 Write the opening of an array value. More...
 
virtual void write_array_end ()=0
 Write the closing of an array value. More...
 
virtual void write_array_delimiter ()=0
 Write the delimiter between two entries in an array. More...
 
virtual void write_string (string_view value)=0
 Write a string value. More...
 
virtual void write_integer (std::int64_t value)=0
 Write an integer value. More...
 
virtual void write_decimal (double value)=0
 Write a decimal value. More...
 
virtual void write_boolean (bool value)=0
 Write a boolean value. More...
 

Detailed Description

An encoder is responsible for writing values to some form of output.

Definition at line 25 of file encode.hpp.

Member Function Documentation

void jsonv::encoder::encode ( const jsonv::value source)

Encode some source value into this encoder.

This is the only useful entry point to this class.

virtual void jsonv::encoder::write_array_begin ( )
protectedpure virtual

Write the opening of an array value.

[

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_array_delimiter ( )
protectedpure virtual

Write the delimiter between two entries in an array.

,

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_array_end ( )
protectedpure virtual

Write the closing of an array value.

]

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_boolean ( bool  value)
protectedpure virtual

Write a boolean value.

true

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_decimal ( double  value)
protectedpure virtual

Write a decimal value.

Parameters
valueis the decimal to write. Keep in mind that standard JSON does not support special IEEE 754 values such as NaN and infinity. It is the implementation's choice of how to deal with such values. Two common options are to output null or to encode a string description of the special value.
4.9

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_integer ( std::int64_t  value)
protectedpure virtual

Write an integer value.

902

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_null ( )
protectedpure virtual

Write the null value.

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_object_begin ( )
protectedpure virtual

Write the opening of an object value.

{

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_object_delimiter ( )
protectedpure virtual

Write the delimiter between two entries in an object.

,

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_object_end ( )
protectedpure virtual

Write the closing of an object value.

}

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_object_key ( string_view  key)
protectedpure virtual

Write the key for an object, including the separator.

"key":

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.

virtual void jsonv::encoder::write_string ( string_view  value)
protectedpure virtual

Write a string value.

Parameters
valueis the string to write. It will hopefully be encoded as valid UTF-8. It is the implementation's choice of how to deal with malformed string values. Two common options are to replace malformed sequences with ?s or to simply output these encodings and let the receiver deal with them.
"value"

Implemented in jsonv::ostream_pretty_encoder, and jsonv::ostream_encoder.


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