|
Public Types |
enum | {
PARSE_OK = XML_ERROR_NONE,
PARSE_BADELEMENT = XML_ERROR_NONE + 400,
PARSE_BADATTRIBUTE = XML_ERROR_NONE + 401,
PARSE_CANTBEROOT = XML_ERROR_NONE + 402,
PARSE_MUSTBEROOT = XML_ERROR_NONE + 403,
PARSE_MISSINGATTRIBUTE = XML_ERROR_NONE + 404,
PARSE_APPERROR = XML_ERROR_NONE + 500
} |
Public Member Functions |
| gxXmlAbstractParser (char *elemSpecs[]=NULL) |
| Constructor takes an optional list of element specs of the form: { "@docroot;attr1;attr2", "elem1;attr3;attr4", NULL }.
|
virtual | ~gxXmlAbstractParser () |
int | parse (const std::string &s, int isFinal=true) |
int | parse (const char *s, int len, int isFinal=true) |
void | stop () |
| Stop the parser without setting error code/message.
|
void | error (const char *errorMessage, int errorCode=PARSE_APPERROR) |
| Stop the parser supplying an error code/message.
|
void | clear () |
int | getLastError () |
std::string | getLastErrorMessage () |
void | setLastError (int error) |
void | setLastErrorMessage (const char *message) |
void | addSpec (const char *spec) |
Protected Types |
typedef std::map< std::string,
gxXmlElementSpec > | element_specs_t |
typedef std::list< gxXmlElement > | context_t |
Protected Member Functions |
virtual int | verifyElement () |
virtual void | onElement ()=0 |
gxXmlElement & | getCurrentElement () |
bool | hasParent () |
gxXmlElement & | getParentElement () |
Protected Attributes |
element_specs_t | elementSpecs |
context_t | m_context |
Takes care of invoking the expat parser, validating elements/attributes, and maintaining a context stack of the XML elements currently being parsed.
When implementing an application specific parser, create a new class derived from gxXmlAbstractParser and override onElement. Within onElement you can invoke helper methods such as getCurrentElement, getParentElement etc.