HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_JSONHandle Class Referenceabstract

UT_JSONHandle processes events from a UT_JSONParser parser. More...

#include <UT_JSONHandle.h>

+ Inheritance diagram for UT_JSONHandle:

Public Member Functions

 UT_JSONHandle ()
 
virtual ~UT_JSONHandle ()
 
 UT_JSONHandle (const UT_JSONHandle &)=delete
 
UT_JSONHandleoperator= (const UT_JSONHandle &)=delete
 
bool parseObject (UT_JSONParser &p, UT_IStream *is=0)
 Convenience method to parse a single object. More...
 
virtual bool jsonNull (UT_JSONParser &p)=0
 Event method to process a null token. More...
 
virtual bool jsonBool (UT_JSONParser &p, bool value)=0
 Event method to process a bool (true or false tokens) More...
 
virtual bool jsonInt (UT_JSONParser &p, int64 value)=0
 Event method to process an integer. More...
 
virtual bool jsonReal (UT_JSONParser &p, fpreal64 value)=0
 Event method to process a real/float. More...
 
virtual bool jsonString (UT_JSONParser &p, const char *value, int64 len)=0
 Event method to process a string value. More...
 
virtual bool jsonStringHolder (UT_JSONParser &p, const UT_StringHolder &s)
 
virtual bool jsonKey (UT_JSONParser &p, const char *v, int64 len)=0
 Event method to process the key of a map/object is read. More...
 
virtual bool jsonKeyHolder (UT_JSONParser &p, const UT_StringHolder &s)
 
virtual bool jsonBeginMap (UT_JSONParser &p)=0
 Event method invoked at the start of a map/object. More...
 
virtual bool jsonEndMap (UT_JSONParser &p)=0
 Event method invoked at the end of a map/object. More...
 
virtual bool jsonBeginArray (UT_JSONParser &p)=0
 Event method invoked at the beginning of an array object. More...
 
virtual bool jsonEndArray (UT_JSONParser &p)=0
 Event method invoked at the end of an array object. More...
 
virtual bool uaBool (UT_JSONParser &p, int64 length)
 
virtual bool uaInt8 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of int8 data. More...
 
virtual bool uaInt16 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of int16 data. More...
 
virtual bool uaInt32 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of int32 data. More...
 
virtual bool uaInt64 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of int64 data. More...
 
virtual bool uaReal16 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of real16 data. More...
 
virtual bool uaReal32 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of real32 data. More...
 
virtual bool uaReal64 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of real64 data. More...
 
virtual bool uaUInt8 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of unsigned uint8 data. More...
 
