MoSync 3.3
MTSax.h File Reference

Tiny SAX parser. More...

Classes

struct  MTXSaxContext_t
 The context of an MTSax parser. More...
class  Mtx::SaxListenerT< Tchar >
 Base class for SAX parser callback interfaces. More...
class  Mtx::SaxListener
 8-bit SAX parser callback interface. More...
class  Mtx::SaxListenerW
 Wide-char SAX parser callback interface. More...
class  Mtx::SaxContextBase
 Base class for SAX parser context wrappers. More...
class  Mtx::SaxContext
 8-bit SAX parser context wrapper class. More...
class  Mtx::SaxContextW
 Wide-char SAX parser context wrapper class. More...

Namespaces

namespace  Mtx
 

MoSync wrappers for XML/SAX parser.


Typedefs

typedef struct MTXSaxContext_t MTXSaxContext
 The context of an MTSax parser.

Functions

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

Detailed Description

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.


Typedef Documentation

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.
Note:
This function alters the content of the input buffer.
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.

Note:
This function alters the content of the input buffer.
See also:
mtxSaxFeed()
bool mtxSaxFeedWide ( MTXSaxContext context,
char *  data,
wchar_t *  wideBuffer 
)
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.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines