MTSax.h File Reference


Detailed Description

MoSync Tiny SAX parser.

MTSax is a simple SAX parser built as a thin layer on top of MTXml.

For detailed information about the parsing capabilities and restrictions of MTSax, see the documentation for MTXml.

MTSax differs mainly from MTXml in that it caches certain pieces of data, in order to provide more user-friendly callbacks. This means that, unlike MTXml, MTSax has to allocate memory from the heap during parsing.


Namespaces

namespace  Mtx

Classes

struct  MTXSaxContext_t
class  Mtx::SaxListener
class  Mtx::SaxContext

Typedefs

typedef MTXSaxContext_t MTXSaxContext

Functions

void mtxSaxStart (MTXSaxContext *context)
bool mtxSaxFeed (MTXSaxContext *context, char *data)
bool mtxSaxFeedProcess (MTXSaxContext *context, char *data)
void mtxSaxStop (MTXSaxContext *context)


Typedef Documentation

typedef struct MTXSaxContext_t MTXSaxContext
 

The context of an MTSax parser. Contains function pointers for callbacks from the parser. Also contains internal variables.

You must set all the callbacks before calling mtxSaxStart().


Function Documentation

void mtxSaxStart MTXSaxContext context  ) 
 

Initializes a context's internal state. Must be called before the first call to mtxSaxFeed() with this context.

Remarks:
As the MTSax context allocates memory from the heap, mtxSaxStop() must be called either to stop the parsing prematurely or after having parsed the entire document. Failure to do so will lead to memory leaks.

bool mtxSaxFeed MTXSaxContext context,
char *  data
 

Parses data in the specified context.

The data is null-terminated. It needn't be the entire XML document; MTXSaxContext::dataRemains() will be called with any data that couldn't be completely parsed. You can then call this function again when you have more data.

You must not call this function from within an MTSax callback. Doing so would corrupt the parser's internal state.

Returns:
True if mtxSaxStop() was called from a callback within the call to this function, false otherwise.

bool mtxSaxFeedProcess MTXSaxContext context,
char *  data
 

Parses data in the specified context.

Data sent to callbacks will have its UTF-8 characters and standard entities converted to Latin-1.

See also:
mtxSaxFeed()

void mtxSaxStop MTXSaxContext context  ) 
 

Stops parsing and frees any allocated memory. Must be called either to stop parsing prematurely, or after having parsed the document, in order to avoid memory leaks.

If called from within an MTSax callback, this function ensures that no more callbacks will be called during this feed and that it is safe to call mtxSaxStart() on the context.

However, it is still not allowed to call mtxSaxFeed() from within a an MTSax callback.


Generated on Sat Feb 13 00:15:38 2010 for MoSync 2 beta 1 by  doxygen 1.4.6-NO