SPT JSON API  1.0.0
Developed by Sans Pareil Technologies, Inc. (SPT)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
spt::json::Json< Container > Struct Template Referenceabstract

Base class that is used to represent JSON data in a polymorphous manner. More...

#include <Json.h>

+ Inheritance diagram for spt::json::Json< Container >:
+ Collaboration diagram for spt::json::Json< Container >:

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< ValuePtr
 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...
 
Jsonoperator= (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...
 
Valueoperator= (Value &&rhs)
 Move assignment operator. More...
 
 Value (const Value &)=delete
 Copy CTOR. Deleted. More...
 
Valueoperator= (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...
 

Detailed Description

template<typename Container>
struct spt::json::Json< Container >

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.

Template Parameters
ContainerThe type of container used to store the elements.
Date
Created 2013/05/02 18:41
Author
Rakesh Vidyadharan
Version
Id
Json.h 5680 2014-10-27 16:52:08Z rakesh

Member Typedef Documentation

template<typename Container>
typedef Container::const_iterator spt::json::Json< Container >::Iterator

The iterator used to iterate over the elements of the object.

Constructor & Destructor Documentation

template<typename Container>
spt::json::Json< Container >::Json ( Type  type)
inlineexplicit

CTOR for initialising base class with specified type.

template<typename Container>
spt::json::Json< Container >::Json ( Json< Container > &&  rhs)
inline

Move CTOR.

Member Function Documentation

template<typename Container>
Iterator spt::json::Json< Container >::begin ( ) const
inline
Returns
Returns a constant iterator over the elements in the document.
template<typename Container>
void spt::json::Json< Container >::clear ( )
inline

Clear all the data stored in this instance.

template<typename Container>
bool spt::json::Json< Container >::empty ( ) const
inline
Returns
Return true if the object has no elements.
template<typename Container>
Iterator spt::json::Json< Container >::end ( ) const
inline
Returns
Iterator indicating the end of the element map.
template<typename Container>
Container& spt::json::Json< Container >::getElements ( )
inlineprotected
Returns
Return the container in which the elements are stored.
template<typename Container>
const Container& spt::json::Json< Container >::getElements ( ) const
inlineprotected

Constant version that returns the elements stored in this instance.

template<typename Container>
Json& spt::json::Json< Container >::operator= ( Json< Container > &&  rhs)
inline

Move assignment operator.

template<typename Container>
std::size_t spt::json::Json< Container >::size ( ) const
inline
Returns
The total number of elements in the document.
template<typename Container>
virtual void spt::json::Json< Container >::toJson ( std::ostream &  stream,
bool  prettyPrint = false 
) const
pure virtual

Write the data in this instance to the specified stream in JSON format.

Parameters
streamThe output stream to which the JSON data is to be written (file, buffer, ...)
prettyPrintFlag that indicates whether the JSON data should be formatted for ease of human reading.
Returns
Return true if the data was written without errors.
See also
spt::json::io::StreamWriter::write

Implemented in spt::json::Object, and spt::json::Array.

template<typename Container>
virtual std::string spt::json::Json< Container >::toString ( bool  prettyPrint = false) const
pure virtual

Return the JSON string representation of the data in this instance.

Parameters
prettyPrintFlag that indicates whether the string representation should be formatted for ease of human reading.
Returns
The JSON string representing the data in this instance.
See also
spt::json::io::StringWriter::write

Implemented in spt::json::Object, and spt::json::Array.


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