HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_JSONHandleError Class Reference

This class generates errors on any JSON events. More...

#include <UT_JSONHandle.h>

+ Inheritance diagram for UT_JSONHandleError:

Public Member Functions

 UT_JSONHandleError (bool fatal=true)
 
virtual ~UT_JSONHandleError ()
 
virtual const char * getClassName () const
 
virtual bool jsonNull (UT_JSONParser &p)
 Event method to process a null token. More...
 
virtual bool jsonBool (UT_JSONParser &p, bool value)
 Event method to process a bool (true or false tokens) More...
 
virtual bool jsonInt (UT_JSONParser &p, int64 value)
 Event method to process an integer. More...
 
virtual bool jsonReal (UT_JSONParser &p, fpreal64 value)
 Event method to process a real/float. More...
 
virtual bool jsonString (UT_JSONParser &p, const char *v, int64 len)
 Event method to process a string value. More...
 
virtual bool jsonKey (UT_JSONParser &p, const char *v, int64 len)
 Event method to process the key of a map/object is read. More...
 
virtual bool jsonBeginMap (UT_JSONParser &p)
 Event method invoked at the start of a map/object. More...
 
virtual bool jsonEndMap (UT_JSONParser &p)
 Event method invoked at the end of a map/object. More...
 
virtual bool jsonBeginArray (UT_JSONParser &p)
 Event method invoked at the beginning of an array object. More...
 
virtual bool jsonEndArray (UT_JSONParser &p)
 Event method invoked at the end of an array object. More...
 
- Public Member Functions inherited from UT_JSONHandle
 UT_JSONHandle ()
 
virtual ~UT_JSONHandle ()
 
bool parseObject (UT_JSONParser &p, UT_IStream *is=0)
 Convenience method to parse a single object. More...
 
virtual bool jsonStringHolder (UT_JSONParser &p, const UT_StringHolder &s)
 
virtual bool jsonKeyHolder (UT_JSONParser &p, const UT_StringHolder &s)
 
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)
 

Protected Member Functions

virtual bool typeError (UT_JSONParser &p, const char *name)
 Add a type error for the given name. More...
 
bool getFatal () const
 Check whether errors should be fatal (or just warnings) More...
 
void setFatal (bool f)
 Set whether errors should be fatal (or just warnings) More...
 
- Protected Member Functions inherited from UT_JSONHandle
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)
 

Additional Inherited Members

- Static Public Member Functions inherited from UT_JSONHandle
static UT_JSONHandlegetNullHandle ()
 
static void releaseNullHandle (UT_JSONHandle *h)
 Instead of deleting the null handle, please call releaseNullHandle() More...
 

Detailed Description

This class generates errors on any JSON events.

The UT_JSONHandleError class will throw errors on any JSON events. It's useful as a base class for an event handler which only expects certain events. For example, if you only expect the keyword argument, you might have a class like:

class MyHandle : public UT_JSONHandleError {
virtual bool jsonKey(UT_JSONParser &p, const char *v, int64 len);
virtual const char *className() { return "MyClass" }
}

The base class would handle trapping errors on anything other than a map key.

Note
Uniform arrays are handled by the UT_JSONHandle base class
See Also
UT_JSONHandle, UT_JSONHandleNull

Definition at line 152 of file UT_JSONHandle.h.

Constructor & Destructor Documentation

UT_JSONHandleError::UT_JSONHandleError ( bool  fatal = true)
inline
Parameters
fatal
If fatal is true then errors will cause parsing to terminate. Otherwise, parsing will continue and errors will cascade.

Definition at line 157 of file UT_JSONHandle.h.

virtual UT_JSONHandleError::~UT_JSONHandleError ( )
inlinevirtual

Definition at line 158 of file UT_JSONHandle.h.

Member Function Documentation

virtual const char* UT_JSONHandleError::getClassName ( ) const
virtual

getClassName() should return a meaningful label. The errors generated will be: Error parsing s: Unexpected "type" JSON object The default is an empty string.

bool UT_JSONHandleError::getFatal ( ) const
inlineprotected

Check whether errors should be fatal (or just warnings)

Definition at line 180 of file UT_JSONHandle.h.

virtual bool UT_JSONHandleError::jsonBeginArray ( UT_JSONParser p)
virtual

Event method invoked at the beginning of an array object.

Implements UT_JSONHandle.

virtual bool UT_JSONHandleError::jsonBeginMap ( UT_JSONParser p)
virtual

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

Implements UT_JSONHandle.

virtual bool UT_JSONHandleError::jsonBool ( UT_JSONParser p,
bool  value 
)
virtual

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

Implements UT_JSONHandle.

virtual bool UT_JSONHandleError::jsonEndArray ( UT_JSONParser p)
virtual

Event method invoked at the end of an array object.

Implements UT_JSONHandle.

virtual bool UT_JSONHandleError::jsonEndMap ( UT_JSONParser p)
virtual

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

Implements UT_JSONHandle.

virtual bool UT_JSONHandleError::jsonInt ( UT_JSONParser p,
int64  value 
)
virtual

Event method to process an integer.

Implements UT_JSONHandle.

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

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

Implements UT_JSONHandle.

virtual bool UT_JSONHandleError::jsonNull ( UT_JSONParser p)
virtual

Event method to process a null token.

Implements UT_JSONHandle.

virtual bool UT_JSONHandleError::jsonReal ( UT_JSONParser p,
fpreal64  value 
)
virtual

Event method to process a real/float.

Implements UT_JSONHandle.

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

Event method to process a string value.

Implements UT_JSONHandle.

void UT_JSONHandleError::setFatal ( bool  f)
inlineprotected

Set whether errors should be fatal (or just warnings)

Definition at line 182 of file UT_JSONHandle.h.

virtual bool UT_JSONHandleError::typeError ( UT_JSONParser p,
const char *  name 
)
protectedvirtual

Add a type error for the given name.


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