IncredibleXMLParser  3.05
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members

Pure Virtual Class defining a basic template for a Pull Parser. More...

#include <IXMLParser.h>

Inheritance diagram for IPullParser:
IJSONPullParser IXMLPullParser

Classes

class  IXMLReader_FromUTF16
 
class  IXMLReader_PassThrough
 
class  IXMLReader_ToUTF16
 

Public Types

enum  IXMLToken {
  IXMLToken_StartDocument =0, IXMLToken_StartTag =1, IXMLToken_EndTag =2, IXMLToken_Text =3,
  IXMLToken_Clear =4, IXMLToken_ProcessingInstruction =5, IXMLToken_EndDocument =6, IXMLToken_Warning =7,
  IXMLToken_Error =8
}
 
enum  IXMLCharEncoding {
  char_encoding_error =0, char_encoding_UTF16 =1, char_encoding_UTF8 =2, char_encoding_System =3,
  char_encoding_legacy =4, char_encoding_ShiftJIS =5, char_encoding_GB2312 =6, char_encoding_Big5 =7,
  char_encoding_GBK =8
}
 Enumeration for XML character encoding. More...
 
typedef enum IPullParser::IXMLToken IXMLToken
 
typedef enum
IPullParser::IXMLCharEncoding 
IXMLCharEncoding
 Enumeration for XML character encoding. More...
 

Public Member Functions

 IPullParser (IXMLReader *_uReader, int _szByteBuffer)
 
virtual ~IPullParser ()
 
char setBufferSize (int _szByteBuffer)
 Change the memory buffer size. More...
 
virtual void reset ()
 re-start the pull parser (set token=IXMLToken_StartDocument) More...
 
virtual void clear ()=0
 free all internal memory buffers More...
 
virtual IXMLToken nextToken ()=0
 read the data stream a little bit more to get the next token More...
 
IXMLToken currentToken () const
 get the current token More...
 
bool findPath (IXMLCStr path, IXMLChar sep='/', IXMLResults *r=NULL)
 read the data stream to reach a XML tag with the specified path More...
 
bool findPathNonConst (IXMLStr path, IXMLChar sep='/', IXMLResults *r=NULL)
 read the data stream to reach a XML tag with the specified path More...
 
IXMLCStr getName () const
 if the current token==IXMLToken_StartTag, return the tag name More...
 
bool isEmptyNode () const
 if the current token==IXMLToken_StartTag, tell if the tag is directly closed or not More...
 
