diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-05-09 15:04:31 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-05-09 15:04:31 +0000 |
commit | ad92dc50b7cdf7cfe086f21d19442d03a90fd05d (patch) | |
tree | 9ca6f7bde704cb44276a05b6e83f36754e07f732 /src/xmldocument.h | |
parent | 2e035fee36768e3c765b7f5dc10bf0a3b7d2448b (diff) | |
download | libbu++-ad92dc50b7cdf7cfe086f21d19442d03a90fd05d.tar.gz libbu++-ad92dc50b7cdf7cfe086f21d19442d03a90fd05d.tar.bz2 libbu++-ad92dc50b7cdf7cfe086f21d19442d03a90fd05d.tar.xz libbu++-ad92dc50b7cdf7cfe086f21d19442d03a90fd05d.zip |
Just a few things re-arranged, moved the new taf/xml systems to the inprogress
directory, and moved the old xml system in, so it will require heavy changes.
Diffstat (limited to 'src/xmldocument.h')
-rw-r--r-- | src/xmldocument.h | 175 |
1 files changed, 162 insertions, 13 deletions
diff --git a/src/xmldocument.h b/src/xmldocument.h index e16e3ea..6671c41 100644 --- a/src/xmldocument.h +++ b/src/xmldocument.h | |||
@@ -1,22 +1,171 @@ | |||
1 | #ifndef XML_DOCUMENT_H | 1 | #ifndef XMLDOCUMENT |
2 | #define XML_DOCUMENT_H | 2 | #define XMLDOCUMENT |
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include "xmlnode.h" |
5 | 5 | ||
6 | namespace Bu | 6 | /** |
7 | * Keeps track of an easily managed set of XmlNode information. Allows simple | ||
8 | * operations for logical writing to and reading from XML structures. Using | ||
9 | * already formed structures is simply done through the XmlNode structures, | ||
10 | * and the getRoot function here. Creation is performed through a simple set | ||
11 | * of operations that creates the data in a stream type format. | ||
12 | *@author Mike Buland | ||
13 | */ | ||
14 | class XmlDocument | ||
7 | { | 15 | { |
16 | public: | ||
8 | /** | 17 | /** |
9 | * | 18 | * Construct either a blank XmlDocuemnt or construct a document around an |
19 | * existing XmlNode. Be careful, once an XmlNode is passed into a document | ||
20 | * the document takes over ownership and will delete it when the XmlDocument | ||
21 | * is deleted. | ||
22 | *@param pRoot The XmlNode to use as the root of this document, or NULL if | ||
23 | * you want to start a new document. | ||
10 | */ | 24 | */ |
11 | class XmlDocument | 25 | XmlDocument( XmlNode *pRoot=NULL ); |
12 | { | ||
13 | public: | ||
14 | XmlDocument(); | ||
15 | virtual ~XmlDocument(); | ||
16 | 26 | ||
17 | private: | 27 | /** |
28 | * Destroy all contained nodes. | ||
29 | */ | ||
30 | virtual ~XmlDocument(); | ||
31 | |||
32 | /** | ||
33 | * Add a new node to the document. The new node is appended to the end of | ||
34 | * the current context, i.e. XmlNode, and the new node, provided it isn't | ||
35 | * close as part of this operation, will become the current context. | ||
36 | *@param sName The name of the new node to add. | ||
37 | *@param sContent A content string to be placed inside of the new node. | ||
38 | *@param bClose Set this to true to close the node immediately after adding | ||
39 | * the node and setting the content and name. If this is set to true the | ||
40 | * node is appended, but the context node doesn't change. | ||
41 | */ | ||
42 | void addNode( const char *sName=NULL, const char *sContent=NULL, bool bClose=false ); | ||
43 | |||
44 | /** | ||
45 | * Set the name of the current node context. | ||
46 | *@param sName The new name of the node. | ||
47 | */ | ||
48 | void setName( const char *sName ); | ||
49 | |||
50 | /** | ||
51 | * Close the current node context. This will move the current context to | ||
52 | * the parent node of the former current node. If the current node was the | ||
53 | * root then the "completed" flag is set and no more operations are allowed. | ||
54 | */ | ||
55 | void closeNode(); | ||
56 | |||
57 | /** | ||
58 | * Change the content of the current node at the current position between | ||
59 | * nodes. | ||
60 | *@param sContent The new content of the current node. | ||
61 | */ | ||
62 | void setContent( const char *sContent ); | ||
63 | |||
64 | /** | ||
65 | * Add a named property to the current context node. | ||
66 | *@param sName The name of the property to add. | ||
67 | *@param sValue The string value of the property. | ||
68 | */ | ||
69 | void addProperty( const char *sName, const char *sValue ); | ||
70 | |||
71 | /** | ||
72 | * Add a named property to the current context node, converting the | ||
73 | * numerical parameter to text using standrd printf style conversion. | ||
74 | *@param sName The name of the property to add. | ||
75 | *@param nValue The numerical value to add. | ||
76 | */ | ||
77 | void addProperty( const char *sName, const unsigned char nValue ); | ||
78 | |||
79 | /** | ||
80 | * Add a named property to the current context node, converting the | ||
81 | * numerical parameter to text using standrd printf style conversion. | ||
82 | *@param sName The name of the property to add. | ||
83 | *@param nValue The numerical value to add. | ||
84 | */ | ||
85 | void addProperty( const char *sName, const char nValue ); | ||
86 | |||
87 | /** | ||
88 | * Add a named property to the current context node, converting the | ||
89 | * numerical parameter to text using standrd printf style conversion. | ||
90 | *@param sName The name of the property to add. | ||
91 | *@param nValue The numerical value to add. | ||
92 | */ | ||
93 | void addProperty( const char *sName, const unsigned short nValue ); | ||
94 | |||
95 | /** | ||
96 | * Add a named property to the current context node, converting the | ||
97 | * numerical parameter to text using standrd printf style conversion. | ||
98 | *@param sName The name of the property to add. | ||
99 | *@param nValue The numerical value to add. | ||
100 | */ | ||
101 | void addProperty( const char *sName, const short nValue ); | ||
102 | |||
103 | /** | ||
104 | * Add a named property to the current context node, converting the | ||
105 | * numerical parameter to text using standrd printf style conversion. | ||
106 | *@param sName The name of the property to add. | ||
107 | *@param nValue The numerical value to add. | ||
108 | */ | ||
109 | void addProperty( const char *sName, const unsigned long nValue ); | ||
110 | |||
111 | /** | ||
112 | * Add a named property to the current context node, converting the | ||
113 | * numerical parameter to text using standrd printf style conversion. | ||
114 | *@param sName The name of the property to add. | ||
115 | *@param nValue The numerical value to add. | ||
116 | */ | ||
117 | void addProperty( const char *sName, const long nValue ); | ||
118 | |||
119 | /** | ||
120 | * Add a named property to the current context node, converting the | ||
121 | * numerical parameter to text using standrd printf style conversion. | ||
122 | *@param sName The name of the property to add. | ||
123 | *@param nValue The numerical value to add. | ||
124 | */ | ||
125 | void addProperty( const char *sName, const int nValue ); | ||
126 | |||
127 | /** | ||
128 | * Add a named property to the current context node, converting the | ||
129 | * numerical parameter to text using standrd printf style conversion. | ||
130 | *@param sName The name of the property to add. | ||
131 | *@param dValue The numerical value to add. | ||
132 | */ | ||
133 | void addProperty( const char *sName, const double dValue ); | ||
134 | |||
135 | /** | ||
136 | * The XmlDocuemnt is considered completed if the root node has been closed. | ||
137 | * Once an XmlDocument has been completed, you can no longer perform | ||
138 | * operations on it. | ||
139 | *@return True if completed, false if still in progress. | ||
140 | */ | ||
141 | bool isCompleted(); | ||
142 | |||
143 | /** | ||
144 | * Get a pointer to the root object of this XmlDocument. | ||
145 | *@returns A pointer to an internally owned XmlNode. Do not delete this | ||
146 | * XmlNode. | ||
147 | */ | ||
148 | XmlNode *getRoot(); | ||
149 | |||
150 | /** | ||
151 | * Get a pointer to the root object of this XmlDocument, and remove the | ||
152 | * ownership from this object. | ||
153 | *@returns A pointer to an internally owned XmlNode. Do not delete this | ||
154 | * XmlNode. | ||
155 | */ | ||
156 | XmlNode *detatchRoot(); | ||
157 | |||
158 | /** | ||
159 | * Get the current context node, which could be the same as the root node. | ||
160 | *@returns A pointer to an internally owned XmlNode. Do not delete this | ||
161 | * XmlNode. | ||
162 | */ | ||
163 | XmlNode *getCurrent(); | ||
18 | 164 | ||
19 | }; | 165 | private: |
20 | } | 166 | XmlNode *pRoot; /**< The root node. */ |
167 | XmlNode *pCurrent; /**< The current node. */ | ||
168 | bool bCompleted; /**< Is it completed? */ | ||
169 | }; | ||
21 | 170 | ||
22 | #endif | 171 | #endif |