diff options
author | lordjaxom <lordjaxom> | 2004-12-08 18:48:39 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2004-12-08 18:48:39 +0000 |
commit | 5382d18d05d358bb1c313c642395e835aa44a6a0 (patch) | |
tree | 2b5ef58620b3640c5b21e8eafe92ee4b266b1d30 /xml/xml.h | |
parent | eb2f2c9600e8f69788232582191b141002bcd522 (diff) | |
download | vdr-plugin-text2skin-5382d18d05d358bb1c313c642395e835aa44a6a0.tar.gz vdr-plugin-text2skin-5382d18d05d358bb1c313c642395e835aa44a6a0.tar.bz2 |
1.0-pre1v1.0-pre1
Diffstat (limited to 'xml/xml.h')
-rw-r--r-- | xml/xml.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/xml/xml.h b/xml/xml.h new file mode 100644 index 0000000..9abc641 --- /dev/null +++ b/xml/xml.h @@ -0,0 +1,63 @@ +/* + * $Id: xml.h,v 1.1.1.1 2004/11/19 16:45:31 lordjaxom Exp $ + * This module was kindly provided by Clemens Kirchgatterer + */ + +#ifndef _XML_H_ +#define _XML_H_ + +#include <string> +#include <map> + +#define XML_NODE_START_CB(CB) \ +bool (*CB)(const std::string &tag, std::map<std::string, std::string> &attr) +#define XML_NODE_END_CB(CB) \ +bool (*CB)(const std::string &tag) +#define XML_CDATA_CB(CB) \ +bool (*CB)(const std::string &text) +#define XML_PARSE_ERROR_CB(CB) \ +void (*CB)(int line, const char *txt, char c) +#define XML_PROGRESS_CB(CB) \ +void (*CB)(int percent) + +class XML { + +public: + + XML(const std::string &file); + XML(const char *mem, unsigned int len); + + void nodeStartCB(XML_NODE_START_CB(cb)); + void nodeEndCB(XML_NODE_END_CB(cb)); + void cdataCB(XML_CDATA_CB(cb)); + void parseErrorCB(XML_PARSE_ERROR_CB(cb)); + void progressCB(XML_PROGRESS_CB(cb)); + + int parse(void); + + int lineNr(void) const { return linenr; } + +protected: + + bool isTokenChar(bool start, int c); + int readChar(int c); + +private: + + bool skipping; + int state; + int linenr; + int delim; + + std::string data, cdata, tag, attrn, attrv; + std::map<std::string, std::string> attr; + + XML_NODE_START_CB(nodestartcb); + XML_NODE_END_CB(nodeendcb); + XML_CDATA_CB(cdatacb); + XML_PARSE_ERROR_CB(parseerrorcb); + XML_PROGRESS_CB(progresscb); + +}; + +#endif // _XML_H_ |