Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

Xml.h

00001 /*
00002  * XML Parser/Generator
00003  * Simple XML parser/generator sufficient to
00004  * send+receive the XML in ICQ SMS messages
00005  *
00006  * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>.
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00021  *
00022  */
00023 
00024 #ifndef XML_H
00025 #define XML_H
00026 
00027 #include <string>
00028 #include <list>
00029 #include <ctype.h>
00030 
00031 using std::string;
00032 using std::list;
00033 
00034 class XmlNode {
00035  private:
00036   static string parseTag(string::iterator& curr, string::iterator end);
00037   static void skipWS(string::iterator& curr, string::iterator end);
00038 
00039  protected:
00040   string tag;
00041   
00042   XmlNode(const string& t);
00043 
00044  public:
00045   virtual ~XmlNode();
00046 
00047   virtual bool isBranch() = 0;
00048   bool isLeaf();
00049 
00050   string getTag();
00051 
00052   static XmlNode *parse(string::iterator& start, string::iterator end);
00053 
00054   static string quote(const string& s);
00055   static string unquote(const string& s);
00056   static string replace_all(const string& s, const string& r1, const string& r2);
00057 
00058   virtual string toString(int n) = 0;
00059 };
00060 
00061 class XmlLeaf;
00062 
00063 class XmlBranch : public XmlNode {
00064  private:
00065   list<XmlNode*> children;
00066 
00067  public:
00068   XmlBranch(const string& t);
00069   ~XmlBranch();
00070 
00071   bool isBranch();
00072   bool exists(const string& tag);
00073   XmlNode *getNode(const string& tag);
00074   XmlBranch *getBranch(const string& tag);
00075   XmlLeaf *getLeaf(const string& tag);
00076 
00077   void pushnode(XmlNode *c);
00078 
00079   string toString(int n);
00080 
00081 };
00082 
00083 class XmlLeaf : public XmlNode {
00084  private:
00085   string value;
00086  public:
00087   XmlLeaf(const string& t, const string& v);
00088   ~XmlLeaf();
00089 
00090   bool isBranch();
00091   string getValue();
00092 
00093   string toString(int n);
00094 
00095 };
00096 
00097 #endif
00098 

Generated on Tue Jan 15 12:24:36 2002 for libicq2000 by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001