VVSDK  1.0
The VVAmbisonic Library
XMLParser.h
Go to the documentation of this file.
1 #ifndef XMLPARSER_H_INCLUDED
2 #define XMLPARSER_H_INCLUDED
3 
4 #include <string>
5 #include <vector>
6 
7 using namespace std;
8 
11 class CXMLException : public exception
12 {
13 };
14 
18 {
19 public:
20  int getLength();
21  string getName(int);
22  string getType(int);
23  string getType(string);
24  string getValue(int);
25  string getValue(string);
26 };
27 
28 class CXMLElement;
29 
30 #pragma warning(disable:4786)
31 using namespace std ;
32 typedef vector<CXMLElement *> CXMLElementList;
33 
38 {
39 public:
40  CXMLElement();
41  CXMLElement(string strTagName);
42  ~CXMLElement();
43  string GetTagName();
44  CXMLElement *AddChild(CXMLElement *pNewElement);
45  CXMLElement *AddChild(string strTagName);
46  CXMLElement *AddChild(string strTagName, string strText);
47  CXMLElement *AddChild(string strTagName, int n);
48  CXMLElement *AddChild(string strTagName, long n);
49  CXMLElement *AddChild(string strTagName, float x);
50  CXMLElement *AddChild(string strTagName, float x, string fmt);
51  CXMLElement *AddChild(string strTagName, double x);
52  CXMLElement *AddChild(string strTagName, bool b);
53  void RemoveChild(long ndx);
54  CXMLElement *GetChild(string strKey, long ndx = 0);
55  CXMLElement *GetChild(long ndx);
56  long GetChildCount();
57  long GetChildCount(string str);
59  string GetValue();
60  int GetIntValue();
61  long GetLongValue();
62  float GetFloatValue();
63  double GetDblValue();
64  bool GetBoolValue();
66  string GetChildValue(string childName, string defaultValue);
67  int GetChildIntValue(string childName, int defaultValue);
68  long GetChildLongValue(string childName, long defaultValue);
69  float GetChildFloatValue(string childName, float defaultValue);
70  double GetChildDblValue(string childName, double defaultValue);
71  bool GetChildBoolValue(string childName, bool defaultValue);
73  string GetXML();
75 public:
76  string GetStrValue();
80  string m_strTagName;
81  string m_strText; // PCData
82 };
83 
88 {
89 public:
92  void characters(const string&, int, int);
93  void endDocument();
94  void endElement(const string& strTagName);
95  void startDocument();
96  void startElement(const string& strTagName);
97  void startElement(const string& strTagName, CXAttributeList);
101 private:
102  CXMLElement *m_pCurElement;
103 };
104 
109 {
110 public:
111  CXMLParser();
112  void parse (string str);
113  void setDocumentHandler(CXDocumentHandler *handler);
117 private:
118  void DoTagClose(string strTagName, char chLastCh,
119  string& strPCData);
120 };
121 
126 {
127 public:
128  CXMLArchive();
129  CXMLArchive(string strRootTagName);
132  CXMLElement* Parse(string);
133  CXMLElement* GetRoot();
134  CXMLElement* SetRoot(CXMLElement*);
135  string Dump();
137 private:
138  CXMLParser xmlParser;
139  CXDocumentHandler xmlDocHandler;
140 };
141 
142 #endif
Definition: XMLParser.h:125
Definition: XMLParser.h:37
Definition: XMLParser.h:11
string m_strTagName
Definition: XMLParser.h:80
CXAttributeList * m_pattList
Definition: XMLParser.h:79
vector< CXMLElement * > CXMLElementList
Definition: XMLParser.h:32
Definition: XMLParser.h:108
string m_strText
Definition: XMLParser.h:81
CXDocumentHandler * m_pDocHandler
Definition: XMLParser.h:115
CXMLElement * m_pRootElement
Definition: XMLParser.h:99
Definition: XMLParser.h:87
Definition: XMLParser.h:17
CXMLElementList m_vChildren
Definition: XMLParser.h:77
CXMLElement * m_pParentElement
Definition: XMLParser.h:78