wrapexpat.h

00001 #ifndef GM_WRAP_EXPAT_H 00002 #define GM_WRAP_EXPAT_H 00003 00004 #include <vector> 00005 #include <stack> 00006 00007 #include "gm/exception.h" 00008 #include "expat.h" 00009 00010 namespace GNUMessenger 00011 { 00012 00013 using namespace std; 00014 00024 class Expat 00025 { 00026 public: 00027 00029 class ParseFailure: public Exception 00030 { 00031 public: 00032 ParseFailure(const string& msg): Exception(msg) {} 00033 }; 00034 00035 Expat(); 00036 virtual ~Expat(); 00037 00041 void parse(string data); 00042 00047 void reset(); 00048 00049 static inline string trim_right(const string& source, const string& t = " "); 00050 static inline string trim_left(const string& source, const string& t = " "); 00051 static inline string trim(const string& source, const string& t = " "); 00052 00053 00054 protected: 00058 virtual void recievedTag( XMLNode &n); 00062 virtual void rootTagRecieved(XMLNode &root); 00067 virtual void rootTagEnded(); 00072 virtual void parserError(string errorMsg, int line ); 00073 00074 00075 private: 00076 00077 static void startElement(void *userData, const XML_Char *name, const XML_Char **atts); 00078 static void endElement(void *userData, const XML_Char *name); 00079 static void charData(void *userData, const char *data, int len); 00080 00081 bool rootRecieved; 00082 00083 void init(); 00084 void cleanup(); 00085 00087 vector<XMLNode> newNodes; 00088 00090 stack<XMLNode> fillingNodes; 00091 00092 XML_Parser parser; 00093 XMLNode root; 00094 }; 00095 00096 } // !GNUMessenger 00097 00098 #endif // !GM_WRAP_EXPAT_H

Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by doxygen 1.3.8