diff options
author | McCabe Maxsted | 2010-07-07 11:40:20 -0700 |
---|---|---|
committer | McCabe Maxsted | 2010-07-07 11:40:20 -0700 |
commit | 35eaded540f31378845b7a88e212a86a68825040 (patch) | |
tree | 05a91e33fe0de6afa555afa2c350b889e770bbcb /linden/indra/llxml | |
parent | Cleaned up the grid manager layout some (diff) | |
download | meta-impy-35eaded540f31378845b7a88e212a86a68825040.zip meta-impy-35eaded540f31378845b7a88e212a86a68825040.tar.gz meta-impy-35eaded540f31378845b7a88e212a86a68825040.tar.bz2 meta-impy-35eaded540f31378845b7a88e212a86a68825040.tar.xz |
Updated hipporestrequest code to hippo 0.6.3
Diffstat (limited to 'linden/indra/llxml')
-rw-r--r-- | linden/indra/llxml/llxmlnode.cpp | 8 | ||||
-rw-r--r-- | linden/indra/llxml/llxmlnode.h | 4 | ||||
-rw-r--r-- | linden/indra/llxml/llxmlparser.cpp | 2 | ||||
-rw-r--r-- | linden/indra/llxml/llxmlparser.h | 2 | ||||
-rw-r--r-- | linden/indra/llxml/llxmltree.cpp | 119 | ||||
-rw-r--r-- | linden/indra/llxml/llxmltree.h | 19 |
6 files changed, 143 insertions, 11 deletions
diff --git a/linden/indra/llxml/llxmlnode.cpp b/linden/indra/llxml/llxmlnode.cpp index 800b135..5bb5012 100644 --- a/linden/indra/llxml/llxmlnode.cpp +++ b/linden/indra/llxml/llxmlnode.cpp | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2005&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2005&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2005-2009, Linden Research, Inc. | 8 | * Copyright (c) 2005-2010, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 11 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -677,7 +677,7 @@ bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXML | |||
677 | U32 length = ftell(fp); | 677 | U32 length = ftell(fp); |
678 | fseek(fp, 0, SEEK_SET); | 678 | fseek(fp, 0, SEEK_SET); |
679 | 679 | ||
680 | U8* buffer = new U8[length+1]; | 680 | char *buffer = new char[length+1]; |
681 | size_t nread = fread(buffer, 1, length, fp); | 681 | size_t nread = fread(buffer, 1, length, fp); |
682 | buffer[nread] = 0; | 682 | buffer[nread] = 0; |
683 | fclose(fp); | 683 | fclose(fp); |
@@ -689,7 +689,7 @@ bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXML | |||
689 | 689 | ||
690 | // static | 690 | // static |
691 | bool LLXMLNode::parseBuffer( | 691 | bool LLXMLNode::parseBuffer( |
692 | U8* buffer, | 692 | const char *buffer, |
693 | U32 length, | 693 | U32 length, |
694 | LLXMLNodePtr& node, | 694 | LLXMLNodePtr& node, |
695 | LLXMLNode* defaults) | 695 | LLXMLNode* defaults) |
@@ -708,7 +708,7 @@ bool LLXMLNode::parseBuffer( | |||
708 | XML_SetUserData(my_parser, (void *)file_node_ptr); | 708 | XML_SetUserData(my_parser, (void *)file_node_ptr); |
709 | 709 | ||
710 | // Do the parsing | 710 | // Do the parsing |
711 | if (XML_Parse(my_parser, (const char *)buffer, length, TRUE) != XML_STATUS_OK) | 711 | if (XML_Parse(my_parser, buffer, length, TRUE) != XML_STATUS_OK) |
712 | { | 712 | { |
713 | llwarns << "Error parsing xml error code: " | 713 | llwarns << "Error parsing xml error code: " |
714 | << XML_ErrorString(XML_GetErrorCode(my_parser)) | 714 | << XML_ErrorString(XML_GetErrorCode(my_parser)) |
diff --git a/linden/indra/llxml/llxmlnode.h b/linden/indra/llxml/llxmlnode.h index d4e127b..ab1a772 100644 --- a/linden/indra/llxml/llxmlnode.h +++ b/linden/indra/llxml/llxmlnode.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2000&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2000&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2000-2009, Linden Research, Inc. | 7 | * Copyright (c) 2000-2010, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -141,7 +141,7 @@ public: | |||
141 | LLXMLNodePtr& node, | 141 | LLXMLNodePtr& node, |
142 | LLXMLNode* defaults_tree); | 142 | LLXMLNode* defaults_tree); |
143 | static bool parseBuffer( | 143 | static bool parseBuffer( |
144 | U8* buffer, | 144 | const char *buffer, |
145 | U32 length, | 145 | U32 length, |
146 | LLXMLNodePtr& node, | 146 | LLXMLNodePtr& node, |
147 | LLXMLNode* defaults); | 147 | LLXMLNode* defaults); |
diff --git a/linden/indra/llxml/llxmlparser.cpp b/linden/indra/llxml/llxmlparser.cpp index 7d887f4..7304730 100644 --- a/linden/indra/llxml/llxmlparser.cpp +++ b/linden/indra/llxml/llxmlparser.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2002-2009, Linden Research, Inc. | 7 | * Copyright (c) 2002-2010, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llxml/llxmlparser.h b/linden/indra/llxml/llxmlparser.h index d7595f6..9e7d256 100644 --- a/linden/indra/llxml/llxmlparser.h +++ b/linden/indra/llxml/llxmlparser.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2002-2009, Linden Research, Inc. | 7 | * Copyright (c) 2002-2010, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
diff --git a/linden/indra/llxml/llxmltree.cpp b/linden/indra/llxml/llxmltree.cpp index 1bce5d2..aa34f79 100644 --- a/linden/indra/llxml/llxmltree.cpp +++ b/linden/indra/llxml/llxmltree.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2002-2009, Linden Research, Inc. | 7 | * Copyright (c) 2002-2010, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -50,6 +50,7 @@ LLStdStringTable LLXmlTree::sAttributeKeys(1024); | |||
50 | 50 | ||
51 | LLXmlTree::LLXmlTree() | 51 | LLXmlTree::LLXmlTree() |
52 | : mRoot( NULL ), | 52 | : mRoot( NULL ), |
53 | mParser(0), | ||
53 | mNodeNames(512) | 54 | mNodeNames(512) |
54 | { | 55 | { |
55 | } | 56 | } |
@@ -83,6 +84,39 @@ BOOL LLXmlTree::parseFile(const std::string &path, BOOL keep_contents) | |||
83 | return success; | 84 | return success; |
84 | } | 85 | } |
85 | 86 | ||
87 | bool LLXmlTree::parseBufferStart(bool keep_contents) | ||
88 | { | ||
89 | if (mRoot) delete mRoot; | ||
90 | mRoot = NULL; | ||
91 | |||
92 | if (mParser) delete mParser; | ||
93 | mParser = new LLXmlTreeParser(this); | ||
94 | mParser->parseBufferStart(keep_contents); | ||
95 | return (mParser != 0); | ||
96 | } | ||
97 | |||
98 | bool LLXmlTree::parseBuffer(const char *buf, int len) | ||
99 | { | ||
100 | bool success = mParser->parseBuffer(buf, len); | ||
101 | if (!success) { | ||
102 | S32 line_number = mParser->getCurrentLineNumber(); | ||
103 | const char* error = mParser->getErrorString(); | ||
104 | llwarns << "LLXmlTree parse failed in line " << line_number << ": " << error << llendl; | ||
105 | delete mParser; | ||
106 | mParser = 0; | ||
107 | } | ||
108 | return success; | ||
109 | } | ||
110 | |||
111 | bool LLXmlTree::parseBufferFinalize() | ||
112 | { | ||
113 | bool success = mParser->parseBufferFinalize(&mRoot); | ||
114 | delete mParser; | ||
115 | mParser = 0; | ||
116 | return success; | ||
117 | } | ||
118 | |||
119 | |||
86 | void LLXmlTree::dump() | 120 | void LLXmlTree::dump() |
87 | { | 121 | { |
88 | if( mRoot ) | 122 | if( mRoot ) |
@@ -102,6 +136,25 @@ void LLXmlTree::dumpNode( LLXmlTreeNode* node, const std::string& prefix ) | |||
102 | } | 136 | } |
103 | } | 137 | } |
104 | 138 | ||
139 | void LLXmlTree::write(std::string &buffer) const | ||
140 | { | ||
141 | if (mRoot) writeNode(mRoot, buffer, ""); | ||
142 | } | ||
143 | |||
144 | void LLXmlTree::writeNode(LLXmlTreeNode *node, std::string &buffer, const std::string &indent) const | ||
145 | { | ||
146 | if (!node->getFirstChild()) { | ||
147 | node->writeNoChild(buffer, indent); | ||
148 | } else { | ||
149 | node->writeStart(buffer, indent); | ||
150 | std::string newIndent = indent + " "; | ||
151 | for (LLXmlTreeNode *child=node->getFirstChild(); child; child=node->getNextChild()) | ||
152 | writeNode(child, buffer, newIndent); | ||
153 | node->writeEnd(buffer, indent); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | |||
105 | ////////////////////////////////////////////////////////////// | 158 | ////////////////////////////////////////////////////////////// |
106 | // LLXmlTreeNode | 159 | // LLXmlTreeNode |
107 | 160 | ||
@@ -139,6 +192,43 @@ void LLXmlTreeNode::dump( const std::string& prefix ) | |||
139 | llcont << llendl; | 192 | llcont << llendl; |
140 | } | 193 | } |
141 | 194 | ||
195 | void LLXmlTreeNode::writeNoChild(std::string &buffer, const std::string &indent) const | ||
196 | { | ||
197 | if (!mContents.empty()) { | ||
198 | writeStart(buffer, indent); | ||
199 | writeEnd(buffer, indent); | ||
200 | } else { | ||
201 | buffer += indent + '<' + mName; | ||
202 | writeAttributes(buffer); | ||
203 | buffer += "/>\n"; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | void LLXmlTreeNode::writeStart(std::string &buffer, const std::string &indent) const | ||
208 | { | ||
209 | buffer += indent + '<' + mName; | ||
210 | writeAttributes(buffer); | ||
211 | buffer += ">\n"; | ||
212 | } | ||
213 | |||
214 | void LLXmlTreeNode::writeEnd(std::string &buffer, const std::string &indent) const | ||
215 | { | ||
216 | if (!mContents.empty()) { | ||
217 | buffer += indent + " " + mContents + '\n'; | ||
218 | } | ||
219 | buffer += indent + "</" + mName + ">\n"; | ||
220 | } | ||
221 | |||
222 | void LLXmlTreeNode::writeAttributes(std::string &buffer) const | ||
223 | { | ||
224 | attribute_map_t::const_iterator it, end = mAttributes.end(); | ||
225 | for (it=mAttributes.begin(); it!=end; ++it) { | ||
226 | LLStdStringHandle key = it->first; | ||
227 | const std::string *value = it->second; | ||
228 | buffer += ' ' + *key + "=\"" + *value + '"'; | ||
229 | } | ||
230 | } | ||
231 | |||
142 | BOOL LLXmlTreeNode::hasAttribute(const std::string& name) | 232 | BOOL LLXmlTreeNode::hasAttribute(const std::string& name) |
143 | { | 233 | { |
144 | LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name ); | 234 | LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name ); |
@@ -527,7 +617,7 @@ BOOL LLXmlTreeParser::parseFile(const std::string &path, LLXmlTreeNode** root, B | |||
527 | 617 | ||
528 | BOOL success = LLXmlParser::parseFile(path); | 618 | BOOL success = LLXmlParser::parseFile(path); |
529 | 619 | ||
530 | *root = mRoot; | 620 | if (root) *root = mRoot; |
531 | mRoot = NULL; | 621 | mRoot = NULL; |
532 | 622 | ||
533 | if( success ) | 623 | if( success ) |
@@ -539,6 +629,31 @@ BOOL LLXmlTreeParser::parseFile(const std::string &path, LLXmlTreeNode** root, B | |||
539 | return success; | 629 | return success; |
540 | } | 630 | } |
541 | 631 | ||
632 | void LLXmlTreeParser::parseBufferStart(BOOL keep_contents) | ||
633 | { | ||
634 | llassert(!mRoot); | ||
635 | llassert(!mCurrent); | ||
636 | mKeepContents = keep_contents; | ||
637 | } | ||
638 | |||
639 | bool LLXmlTreeParser::parseBuffer(const char *buf, int len) | ||
640 | { | ||
641 | return (LLXmlParser::parse(buf, len, false) != 0); | ||
642 | } | ||
643 | |||
644 | bool LLXmlTreeParser::parseBufferFinalize(LLXmlTreeNode** root) | ||
645 | { | ||
646 | bool success = (LLXmlParser::parse(0, 0, true) != 0); | ||
647 | |||
648 | if (root) *root = mRoot; | ||
649 | mRoot = NULL; | ||
650 | |||
651 | llassert(!success || !mCurrent); | ||
652 | mCurrent = NULL; | ||
653 | |||
654 | return success; | ||
655 | } | ||
656 | |||
542 | 657 | ||
543 | const std::string& LLXmlTreeParser::tabs() | 658 | const std::string& LLXmlTreeParser::tabs() |
544 | { | 659 | { |
diff --git a/linden/indra/llxml/llxmltree.h b/linden/indra/llxml/llxmltree.h index 1a020f2..31f89de 100644 --- a/linden/indra/llxml/llxmltree.h +++ b/linden/indra/llxml/llxmltree.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2001-2009, Linden Research, Inc. | 8 | * Copyright (c) 2001-2010, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 11 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -63,11 +63,18 @@ public: | |||
63 | 63 | ||
64 | virtual BOOL parseFile(const std::string &path, BOOL keep_contents = TRUE); | 64 | virtual BOOL parseFile(const std::string &path, BOOL keep_contents = TRUE); |
65 | 65 | ||
66 | bool parseBufferStart(bool keep_contents = true); | ||
67 | bool parseBuffer(const char *buf, int len); | ||
68 | bool parseBufferFinalize(); | ||
69 | |||
66 | LLXmlTreeNode* getRoot() { return mRoot; } | 70 | LLXmlTreeNode* getRoot() { return mRoot; } |
67 | 71 | ||
68 | void dump(); | 72 | void dump(); |
69 | void dumpNode( LLXmlTreeNode* node, const std::string& prefix ); | 73 | void dumpNode( LLXmlTreeNode* node, const std::string& prefix ); |
70 | 74 | ||
75 | void write(std::string &buffer) const; | ||
76 | void writeNode(LLXmlTreeNode *node, std::string &buffer, const std::string &indent) const; | ||
77 | |||
71 | static LLStdStringHandle addAttributeString( const std::string& name) | 78 | static LLStdStringHandle addAttributeString( const std::string& name) |
72 | { | 79 | { |
73 | return sAttributeKeys.addString( name ); | 80 | return sAttributeKeys.addString( name ); |
@@ -79,6 +86,7 @@ public: | |||
79 | 86 | ||
80 | protected: | 87 | protected: |
81 | LLXmlTreeNode* mRoot; | 88 | LLXmlTreeNode* mRoot; |
89 | LLXmlTreeParser *mParser; | ||
82 | 90 | ||
83 | // local | 91 | // local |
84 | LLStdStringTable mNodeNames; | 92 | LLStdStringTable mNodeNames; |
@@ -175,6 +183,11 @@ private: | |||
175 | 183 | ||
176 | void dump( const std::string& prefix ); | 184 | void dump( const std::string& prefix ); |
177 | 185 | ||
186 | void writeNoChild(std::string &buffer, const std::string &indent) const; | ||
187 | void writeStart(std::string &buffer, const std::string &indent) const; | ||
188 | void writeEnd(std::string &buffer, const std::string &indent) const; | ||
189 | void writeAttributes(std::string &buffer) const; | ||
190 | |||
178 | protected: | 191 | protected: |
179 | typedef std::map<LLStdStringHandle, const std::string*> attribute_map_t; | 192 | typedef std::map<LLStdStringHandle, const std::string*> attribute_map_t; |
180 | attribute_map_t mAttributes; | 193 | attribute_map_t mAttributes; |
@@ -207,6 +220,10 @@ public: | |||
207 | 220 | ||
208 | BOOL parseFile(const std::string &path, LLXmlTreeNode** root, BOOL keep_contents ); | 221 | BOOL parseFile(const std::string &path, LLXmlTreeNode** root, BOOL keep_contents ); |
209 | 222 | ||
223 | void parseBufferStart(BOOL keep_contents); | ||
224 | bool parseBuffer(const char *buf, int len); | ||
225 | bool parseBufferFinalize(LLXmlTreeNode** root); | ||
226 | |||
210 | protected: | 227 | protected: |
211 | const std::string& tabs(); | 228 | const std::string& tabs(); |
212 | 229 | ||