SPT JSON API
1.0.0
Developed by Sans Pareil Technologies, Inc. (SPT)
|
Base class that is used to represent JSON data in a polymorphous manner. More...
#include <Json.h>
Public Types | |
typedef Container::const_iterator | Iterator |
The iterator used to iterate over the elements of the object. More... | |
Public Types inherited from spt::json::Value | |
enum | Type : int8_t { Type::String, Type::Number, Type::Object, Type::Array, Type::Boolean, Type::Null } |
Enumeration of JSON data types. More... | |
typedef std::unique_ptr< Value > | Ptr |
Unique pointer that holds a value instance. More... | |
Public Member Functions | |
Json (Type type) | |
CTOR for initialising base class with specified type. More... | |
Json (Json &&rhs) | |
Move CTOR. More... | |
Json & | operator= (Json &&rhs) |
Move assignment operator. More... | |
Iterator | begin () const |
Iterator | end () const |
bool | empty () const |
std::size_t | size () const |
void | clear () |
Clear all the data stored in this instance. More... | |
virtual void | toJson (std::ostream &stream, bool prettyPrint=false) const =0 |
Write the data in this instance to the specified stream in JSON format. More... | |
virtual std::string | toString (bool prettyPrint=false) const =0 |
Return the JSON string representation of the data in this instance. More... | |
Public Member Functions inherited from spt::json::Value | |
virtual | ~Value () |
Virtual DTOR for sub-classes. More... | |
Value (Value &&rhs) | |
Move CTOR. More... | |
Value & | operator= (Value &&rhs) |
Move assignment operator. More... | |
Value (const Value &)=delete | |
Copy CTOR. Deleted. More... | |
Value & | operator= (Value &)=delete |
Copy assignment operator deleted. More... | |
Type | getType () const |
Return the type of data that is represented by this instance. More... | |
Protected Member Functions | |
Container & | getElements () |
const Container & | getElements () const |
Constant version that returns the elements stored in this instance. More... | |
Protected Member Functions inherited from spt::json::Value | |
Value (Type t) | |
CTOR with specified type. More... | |
Base class that is used to represent JSON data in a polymorphous manner.
This class is used to allow parser implementations to provide a generic parse
method which returns either a spt::json::Object or spt::json::Array instance depending upon the type of JSON data.
Container | The type of container used to store the elements. |
typedef Container::const_iterator spt::json::Json< Container >::Iterator |
The iterator used to iterate over the elements of the object.
|
inlineexplicit |
CTOR for initialising base class with specified type.
|
inline |
Move CTOR.
|
inline |
|
inline |
Clear all the data stored in this instance.
|
inline |
true
if the object has no elements.
|
inline |
|
inlineprotected |
|
inlineprotected |
Constant version that returns the elements stored in this instance.
|
inline |
Move assignment operator.
|
inline |
|
pure virtual |
Write the data in this instance to the specified stream in JSON format.
stream | The output stream to which the JSON data is to be written (file, buffer, ...) |
prettyPrint | Flag that indicates whether the JSON data should be formatted for ease of human reading. |
true
if the data was written without errors. Implemented in spt::json::Object, and spt::json::Array.
|
pure virtual |
Return the JSON string representation of the data in this instance.
prettyPrint | Flag that indicates whether the string representation should be formatted for ease of human reading. |
Implemented in spt::json::Object, and spt::json::Array.