bool isArrayStart () const
 used during JSON parsing to separate arrays([) from object({). More...
 
int nAttribute () const
 if the current token==IXMLToken_StartTag, return number of attributes More...
 
IXMLAttributegetAttribute (int i=0) const
 if the current token==IXMLToken_StartTag, return ith attribute More...
 
IXMLCStr getAttributeName (int i=0) const
 if the current token==IXMLToken_StartTag, return ith attribute name More...
 
IXMLCStr getAttributeValue (int i=0) const
 if the current token==IXMLToken_StartTag, return ith attribute value More...
 
int szAttributeValue (int i=0) const
 if the current token==IXMLToken_StartTag, return ith attribute size More...
 
IXMLCStr getText () const
 if the current token==IXMLToken_Text, return the text More...
 
int szText () const
 if the current token==IXMLToken_Text, return the text size in char More...
 
bool isTextWhiteSpace () const
 if the current token==IXMLToken_Text, return true if the text is ignorable (i.e.composed of white space only) More...
 
const IXMLCleargetClear () const
 if the current token==IXMLToken_Clear, return the clear tag More...
 
IXMLError getErrorCode () const
 if the current token==IXMLToken_Error, return the error code More...
 
long long getLineNumber () const
 return the current line number More...
 
virtual int getColumnNumber () const
 return the current column number expressed in byte or wchar More...
 
int getDepth () const
 return the current depth More...
 
void setAutoDetectSourceEncoding (bool autoDetectSource=false)
 
bool getAutoDetectSourceEncoding ()
 
virtual char setCharEncoding (IXMLCharEncoding sourceEncoding=char_encoding_UTF8, IXMLCharEncoding destinationEncoding=char_encoding_UTF8)
 
virtual IXMLCharEncoding getCharEncodingDestination ()
 
IXMLCStr getVersion ()
 Return the IXMLParser library version number. More...
 

Static Public Member Functions

static IXMLCStr getErrorMessage (IXMLError error)
 this gives you a user-friendly explanation of the parsing error More...
 

Protected Member Functions

bool skipBranch (int skipVar)
 
char readData (IXMLStr *ptr, IXMLStr *pend, IXMLStr *ptrOut, IXMLStr *pStart)
 

Protected Attributes

IXMLReaderuReader
 
IXMLReadersourceUReader
 
IXMLAttributeallAttributes
 
int szByteBuffer
 
int _nAttribute
 
IXMLToken curToken
 
int depth
 
int _szText
 
long long nLine
 
bool _isEmptyNode
 
bool _isIgnorableSpace
 
bool _isInArray
 
IXMLError lastError
 
IXMLClear curClearTag
 
IXMLStr pContent
 
bool autoDetectSource
 
IXMLCharEncoding characterEncoding
 
const char * XML_ByteTable
 
IXMLReader_ToUTF16 charEncodingConverterToUTF16
 
IXMLReader_FromUTF16 charEncodingConverterFromUTF16
 
unsigned char * bufferChar
 
IXMLStr pCurrentPos
 
IXMLStr pEndPos
 
IXMLStr pStartOfLine
 
bool isStreamFinished
 

Detailed Description

Pure Virtual Class defining a basic template for a Pull Parser.

Do not use this class: Use instead one of the Children classes: IXMLPullParser or IJSONPullParser

Definition at line 451 of file IXMLParser.h.

Member Typedef Documentation

Enumeration for XML character encoding.

Member Enumeration Documentation

Enumeration for XML character encoding.

Enumerator
char_encoding_error 
char_encoding_UTF16 
char_encoding_UTF8 
char_encoding_System 
char_encoding_legacy 
char_encoding_ShiftJIS 
char_encoding_GB2312 
char_encoding_Big5 
char_encoding_GBK 

Definition at line 540 of file IXMLParser.h.

Enumerator
IXMLToken_StartDocument 
IXMLToken_StartTag 
IXMLToken_EndTag 
IXMLToken_Text 
IXMLToken_Clear 
IXMLToken_ProcessingInstruction 
IXMLToken_EndDocument 
IXMLToken_Warning 
IXMLToken_Error 

Definition at line 469 of file IXMLParser.h.

Constructor & Destructor Documentation

IPullParser::IPullParser ( IXMLReader _uReader,
int  _szByteBuffer 
)
virtual IPullParser::~IPullParser ( )
inlinevirtual

Definition at line 455 of file IXMLParser.h.

Member Function Documentation

virtual void IPullParser::clear ( )
pure virtual

free all internal memory buffers

Call this function when you have finished using this object to release memory used by the internal buffers.

Implemented in IJSONPullParser, and IXMLPullParser.

IXMLToken IPullParser::currentToken ( ) const

get the current token

bool IPullParser::findPath ( IXMLCStr  path,
IXMLChar  sep = '/',
IXMLResults r = NULL 
)

read the data stream to reach a XML tag with the specified path

Referenced by example7().

bool IPullParser::findPathNonConst ( IXMLStr  path,
IXMLChar  sep = '/',
IXMLResults r = NULL 
)

read the data stream to reach a XML tag with the specified path

IXMLAttribute* IPullParser::getAttribute ( int  i = 0) const

if the current token==IXMLToken_StartTag, return ith attribute

IXMLCStr IPullParser::getAttributeName ( int  i = 0) const

if the current token==IXMLToken_StartTag, return ith attribute name

IXMLCStr IPullParser::getAttributeValue ( int  i = 0) const

if the current token==IXMLToken_StartTag, return ith attribute value

bool IPullParser::getAutoDetectSourceEncoding ( )

When the "AutoDetectSourceEncoding" flag is set, the parser try to guess the character encoding. It then change the current character encoding used inside the parser accordingly. The guess is based on the content of a buffer of length 512 bytes that contains the first bytes of the file/string to be parsed. There are several heuristics used to do the guess. One of the heuristic is based on the "encoding" attribute inside the XML text. The original XML specifications forbids to use this attribute to do the guess but we still use it nevertheless (this is the behavior of 99% of the parsers).

By default, the "AutoDetectSourceEncoding" flag is OFF in char* mode. By default, the "AutoDetectSourceEncoding" flag is ON in wchar_t* mode.

virtual IXMLCharEncoding IPullParser::getCharEncodingDestination ( )
virtual

Set the current encoding of the source XML text and the desired encoding of the strings returned by the Pull Parser.

Returns
"0" when there are no errors. If you try to set an unrecognized encoding then the return value will be "1" to signal an error.
const IXMLClear* IPullParser::getClear ( ) const

if the current token==IXMLToken_Clear, return the clear tag

virtual int IPullParser::getColumnNumber ( ) const
virtual

return the current column number expressed in byte or wchar

Reimplemented in IXMLPullParser.

int IPullParser::getDepth ( ) const

return the current depth

IXMLError IPullParser::getErrorCode ( ) const

if the current token==IXMLToken_Error, return the error code

static IXMLCStr IPullParser::getErrorMessage ( IXMLError  error)
static

this gives you a user-friendly explanation of the parsing error

Referenced by example4().

long long IPullParser::getLineNumber ( ) const

return the current line number

IXMLCStr IPullParser::getName ( ) const

if the current token==IXMLToken_StartTag, return the tag name

IXMLCStr IPullParser::getText ( ) const

if the current token==IXMLToken_Text, return the text

IXMLCStr IPullParser::getVersion ( )

Return the IXMLParser library version number.

bool IPullParser::isArrayStart ( ) const

used during JSON parsing to separate arrays([) from object({).

During JSON parsing only: If the current token==IXMLToken_StartTag or IXMLToken_EndTag This tells you if we are inside an JSON array ([) or inside an JSON object ({).

bool IPullParser::isEmptyNode ( ) const

if the current token==IXMLToken_StartTag, tell if the tag is directly closed or not

For example:

bool IPullParser::isTextWhiteSpace ( ) const

if the current token==IXMLToken_Text, return true if the text is ignorable (i.e.composed of white space only)

int IPullParser::nAttribute ( ) const

if the current token==IXMLToken_StartTag, return number of attributes

virtual IXMLToken IPullParser::nextToken ( )
pure virtual

read the data stream a little bit more to get the next token

Implemented in IJSONPullParser, and IXMLPullParser.

char IPullParser::readData ( IXMLStr ptr,
IXMLStr pend,
IXMLStr ptrOut,
IXMLStr pStart 
)
protected
virtual void IPullParser::reset ( )
virtual

re-start the pull parser (set token=IXMLToken_StartDocument)

This does not free the memory buffers and it also keeps the current char encoding settings.

Reimplemented in IJSONPullParser, and IXMLPullParser.

void IPullParser::setAutoDetectSourceEncoding ( bool  autoDetectSource = false)
char IPullParser::setBufferSize ( int  _szByteBuffer)

Change the memory buffer size.

You can only change the buffer size when the token==IXMLToken_StartDocument

Returns
"0" if you successfully changed the buffer size.
virtual char IPullParser::setCharEncoding ( IXMLCharEncoding  sourceEncoding = char_encoding_UTF8,
IXMLCharEncoding  destinationEncoding = char_encoding_UTF8 
)
virtual
bool IPullParser::skipBranch ( int  skipVar)
protected
int IPullParser::szAttributeValue ( int  i = 0) const

if the current token==IXMLToken_StartTag, return ith attribute size

int IPullParser::szText ( ) const

if the current token==IXMLToken_Text, return the text size in char

Member Data Documentation

bool IPullParser::_isEmptyNode
protected

Definition at line 580 of file IXMLParser.h.

bool IPullParser::_isIgnorableSpace
protected

Definition at line 580 of file IXMLParser.h.

bool IPullParser::_isInArray
protected

Definition at line 580 of file IXMLParser.h.

int IPullParser::_nAttribute
protected

Definition at line 576 of file IXMLParser.h.

int IPullParser::_szText
protected

Definition at line 578 of file IXMLParser.h.

IXMLAttribute* IPullParser::allAttributes
protected

Definition at line 575 of file IXMLParser.h.

bool IPullParser::autoDetectSource
protected

Definition at line 585 of file IXMLParser.h.

unsigned char* IPullParser::bufferChar
protected

Definition at line 631 of file IXMLParser.h.

IXMLCharEncoding IPullParser::characterEncoding
protected

Definition at line 586 of file IXMLParser.h.

IXMLReader_FromUTF16 IPullParser::charEncodingConverterFromUTF16
protected

Definition at line 629 of file IXMLParser.h.

IXMLReader_ToUTF16 IPullParser::charEncodingConverterToUTF16
protected

Definition at line 628 of file IXMLParser.h.

IXMLClear IPullParser::curClearTag
protected

Definition at line 582 of file IXMLParser.h.

IXMLToken IPullParser::curToken
protected

Definition at line 577 of file IXMLParser.h.

int IPullParser::depth
protected

Definition at line 578 of file IXMLParser.h.

bool IPullParser::isStreamFinished
protected

Definition at line 633 of file IXMLParser.h.

IXMLError IPullParser::lastError
protected

Definition at line 581 of file IXMLParser.h.

long long IPullParser::nLine
protected

Definition at line 579 of file IXMLParser.h.

IXMLStr IPullParser::pContent
protected

Definition at line 583 of file IXMLParser.h.

IXMLStr IPullParser::pCurrentPos
protected

Definition at line 632 of file IXMLParser.h.

IXMLStr IPullParser::pEndPos
protected

Definition at line 632 of file IXMLParser.h.

IXMLStr IPullParser::pStartOfLine
protected

Definition at line 632 of file IXMLParser.h.

IXMLReader * IPullParser::sourceUReader
protected

Definition at line 574 of file IXMLParser.h.

int IPullParser::szByteBuffer
protected

Definition at line 576 of file IXMLParser.h.

IXMLReader* IPullParser::uReader
protected

Definition at line 574 of file IXMLParser.h.

const char* IPullParser::XML_ByteTable
protected

Definition at line 587 of file IXMLParser.h.


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