IncredibleXMLParser
3.05
|
Pure Virtual Class defining a basic template for a Pull Parser. More...
#include <IXMLParser.h>
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... | |
IXMLAttribute * | getAttribute (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 IXMLClear * | getClear () 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 | |
IXMLReader * | uReader |
IXMLReader * | sourceUReader |
IXMLAttribute * | allAttributes |
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 |
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.
Enumeration for XML character encoding.
typedef enum IPullParser::IXMLToken IPullParser::IXMLToken |
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.
IPullParser::IPullParser | ( | IXMLReader * | _uReader, |
int | _szByteBuffer | ||
) |
|
inlinevirtual |
Definition at line 455 of file IXMLParser.h.
|
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 |
Set the current encoding of the source XML text and the desired encoding of the strings returned by the Pull Parser.
const IXMLClear* IPullParser::getClear | ( | ) | const |
if the current token==IXMLToken_Clear, return the clear tag
|
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
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
|
pure virtual |
read the data stream a little bit more to get the next token
Implemented in IJSONPullParser, and IXMLPullParser.
|
protected |
|
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
|
virtual |
|
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
|
protected |
Definition at line 580 of file IXMLParser.h.
|
protected |
Definition at line 580 of file IXMLParser.h.
|
protected |
Definition at line 580 of file IXMLParser.h.
|
protected |
Definition at line 576 of file IXMLParser.h.
|
protected |
Definition at line 578 of file IXMLParser.h.
|
protected |
Definition at line 575 of file IXMLParser.h.
|
protected |
Definition at line 585 of file IXMLParser.h.
|
protected |
Definition at line 631 of file IXMLParser.h.
|
protected |
Definition at line 586 of file IXMLParser.h.
|
protected |
Definition at line 629 of file IXMLParser.h.
|
protected |
Definition at line 628 of file IXMLParser.h.
|
protected |
Definition at line 582 of file IXMLParser.h.
|
protected |
Definition at line 577 of file IXMLParser.h.
|
protected |
Definition at line 578 of file IXMLParser.h.
|
protected |
Definition at line 633 of file IXMLParser.h.
|
protected |
Definition at line 581 of file IXMLParser.h.
|
protected |
Definition at line 579 of file IXMLParser.h.
|
protected |
Definition at line 583 of file IXMLParser.h.
|
protected |
Definition at line 632 of file IXMLParser.h.
|
protected |
Definition at line 632 of file IXMLParser.h.
|
protected |
Definition at line 632 of file IXMLParser.h.
|
protected |
Definition at line 574 of file IXMLParser.h.
|
protected |
Definition at line 576 of file IXMLParser.h.
|
protected |
Definition at line 574 of file IXMLParser.h.
|
protected |
Definition at line 587 of file IXMLParser.h.