gfxEngine_documentation
simplexml.h File Reference

Go to the source code of this file.

Macros

#define SIMPLE_XML_USER_ERROR   1000
 

Typedefs

typedef void * SimpleXmlParser
 
typedef enum simple_xml_event SimpleXmlEvent
 
typedef void *(* SimpleXmlTagHandler) (SimpleXmlParser parser, SimpleXmlEvent event, const char *szName, const char *szAttribute, const char *szValue)
 

Enumerations

enum  simple_xml_event {
  FINISH_TAG, ADD_ATTRIBUTE, FINISH_ATTRIBUTES, ADD_CONTENT,
  ADD_SUBTAG
}
 

Functions

SimpleXmlParser simpleXmlCreateParser (const char *sData, long nDataSize)
 
void simpleXmlDestroyParser (SimpleXmlParser parser)
 
int simpleXmlInitializeParser (SimpleXmlParser parser, const char *sData, long nDataSize)
 
int simpleXmlParse (SimpleXmlParser parser, SimpleXmlTagHandler handler)
 
char * simpleXmlGetErrorDescription (SimpleXmlParser parser)
 
long simpleXmlGetLineNumber (SimpleXmlParser parser)
 
void simpleXmlParseAbort (SimpleXmlParser parser, int nErrorCode)
 
int simpleXmlPushUserData (SimpleXmlParser parser, void *pData)
 
void * simpleXmlPopUserData (SimpleXmlParser parser)
 
void * simpleXmlGetUserData (SimpleXmlParser parser)
 
void * simpleXmlGetUserDataAt (SimpleXmlParser parser, int nLevel)
 

Macro Definition Documentation

#define SIMPLE_XML_USER_ERROR   1000

Minimum value for a user abort.

See also
simpleXmlParseAbort

Typedef Documentation

Enumeration describing the event types that are sent to an SimpleXmlHandler by an SimpleXmlParser.

See also
SimpleXmlTagHandler
SimpleXmlParser
typedef void* SimpleXmlParser

The simple xml parser structure.

SimpleXmlParsers should be created and destroyed using the functions simpleXmlCreateParser, simpleXmlDestoryParser.

typedef void*(* SimpleXmlTagHandler) (SimpleXmlParser parser, SimpleXmlEvent event, const char *szName, const char *szAttribute, const char *szValue)

Callback function to handle simple xml events.

The SimpleXmlTagHandler is invoked by a SimpleXmlParser whenever one of the following event types occur:

FINISH_TAG indicates that parsing of this tag has finished, szName contains the tag name, szAttribute and szValue are NULL, the result of the handler is ignored. ADD_ATTRIBUTE indicates that an attribute for this tag has been parsed, szName contains the tag name, szAttribute the attribute name and szValue contains the attribute contents, the result of the handler is ignored. FINISH_ATTRIBUTES, indicates that parsing of attributes for this tag is finished, szName contains the tag name, szAttribute and szValue are NULL, the result of the handler is ignored. ADD_CONTENT indicates that content of this tag has been parsed and should be added, szName contains the tag name and szValue contains the data to add, szAttribute is NULL and the result of the handler is ignored. ADD_SUBTAG indicates that a subtag has been parsed, szName contains the name of the subtag read, szAttribute and szValue are NULL, the result of the handler should either be NULL to indicate that this subtag is not of interest and should be skipped a SimpleXmlTagHandler that is used for handling the subtag.

See also
SimpleXmlEvent
SimpleXmlParser

Enumeration Type Documentation

Enumeration describing the event types that are sent to an SimpleXmlHandler by an SimpleXmlParser.

See also
SimpleXmlTagHandler
SimpleXmlParser
Enumerator
FINISH_TAG 
ADD_ATTRIBUTE 
FINISH_ATTRIBUTES 
ADD_CONTENT 
ADD_SUBTAG 

Function Documentation

SimpleXmlParser simpleXmlCreateParser ( const char *  sData,
long  nDataSize 
)

Creates a new simple xml parser for the specified input data.

The input data may be parsed with simpleXmlParse and the parser returned by this function as parameter.

