diff options
Diffstat (limited to 'linden/indra/llxml/llxmlnode.h')
-rw-r--r-- | linden/indra/llxml/llxmlnode.h | 107 |
1 files changed, 61 insertions, 46 deletions
diff --git a/linden/indra/llxml/llxmlnode.h b/linden/indra/llxml/llxmlnode.h index 269108c..ed170f6 100644 --- a/linden/indra/llxml/llxmlnode.h +++ b/linden/indra/llxml/llxmlnode.h | |||
@@ -49,6 +49,13 @@ | |||
49 | #include "llstringtable.h" | 49 | #include "llstringtable.h" |
50 | 50 | ||
51 | 51 | ||
52 | class LLVector3; | ||
53 | class LLVector3d; | ||
54 | class LLQuaternion; | ||
55 | class LLUUID; | ||
56 | class LLColor4; | ||
57 | class LLColor4U; | ||
58 | |||
52 | 59 | ||
53 | struct CompareAttributes | 60 | struct CompareAttributes |
54 | { | 61 | { |
@@ -68,10 +75,18 @@ struct CompareAttributes | |||
68 | 75 | ||
69 | class LLXMLNode; | 76 | class LLXMLNode; |
70 | typedef LLPointer<LLXMLNode> LLXMLNodePtr; | 77 | typedef LLPointer<LLXMLNode> LLXMLNodePtr; |
71 | typedef std::multimap<LLString, LLXMLNodePtr > LLXMLNodeList; | 78 | typedef std::multimap<std::string, LLXMLNodePtr > LLXMLNodeList; |
72 | typedef std::multimap<const LLStringTableEntry *, LLXMLNodePtr > LLXMLChildList; | 79 | typedef std::multimap<const LLStringTableEntry *, LLXMLNodePtr > LLXMLChildList; |
73 | typedef std::map<const LLStringTableEntry *, LLXMLNodePtr, CompareAttributes> LLXMLAttribList; | 80 | typedef std::map<const LLStringTableEntry *, LLXMLNodePtr, CompareAttributes> LLXMLAttribList; |
74 | 81 | ||
82 | class LLColor4; | ||
83 | class LLColor4U; | ||
84 | class LLQuaternion; | ||
85 | class LLVector3; | ||
86 | class LLVector3d; | ||
87 | class LLVector4; | ||
88 | class LLVector4U; | ||
89 | |||
75 | struct LLXMLChildren | 90 | struct LLXMLChildren |
76 | { | 91 | { |
77 | LLXMLChildList map; // Map of children names->pointers | 92 | LLXMLChildList map; // Map of children names->pointers |
@@ -107,7 +122,7 @@ protected: | |||
107 | 122 | ||
108 | public: | 123 | public: |
109 | LLXMLNode(); | 124 | LLXMLNode(); |
110 | LLXMLNode(const LLString& name, BOOL is_attribute); | 125 | LLXMLNode(const char* name, BOOL is_attribute); |
111 | LLXMLNode(LLStringTableEntry* name, BOOL is_attribute); | 126 | LLXMLNode(LLStringTableEntry* name, BOOL is_attribute); |
112 | 127 | ||
113 | BOOL isNull(); | 128 | BOOL isNull(); |
@@ -118,7 +133,7 @@ public: | |||
118 | 133 | ||
119 | // Serialization | 134 | // Serialization |
120 | static bool parseFile( | 135 | static bool parseFile( |
121 | LLString filename, | 136 | const std::string& filename, |
122 | LLXMLNodePtr& node, | 137 | LLXMLNodePtr& node, |
123 | LLXMLNode* defaults_tree); | 138 | LLXMLNode* defaults_tree); |
124 | static bool parseBuffer( | 139 | static bool parseBuffer( |
@@ -134,16 +149,16 @@ public: | |||
134 | LLXMLNodePtr& node, | 149 | LLXMLNodePtr& node, |
135 | LLXMLNodePtr& update_node); | 150 | LLXMLNodePtr& update_node); |
136 | static void writeHeaderToFile(LLFILE *fOut); | 151 | static void writeHeaderToFile(LLFILE *fOut); |
137 | void writeToFile(LLFILE *fOut, LLString indent = LLString()); | 152 | void writeToFile(LLFILE *fOut, const std::string& indent = std::string()); |
138 | void writeToOstream(std::ostream& output_stream, const LLString& indent = LLString()); | 153 | void writeToOstream(std::ostream& output_stream, const std::string& indent = std::string()); |
139 | 154 | ||
140 | // Utility | 155 | // Utility |
141 | void findName(const LLString& name, LLXMLNodeList &results); | 156 | void findName(const std::string& name, LLXMLNodeList &results); |
142 | void findName(LLStringTableEntry* name, LLXMLNodeList &results); | 157 | void findName(LLStringTableEntry* name, LLXMLNodeList &results); |
143 | void findID(const LLString& id, LLXMLNodeList &results); | 158 | void findID(const std::string& id, LLXMLNodeList &results); |
144 | 159 | ||
145 | 160 | ||
146 | virtual LLXMLNodePtr createChild(const LLString& name, BOOL is_attribute); | 161 | virtual LLXMLNodePtr createChild(const char* name, BOOL is_attribute); |
147 | virtual LLXMLNodePtr createChild(LLStringTableEntry* name, BOOL is_attribute); | 162 | virtual LLXMLNodePtr createChild(LLStringTableEntry* name, BOOL is_attribute); |
148 | 163 | ||
149 | 164 | ||
@@ -155,49 +170,49 @@ public: | |||
155 | U32 getLongValue(U32 expected_length, U64 *array, Encoding encoding = ENCODING_DEFAULT); | 170 | U32 getLongValue(U32 expected_length, U64 *array, Encoding encoding = ENCODING_DEFAULT); |
156 | U32 getFloatValue(U32 expected_length, F32 *array, Encoding encoding = ENCODING_DEFAULT); | 171 | U32 getFloatValue(U32 expected_length, F32 *array, Encoding encoding = ENCODING_DEFAULT); |
157 | U32 getDoubleValue(U32 expected_length, F64 *array, Encoding encoding = ENCODING_DEFAULT); | 172 | U32 getDoubleValue(U32 expected_length, F64 *array, Encoding encoding = ENCODING_DEFAULT); |
158 | U32 getStringValue(U32 expected_length, LLString *array); | 173 | U32 getStringValue(U32 expected_length, std::string *array); |
159 | U32 getUUIDValue(U32 expected_length, LLUUID *array); | 174 | U32 getUUIDValue(U32 expected_length, LLUUID *array); |
160 | U32 getNodeRefValue(U32 expected_length, LLXMLNode **array); | 175 | U32 getNodeRefValue(U32 expected_length, LLXMLNode **array); |
161 | 176 | ||
162 | BOOL hasAttribute(const LLString& name ); | 177 | BOOL hasAttribute(const char* name ); |
163 | 178 | ||
164 | BOOL getAttributeBOOL(const LLString& name, BOOL& value ); | 179 | BOOL getAttributeBOOL(const char* name, BOOL& value ); |
165 | BOOL getAttributeU8(const LLString& name, U8& value ); | 180 | BOOL getAttributeU8(const char* name, U8& value ); |
166 | BOOL getAttributeS8(const LLString& name, S8& value ); | 181 | BOOL getAttributeS8(const char* name, S8& value ); |
167 | BOOL getAttributeU16(const LLString& name, U16& value ); | 182 | BOOL getAttributeU16(const char* name, U16& value ); |
168 | BOOL getAttributeS16(const LLString& name, S16& value ); | 183 | BOOL getAttributeS16(const char* name, S16& value ); |
169 | BOOL getAttributeU32(const LLString& name, U32& value ); | 184 | BOOL getAttributeU32(const char* name, U32& value ); |
170 | BOOL getAttributeS32(const LLString& name, S32& value ); | 185 | BOOL getAttributeS32(const char* name, S32& value ); |
171 | BOOL getAttributeF32(const LLString& name, F32& value ); | 186 | BOOL getAttributeF32(const char* name, F32& value ); |
172 | BOOL getAttributeF64(const LLString& name, F64& value ); | 187 | BOOL getAttributeF64(const char* name, F64& value ); |
173 | BOOL getAttributeColor(const LLString& name, LLColor4& value ); | 188 | BOOL getAttributeColor(const char* name, LLColor4& value ); |
174 | BOOL getAttributeColor4(const LLString& name, LLColor4& value ); | 189 | BOOL getAttributeColor4(const char* name, LLColor4& value ); |
175 | BOOL getAttributeColor4U(const LLString& name, LLColor4U& value ); | 190 | BOOL getAttributeColor4U(const char* name, LLColor4U& value ); |
176 | BOOL getAttributeVector3(const LLString& name, LLVector3& value ); | 191 | BOOL getAttributeVector3(const char* name, LLVector3& value ); |
177 | BOOL getAttributeVector3d(const LLString& name, LLVector3d& value ); | 192 | BOOL getAttributeVector3d(const char* name, LLVector3d& value ); |
178 | BOOL getAttributeQuat(const LLString& name, LLQuaternion& value ); | 193 | BOOL getAttributeQuat(const char* name, LLQuaternion& value ); |
179 | BOOL getAttributeUUID(const LLString& name, LLUUID& value ); | 194 | BOOL getAttributeUUID(const char* name, LLUUID& value ); |
180 | BOOL getAttributeString(const LLString& name, LLString& value ); | 195 | BOOL getAttributeString(const char* name, std::string& value ); |
181 | 196 | ||
182 | const ValueType& getType() const { return mType; } | 197 | const ValueType& getType() const { return mType; } |
183 | U32 getLength() const { return mLength; } | 198 | U32 getLength() const { return mLength; } |
184 | U32 getPrecision() const { return mPrecision; } | 199 | U32 getPrecision() const { return mPrecision; } |
185 | const LLString& getValue() const { return mValue; } | 200 | const std::string& getValue() const { return mValue; } |
186 | LLString getTextContents() const; | 201 | std::string getTextContents() const; |
187 | const LLStringTableEntry* getName() const { return mName; } | 202 | const LLStringTableEntry* getName() const { return mName; } |
188 | BOOL hasName(const char* name) const { return mName == gStringTable.checkStringEntry(name); } | 203 | BOOL hasName(const char* name) const { return mName == gStringTable.checkStringEntry(name); } |
189 | BOOL hasName(LLString name) const { return mName == gStringTable.checkStringEntry(name.c_str()); } | 204 | BOOL hasName(const std::string& name) const { return mName == gStringTable.checkStringEntry(name.c_str()); } |
190 | const LLString& getID() const { return mID; } | 205 | const std::string& getID() const { return mID; } |
191 | 206 | ||
192 | U32 getChildCount() const; | 207 | U32 getChildCount() const; |
193 | // getChild returns a Null LLXMLNode (not a NULL pointer) if there is no such child. | 208 | // getChild returns a Null LLXMLNode (not a NULL pointer) if there is no such child. |
194 | // This child has no value so any getTYPEValue() calls on it will return 0. | 209 | // This child has no value so any getTYPEValue() calls on it will return 0. |
195 | bool getChild(const LLString& name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); | 210 | bool getChild(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); |
196 | bool getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); | 211 | bool getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); |
197 | void getChildren(const LLString& name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const; | 212 | void getChildren(const char* name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const; |
198 | void getChildren(const LLStringTableEntry* name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const; | 213 | void getChildren(const LLStringTableEntry* name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const; |
199 | 214 | ||
200 | bool getAttribute(const LLString& name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); | 215 | bool getAttribute(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); |
201 | bool getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); | 216 | bool getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE); |
202 | 217 | ||
203 | // The following skip over attributes | 218 | // The following skip over attributes |
@@ -208,7 +223,7 @@ public: | |||
208 | 223 | ||
209 | // Setters | 224 | // Setters |
210 | 225 | ||
211 | bool setAttributeString(const LLString& attr, const LLString& value); | 226 | bool setAttributeString(const char* attr, const std::string& value); |
212 | 227 | ||
213 | void setBoolValue(const BOOL value) { setBoolValue(1, &value); } | 228 | void setBoolValue(const BOOL value) { setBoolValue(1, &value); } |
214 | void setByteValue(const U8 value, Encoding encoding = ENCODING_DEFAULT) { setByteValue(1, &value, encoding); } | 229 | void setByteValue(const U8 value, Encoding encoding = ENCODING_DEFAULT) { setByteValue(1, &value, encoding); } |
@@ -217,7 +232,7 @@ public: | |||
217 | void setLongValue(const U64 value, Encoding encoding = ENCODING_DEFAULT) { setLongValue(1, &value, encoding); } | 232 | void setLongValue(const U64 value, Encoding encoding = ENCODING_DEFAULT) { setLongValue(1, &value, encoding); } |
218 | void setFloatValue(const F32 value, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0) { setFloatValue(1, &value, encoding); } | 233 | void setFloatValue(const F32 value, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0) { setFloatValue(1, &value, encoding); } |
219 | void setDoubleValue(const F64 value, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0) { setDoubleValue(1, &value, encoding); } | 234 | void setDoubleValue(const F64 value, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0) { setDoubleValue(1, &value, encoding); } |
220 | void setStringValue(const LLString value) { setStringValue(1, &value); } | 235 | void setStringValue(const std::string& value) { setStringValue(1, &value); } |
221 | void setUUIDValue(const LLUUID value) { setUUIDValue(1, &value); } | 236 | void setUUIDValue(const LLUUID value) { setUUIDValue(1, &value); } |
222 | void setNodeRefValue(const LLXMLNode *value) { setNodeRefValue(1, &value); } | 237 | void setNodeRefValue(const LLXMLNode *value) { setNodeRefValue(1, &value); } |
223 | 238 | ||
@@ -228,16 +243,16 @@ public: | |||
228 | void setLongValue(U32 length, const U64 *array, Encoding encoding = ENCODING_DEFAULT); | 243 | void setLongValue(U32 length, const U64 *array, Encoding encoding = ENCODING_DEFAULT); |
229 | void setFloatValue(U32 length, const F32 *array, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0); | 244 | void setFloatValue(U32 length, const F32 *array, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0); |
230 | void setDoubleValue(U32 length, const F64 *array, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0); | 245 | void setDoubleValue(U32 length, const F64 *array, Encoding encoding = ENCODING_DEFAULT, U32 precision = 0); |
231 | void setStringValue(U32 length, const LLString *array); | 246 | void setStringValue(U32 length, const std::string *array); |
232 | void setUUIDValue(U32 length, const LLUUID *array); | 247 | void setUUIDValue(U32 length, const LLUUID *array); |
233 | void setNodeRefValue(U32 length, const LLXMLNode **array); | 248 | void setNodeRefValue(U32 length, const LLXMLNode **array); |
234 | void setValue(const LLString& value); | 249 | void setValue(const std::string& value); |
235 | void setName(const LLString& name); | 250 | void setName(const std::string& name); |
236 | void setName(LLStringTableEntry* name); | 251 | void setName(LLStringTableEntry* name); |
237 | 252 | ||
238 | // Escapes " (quot) ' (apos) & (amp) < (lt) > (gt) | 253 | // Escapes " (quot) ' (apos) & (amp) < (lt) > (gt) |
239 | // TomY TODO: Make this private | 254 | // TomY TODO: Make this private |
240 | static LLString escapeXML(const LLString& xml); | 255 | static std::string escapeXML(const std::string& xml); |
241 | 256 | ||
242 | // Set the default node corresponding to this default node | 257 | // Set the default node corresponding to this default node |
243 | void setDefault(LLXMLNode *default_node); | 258 | void setDefault(LLXMLNode *default_node); |
@@ -250,20 +265,20 @@ public: | |||
250 | // Delete any child nodes that aren't among the tree's children, recursive | 265 | // Delete any child nodes that aren't among the tree's children, recursive |
251 | void scrubToTree(LLXMLNode *tree); | 266 | void scrubToTree(LLXMLNode *tree); |
252 | 267 | ||
253 | BOOL deleteChildren(const LLString& name); | 268 | BOOL deleteChildren(const std::string& name); |
254 | BOOL deleteChildren(LLStringTableEntry* name); | 269 | BOOL deleteChildren(LLStringTableEntry* name); |
255 | void setAttributes(ValueType type, U32 precision, Encoding encoding, U32 length); | 270 | void setAttributes(ValueType type, U32 precision, Encoding encoding, U32 length); |
256 | void appendValue(const LLString& value); | 271 | // void appendValue(const std::string& value); // Unused |
257 | 272 | ||
258 | // Unit Testing | 273 | // Unit Testing |
259 | void createUnitTest(S32 max_num_children); | 274 | void createUnitTest(S32 max_num_children); |
260 | BOOL performUnitTest(LLString &error_buffer); | 275 | BOOL performUnitTest(std::string &error_buffer); |
261 | 276 | ||
262 | protected: | 277 | protected: |
263 | BOOL removeChild(LLXMLNode* child); | 278 | BOOL removeChild(LLXMLNode* child); |
264 | 279 | ||
265 | public: | 280 | public: |
266 | LLString mID; // The ID attribute of this node | 281 | std::string mID; // The ID attribute of this node |
267 | 282 | ||
268 | XML_Parser *mParser; // Temporary pointer while loading | 283 | XML_Parser *mParser; // Temporary pointer while loading |
269 | 284 | ||
@@ -286,7 +301,7 @@ public: | |||
286 | 301 | ||
287 | protected: | 302 | protected: |
288 | LLStringTableEntry *mName; // The name of this node | 303 | LLStringTableEntry *mName; // The name of this node |
289 | LLString mValue; // The value of this node (use getters/setters only) | 304 | std::string mValue; // The value of this node (use getters/setters only) |
290 | 305 | ||
291 | LLXMLNodePtr mDefault; // Mirror node in the default tree | 306 | LLXMLNodePtr mDefault; // Mirror node in the default tree |
292 | 307 | ||