nomlib
Loading...
Searching...
No Matches
nom::JsonCppSerializer Class Reference

Saving of nom::Value objects to JSON documents using the JsonCpp library. More...

#include <JsonCppSerializer.hpp>

Inheritance diagram for nom::JsonCppSerializer:
[legend]

Public Types

typedef JsonCppSerializer SelfType
Public Types inherited from nom::IValueSerializer
typedef IValueSerializer self_type
typedef self_type * raw_ptr
typedef std::unique_ptr< self_type > unique_ptr
typedef std::shared_ptr< self_type > shared_ptr

Public Member Functions

 JsonCppSerializer (void)
 Default constructor; initialize the writer with human friendly output.
 ~JsonCppSerializer (void)
 Destructor.
 JsonCppSerializer (enum SerializerOptions options)
 Construct a parser with a feature set enumeration.
std::string serialize (const Value &source)
 Output a nom::Value object to a string.
bool save (const Value &source, const std::string &filename)
 Convenience method provided to output JSON-formatted data to a file.

Private Member Functions

bool write (const Value &source, Json::Value &dest) const
bool write_value (const Value &object, Json::Value &dest) const
bool write_array_value (const Value &object, Json::Value &dest) const
bool write_array (const Value &object, Json::Value &dest) const
 Internal helper method for serialization of array nodes.
bool write_object (const Value &object, Json::Value &dest) const
 Internal helper method for serialization of object nodes.

Private Attributes

enum SerializerOptions options_

Detailed Description

Saving of nom::Value objects to JSON documents using the JsonCpp library.

[TO BE WRITTEN]

Definition at line 62 of file JsonCppSerializer.hpp.

Member Typedef Documentation

◆ SelfType

typedef JsonCppSerializer nom::JsonCppSerializer::SelfType

Definition at line 65 of file JsonCppSerializer.hpp.

Constructor & Destructor Documentation

◆ JsonCppSerializer()

nom::JsonCppSerializer::JsonCppSerializer ( void )

Default constructor; initialize the writer with human friendly output.

Remarks
See the SerializerOptions enumeration for more information.

Member Function Documentation

◆ save()

bool nom::JsonCppSerializer::save ( const Value & source,
const std::string & filename )
virtual

Convenience method provided to output JSON-formatted data to a file.

Parameters
sourcenom::Value container to serialize from.
filenameAbsolute file path to output resulting data to.
Note
Implements ISerializer interface.
Remarks
The resulting file's output is written (literally) out as the text "null" even if the source Value object's size is null.

Implements nom::IValueSerializer.

◆ serialize()

std::string nom::JsonCppSerializer::serialize ( const Value & source)
virtual

Output a nom::Value object to a string.

Parameters
sourcenom::Value container to serialize from.
Returns
std::string with JSON-conforming output on success, or a null- terminated string on err.
Note
Implements ISerializer interface.

Implements nom::IValueSerializer.

◆ write_array()

bool nom::JsonCppSerializer::write_array ( const Value & object,
Json::Value & dest ) const
private

Internal helper method for serialization of array nodes.

Todo
Err handling where used in code

◆ write_array_value()

bool nom::JsonCppSerializer::write_array_value ( const Value & object,
Json::Value & dest ) const
private
Todo
Err handling where used in code

◆ write_object()

bool nom::JsonCppSerializer::write_object ( const Value & object,
Json::Value & dest ) const
private

Internal helper method for serialization of object nodes.

Todo
Err handling where used in code

◆ write_value()

bool nom::JsonCppSerializer::write_value ( const Value & object,
Json::Value & dest ) const
private
Todo
Err handling where used in code

Member Data Documentation

◆ options_

enum SerializerOptions nom::JsonCppSerializer::options_
private

Definition at line 102 of file JsonCppSerializer.hpp.


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