|
|
Home | Loader API | Interfaces | File List | Index | |
This is the main JSON interface. More...
#include <p6jsonreader.h>
Inherits P6R::p6ICom.
Public Member Functions | |
virtual P6R::P6INT32 | addref ()=0 |
This method increases the reference count of the component instance by one. | |
virtual P6R::P6ERR | getContentHandler (p6IJSONContentHandler **pObject)=0 |
The content handler component is defined and set by the application. | |
virtual P6R::P6ERR | getErrorHandler (p6IJSONErrorHandler **pObject)=0 |
The Error handler component is defined and set by the application. | |
virtual P6R::P6ERR | initialize (P6JSONFLAGS flags, P6UINT32 streamBufSize)=0 |
Sets up the component to run properly. | |
virtual P6R::P6ERR | queryInterface (const P6R::IID &iid, P6R::P6VOID **ppIface)=0 |
This method queries the component for a specific interface. | |
virtual P6R::P6INT32 | release ()=0 |
This method decrements a components reference count. | |
virtual P6R::P6ERR | releaseAllHandlers ()=0 |
This was addded to make it easy for an application to tell the JSON reader to free all set handlers. | |
virtual P6R::P6ERR | setContentHandler (p6IJSONContentHandler *pObject)=0 |
The calling application uses this method to register a content handler. | |
virtual P6R::P6ERR | setErrorHandler (p6IJSONErrorHandler *pObject)=0 |
The calling application uses this method to register an error event hanlder. |
This is the main JSON interface.
Notice that there is no separate parse function. That is because this component implements the P6R::p6IDataStream interface (see p6datastream.h). Thus this component supports the parsing of a stream of JSON data.
To parse either a single buffer or a stream of JSON buffers perform the following steps:
First get an JSON reader object: p6IJSONReader *pReader; P6ERR err = p6CreateInstance( NULL, CID_p6JSONReader, VALIDATEIF( p6IJSONReader, &pReader )); Then using the JSON reader, get the p6IDataStream interface on that component: p6IDataStream *pStream err = pReader->queryInterface( VALIDATEIF( p6IDataStream, &pStream )); Initialize the data stream interface: err = pStream->beginStream(); Pass the buffer(s) to be parsed one at a time: err = pStream->processStream( buffer, bufSize ); // -> 1st buffer of stream . . . . . . err = pStream->processStream( buffer, bufSize ); // -> nth buffer of stream
The input 'buffer' to the processStream() method is where the P6JSONSTRING pointers will often point to. The processStream() function can return an "eEndOfFile" error code to indicate that it is done with the buffer provided and that the buffer is incomplete (i.e., the JSON top most object has not yet been closed).
Close the stream down: err = pStream->endStream(); pStream->release();
Definition at line 74 of file p6jsonreader.h.