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::Reader Struct Reference

Base JSON data reader interface. Implementations provide support for reading JSON data from various sources. Event notifications will be sent to the callback handler set for the reader. Handler instances may be updated during the course of data parsing. More...

#include <Reader.h>

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

Public Member Functions

 Reader (Handler::Ptr callback=Handler::Ptr())
 
virtual ~Reader ()
 Virtual DTOR for subclasses. More...
 
Handler::Ptr getHandler () const
 
void setHandler (Handler::Ptr callback)
 

Protected Member Functions

void parseNumber (const std::string &value)
 
bool isWhiteSpace (char current)
 Check to see if the specified character is white space. More...
 
bool isNumeric (char current)
 Check to see if current character represents a numeric value. More...
 

Protected Attributes

Handler::Ptr handler
 The call-back handler to send data event notifications to. More...
 

Static Protected Attributes

static const std::string null
 A constant representing a JSON null value. More...
 
static const std::string True
 A constant representing a JSON true value. More...
 
static const std::string False
 A constant representing a JSON false value. More...
 

Detailed Description

Base JSON data reader interface. Implementations provide support for reading JSON data from various sources. Event notifications will be sent to the callback handler set for the reader. Handler instances may be updated during the course of data parsing.

Date
Created 2013/05/02 20:41
Author
Rakesh
Version
Id
Reader.h 5677 2014-10-26 12:36:27Z rakesh

Constructor & Destructor Documentation

spt::json::io::Reader::Reader ( Handler::Ptr  callback = Handler::Ptr())
inlineexplicit

Create a new parser instance using the specified call-back handler to send JSON data event notifications to.

Note: It is possible to specify an empty handler, in which case the parser will consume the JSON data without producing any output.

Parameters
callbackThe call-back handler that will receive data events.
virtual spt::json::io::Reader::~Reader ( )
inlinevirtual

Virtual DTOR for subclasses.

Member Function Documentation

Handler::Ptr spt::json::io::Reader::getHandler ( ) const
inline

Return the call-back handler set for the parser. This may be nullptr

Returns
The call-back handler currently configured for the parser.
bool spt::json::io::Reader::isNumeric ( char  current)
protected

Check to see if current character represents a numeric value.

bool spt::json::io::Reader::isWhiteSpace ( char  current)
protected

Check to see if the specified character is white space.

void spt::json::io::Reader::parseNumber ( const std::string &  value)
protected

Parses the specified string value into a number. The implementation invokes the appropriate callback methods on the handler based on whether the value is integral or floating point.

void spt::json::io::Reader::setHandler ( Handler::Ptr  callback)
inline

Update/set the call-back handler to which JSON data event notifications are sent when parsing the JSON data stream.

Note: Callers may change the handler at any time during the parsing phase. This is most useful if one handler delegates the event handling to another handler, which in turn may delegate to another handler depending upon the events being received. This way implementations may use dedicated handlers for parsing specific JSON data structures from the full JSON data.

Note: No locks/mutexes are in use, hence this is not meant to be invoked for other threads. The design goal is to allow handlers to delegate to other handlers, and thus not get into any concurrent modification issues.

Parameters
callbackThe call-back handler to use.

Member Data Documentation

const std::string spt::json::io::Reader::False
staticprotected

A constant representing a JSON false value.

Handler::Ptr spt::json::io::Reader::handler
protected

The call-back handler to send data event notifications to.

const std::string spt::json::io::Reader::null
staticprotected

A constant representing a JSON null value.

const std::string spt::json::io::Reader::True
staticprotected

A constant representing a JSON true value.


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