Note: The parser will not copy the input data or in any way modify it. However any modifications of the input data in a callback handler while parsing will have an undefined result!

Parameters
sDatathe input data to parse (must no be NULL).
nDataSizethe size of the input data buffer (sData) to parse (must be greater than 0).
Returns
the new simple xml parser or NULL if there is not enough memory or the input data specified cannot be parsed.
void simpleXmlDestroyParser ( SimpleXmlParser  parser)

Destroys the specified simple xml parser.

Parameters
parserthe parser to destroy (must have been created using simpleXmlCreateParser).
char* simpleXmlGetErrorDescription ( SimpleXmlParser  parser)

Returns a description of the error that occured during parsing.

Parameters
parserthe parser for which to get the error description.
Returns
an error description or NULL if there was no error during parsing.
long simpleXmlGetLineNumber ( SimpleXmlParser  parser)

Returns the line number of the current input line that the parser has read.

In case of an error this method will return the line number on which the error was encountered after a call to simpleXmlParse.

If called from a handler during parsing this function will return the current line number.

If called after a successfull simpleXmlParse run this function will return the line number of the last line parsed in the xml data.

Returns
the current input line number of the parser or -1 if it is unknown.
void* simpleXmlGetUserData ( SimpleXmlParser  parser)

Peeks at the top of the user data stack.

The last pointer pushed on the user data stack is returned.

Note: This function does not modify the stack.

This function is a convenience function for simpleXmlGetUserDataAt(parser, 0);

Parameters
parserthe parser from which to get the user data pointer.
Returns
the value of the user data pointer or NULL if the pointer has not been set yet.
void* simpleXmlGetUserDataAt ( SimpleXmlParser  parser,
int  nLevel 
)

Peeks at a specified location from to the top of the user data stack.

The level indicates the level from the top of the stack that is inspected.

Note: This method does not modify the stack.

Parameters
parserthe parser from which to get the user data pointer.
nLevelthe level (from the top of the stack) to inspect.
Returns
the value of the user data pointer at the specified level or NULL if there is no such entry (i.e. the level is higher than the stack depth).
int simpleXmlInitializeParser ( SimpleXmlParser  parser,
const char *  sData,
long  nDataSize 
)

Reinitializes the specified simple xml parser for parsing the specified input data.

Parameters
parserthe parser to initialize.
sDatathe input data to parse (must no be NULL).
nDataSizethe size of the input data buffer (sData) to parse (must be greater than 0).
Returns
0 if the parser could not be initialized, > 0 if the parser was initialized successfully and parsing may be started using simpleXmlParse.
int simpleXmlParse ( SimpleXmlParser  parser,
SimpleXmlTagHandler  handler 
)

Starts an initialized (or newly created) xml parser with the specified document tag handler.

Note: This function may only be called once after creation or initialization of a parser. To reuse the parser it has to be freshly initialized (using simpleXmlInitializeParser) prior to calling the function again.

Parameters
parserthe parser to start.
handlerthe handler to use for the document tag.
Returns
0 if there was no error, and error code > 0 if there was an error.
void simpleXmlParseAbort ( SimpleXmlParser  parser,
int  nErrorCode 
)

Causes the simple xml parser to abort parsing of the input data.

This method may only be called from a tag handler.

The active simpleXmlParse run will be aborted and the simpleXmlParse function will return with the specified error code.

Parameters
nErrorCodethe error code with which to abort (the error code must be >= SIMPLE_XML_USER_ERROR else the abort request is ignored!)
void* simpleXmlPopUserData ( SimpleXmlParser  parser)

Pops the last pointer pushed on the user data stack of the parser.

Parameters
parserthe parser on which to pop the user data pointer.
Returns
the last pointer pushed or NULL if the stack is empty.
int simpleXmlPushUserData ( SimpleXmlParser  parser,
void *  pData 
)

Pushes the specified pointer on the user data stack of the parser.

Parameters
parserthe parser on which to push the user data pointer.
pDatapointer to the user data to set (NULL is not a valid value).
Returns
> 0 on success, 0 if there is not enough memory left or it was tried to push a NULL data pointer.