virtual bool uaUInt16 (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of unsigned uint16 data. More...
 
virtual bool uaString (UT_JSONParser &p, int64 length)
 Event method to handle uniform array of string data (use uaReadString) More...
 
virtual bool uaStringToken (UT_JSONParser &p, int64 length)
 
virtual void errorPrefix (UT_JSONParser &p, UT_WorkBuffer &msg)
 

Static Public Member Functions

static UT_JSONHandlegetNullHandle ()
 
static void releaseNullHandle (UT_JSONHandle *h)
 Instead of deleting the null handle, please call releaseNullHandle() More...
 

Protected Member Functions

bool isKey (const char *s1, const char *s2) const
 Convenience method to test key values. More...
 
void skipBadKey (UT_JSONParser &p, const char *key)
 
void fatalBadKey (UT_JSONParser &p, const char *key)
 

Detailed Description

UT_JSONHandle processes events from a UT_JSONParser parser.

The UT_JSONParser is passed a UT_JSONHandle to interpret the JSON tokens. As each entity is encountered, an event callback is invoked on the handle to process the token.

It's possible to recurse into the parser from within a callback with a different handler and possibly even a different input stream by calling UT_JSONParser::parseObject().

See Also
UT_JSONParser, UT_JSONHandleError, UT_JSONHandleNull, UT_JSONIStream

Definition at line 36 of file UT_JSONHandle.h.

Constructor & Destructor Documentation

UT_JSONHandle::UT_JSONHandle ( )
inline

Definition at line 38 of file UT_JSONHandle.h.

virtual UT_JSONHandle::~UT_JSONHandle ( )
inlinevirtual

Definition at line 39 of file UT_JSONHandle.h.

UT_JSONHandle::UT_JSONHandle ( const UT_JSONHandle )
delete

Member Function Documentation

virtual void UT_JSONHandle::errorPrefix ( UT_JSONParser p,
UT_WorkBuffer msg 
)
virtual

This method is called by addError to create the prefix for error messages. By default, the method looks something like:

msg.sprintf("JSON ERROR[%ld]:", (long)p.getStreamPosition());
void UT_JSONHandle::fatalBadKey ( UT_JSONParser p,
const char *  key 
)
protected

Convenience method to add a fatal error about a bad key name addError("Unexpected key token '%s'" % key);

static UT_JSONHandle* UT_JSONHandle::getNullHandle ( )
static

The Null Handle acts as a pass through when parsing a JSON file. It can be used for simple syntax checking:

bool UT_JSONHandle::isKey ( const char *  s1,
const char *  s2 
) const
inlineprotected

Convenience method to test key values.

Definition at line 127 of file UT_JSONHandle.h.

virtual bool UT_JSONHandle::jsonBeginArray ( UT_JSONParser p)
pure virtual

Event method invoked at the beginning of an array object.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonBeginMap ( UT_JSONParser p)
pure virtual

Event method invoked at the start of a map/object.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonBool ( UT_JSONParser p,
bool  value 
)
pure virtual

Event method to process a bool (true or false tokens)

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonEndArray ( UT_JSONParser p)
pure virtual

Event method invoked at the end of an array object.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonEndMap ( UT_JSONParser p)
pure virtual

Event method invoked at the end of a map/object.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonInt ( UT_JSONParser p,
int64  value 
)
pure virtual

Event method to process an integer.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonKey ( UT_JSONParser p,
const char *  v,
int64  len 
)
pure virtual

Event method to process the key of a map/object is read.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonKeyHolder ( UT_JSONParser p,
const UT_StringHolder s 
)
virtual
virtual bool UT_JSONHandle::jsonNull ( UT_JSONParser p)
pure virtual

Event method to process a null token.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonReal ( UT_JSONParser p,
fpreal64  value 
)
pure virtual

Event method to process a real/float.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonString ( UT_JSONParser p,
const char *  value,
int64  len 
)
pure virtual

Event method to process a string value.

Implemented in UT_JSONHandleNull, UT_JSONHandleError, and UT_PerfMonJSONHandle.

virtual bool UT_JSONHandle::jsonStringHolder ( UT_JSONParser p,
const UT_StringHolder s 
)
virtual

The string event taking a UT_StringHolder calls the jsonString() method by default. However, if you can process a UT_StringHolder instead, you can get a direct reference to the UT_StringHolder.

UT_JSONHandle& UT_JSONHandle::operator= ( const UT_JSONHandle )
delete
bool UT_JSONHandle::parseObject ( UT_JSONParser p,
UT_IStream is = 0 
)

Convenience method to parse a single object.

static void UT_JSONHandle::releaseNullHandle ( UT_JSONHandle h)
static

Instead of deleting the null handle, please call releaseNullHandle()

void UT_JSONHandle::skipBadKey ( UT_JSONParser p,
const char *  key 
)
protected

Convenience method to add an error about a bad key name addError("Unexpected key token '%s'" % key); This also skips the next object.

virtual bool UT_JSONHandle::uaBool ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle for uniform array of bool (encoded as bit fields)

virtual bool UT_JSONHandle::uaInt16 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of int16 data.

virtual bool UT_JSONHandle::uaInt32 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of int32 data.

virtual bool UT_JSONHandle::uaInt64 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of int64 data.

virtual bool UT_JSONHandle::uaInt8 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of int8 data.

virtual bool UT_JSONHandle::uaReal16 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of real16 data.

virtual bool UT_JSONHandle::uaReal32 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of real32 data.

virtual bool UT_JSONHandle::uaReal64 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of real64 data.

virtual bool UT_JSONHandle::uaString ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of string data (use uaReadString)

virtual bool UT_JSONHandle::uaStringToken ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of string token data (use uaReadStringToken)

virtual bool UT_JSONHandle::uaUInt16 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of unsigned uint16 data.

virtual bool UT_JSONHandle::uaUInt8 ( UT_JSONParser p,
int64  length 
)
virtual

Event method to handle uniform array of unsigned uint8 data.


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