xml.h

00001 #ifndef GM_XML_H 00002 #define GM_XML_H 00003 00004 #include <string> 00005 #include <map> 00006 #include <vector> 00007 #include <stack> 00008 00009 #include "gm/gm.h" 00010 #include "gm/wrapexpat.h" 00011 00012 namespace GNUMessenger 00013 { 00014 using namespace std; 00015 00027 class XMLParser: public Expat 00028 { 00029 00030 public: 00031 00033 class ParseFailure: public Exception 00034 { 00035 public: 00036 ParseFailure(const string& msg): Exception(msg) {} 00037 }; 00038 00040 class DiskError: public Exception 00041 { 00042 public: 00043 DiskError(const string& msg): Exception(msg) {} 00044 }; 00045 00047 enum Type { File, String }; 00048 00055 XMLParser(const string &data="",Type type=XMLParser::String); 00056 00060 XMLParser(XMLNode &root); 00061 00062 ~XMLParser(); 00063 00069 int tree_to_xml(string &line); 00070 00072 int tree_to_file(const string &filename); 00073 00082 vector<XMLNode> get_tags(const string &key); 00083 00087 XMLNode &get_root() { return root;} 00088 00089 int lock(const string &fname); 00090 int release(const string &fname); 00091 int bad() { return status;} 00092 int good() { return status == 0;} 00093 00094 static int printTag(const XMLNode &node, string &ret,int indent=0); 00095 int getParsed() const { return 0; } 00096 00097 static string escape(string str); 00098 00099 00100 protected: 00101 00102 virtual void recievedTag(XMLNode &n); 00103 virtual void rootTagRecieved(XMLNode &n); 00104 virtual void parserError(const string& errorMsg, int line); 00105 00106 private: 00107 00108 void init(const string &line, Type type); 00109 00110 XMLNode root; 00111 int status; 00112 }; 00113 00114 } // !GNUMessenger 00115 00116 #endif // !GM_XML_H

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