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::io::DefaultHandler Class Reference

A default handler that populates a Json instance with the JSON data being parsed. More...

#include <DefaultHandler.h>

+ Inheritance diagram for spt::json::io::DefaultHandler:
+ Collaboration diagram for spt::json::io::DefaultHandler:

Public Member Functions

 DefaultHandler (Reader *p)
 Create a new handler instance that receives notifications from the specified parser instance. More...
 
Value::Ptr getJson ()
 Return the JSON object or array parsed from the JSON data. More...
 
void startObject () override
 Call-back function invoked when a new object will be read from the JSON data. This is triggered when the parser has read a '{'. More...
 
void endObject () override
 Call-back function invoked when an object has been read from the JSON data. This is triggered when the parser has read a '}'. More...
 
void startArray () override
 Call-back function invoked when a new array will be read from the JSON data. This is triggered when the parser has read a '['. More...
 
void endArray () override
 Call-back function invoked when an array has been read from the JSON data. This is triggered when the parser has read a ']'. More...
 
void name (std::string &&name) override
 Call-back function invoked when a name (applies only to objects) value has been read from the JSON data. More...
 
void value (std::string &&value) override
 Call-back function invoked when a string value has been read from the JSON data. More...
 
void value (int64_t value) override
 Call-back function invoked when a integral value has been read from the JSON data. More...
 
void value (double value) override
 Call-back function invoked when a floating point value has been read from the JSON data. More...
 
void value (bool value) override
 Call-back function invoked when a boolean value has been read from the JSON data. More...
 
void null () override
 Call-back function invoked when a null value has been read from the JSON data. More...
 
void eof () override
 
bool isArray () const override
 
bool isObject () const override
 
- Public Member Functions inherited from spt::json::io::Handler
virtual ~Handler ()
 Virtual DTOR for sub-classes. More...
 

Protected Member Functions

void processChild ()
 
void setElement (Value::Ptr &&value)
 

Additional Inherited Members

- Public Types inherited from spt::json::io::Handler
typedef std::shared_ptr< HandlerPtr
 Shared pointer to a handler instance. More...
 

Detailed Description

A default handler that populates a Json instance with the JSON data being parsed.

Date
Created 2013/05/07 19:45
Author
Rakesh Vidyadharan
Version
Id
DefaultHandler.h 5665 2014-10-25 02:32:00Z rakesh

Constructor & Destructor Documentation

spt::json::io::DefaultHandler::DefaultHandler ( Reader p)
inlineexplicit

Create a new handler instance that receives notifications from the specified parser instance.

The parent instance is the instance that instantiated this instance and is used to track recursive parsing of objects and arrays.

Note: This instance will become the registered handler for the parser.

Parameters
pThe JSON parser instance.

Member Function Documentation

void spt::json::io::DefaultHandler::endArray ( )
overridevirtual

Call-back function invoked when an array has been read from the JSON data. This is triggered when the parser has read a ']'.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::endObject ( )
overridevirtual

Call-back function invoked when an object has been read from the JSON data. This is triggered when the parser has read a '}'.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::eof ( )
overridevirtual
Exceptions
std::runtime_errorIf JSON data is incomplete

Implements spt::json::io::Handler.

Value::Ptr spt::json::io::DefaultHandler::getJson ( )
inline

Return the JSON object or array parsed from the JSON data.

Note: This method is destructive and should be called only after the handler has finished receiving notifications from the parser.

Returns
A Object or Array instance representing the JSON data.
bool spt::json::io::DefaultHandler::isArray ( ) const
overridevirtual
Returns
Indicate whether the data parsed was an array.

Implements spt::json::io::Handler.

bool spt::json::io::DefaultHandler::isObject ( ) const
overridevirtual
Returns
Indicate whether the data parsed was an object.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::name ( std::string &&  name)
overridevirtual

Call-back function invoked when a name (applies only to objects) value has been read from the JSON data.

Parameters
nameThe name value that was read from the JSON data.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::null ( )
overridevirtual

Call-back function invoked when a null value has been read from the JSON data.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::processChild ( )
protected
void spt::json::io::DefaultHandler::setElement ( Value::Ptr &&  value)
protected
void spt::json::io::DefaultHandler::startArray ( )
overridevirtual

Call-back function invoked when a new array will be read from the JSON data. This is triggered when the parser has read a '['.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::startObject ( )
overridevirtual

Call-back function invoked when a new object will be read from the JSON data. This is triggered when the parser has read a '{'.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::value ( std::string &&  value)
overridevirtual

Call-back function invoked when a string value has been read from the JSON data.

Parameters
valueThe string that was read.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::value ( int64_t  value)
overridevirtual

Call-back function invoked when a integral value has been read from the JSON data.

Parameters
valueThe integral value that was read.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::value ( double  value)
overridevirtual

Call-back function invoked when a floating point value has been read from the JSON data.

Parameters
valueThe floating point value that was read.

Implements spt::json::io::Handler.

void spt::json::io::DefaultHandler::value ( bool  value)
overridevirtual

Call-back function invoked when a boolean value has been read from the JSON data.

Parameters
valueThe boolean that was read.

Implements spt::json::io::Handler.


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