summaryrefslogtreecommitdiff
path: root/indra/llxml
diff options
context:
space:
mode:
authorAaron Brashears <aaronb@lindenlab.com>2007-06-13 18:02:37 +0000
committerAaron Brashears <aaronb@lindenlab.com>2007-06-13 18:02:37 +0000
commitf118e7c80b95d8c0a0c8abb14ff379b6697e01b6 (patch)
treedb55a74f8d18b3c366608a537e2a32f6d089d56f /indra/llxml
parent680667d4bdca7e2a6df15cd6f16f34c12c97da8e (diff)
result of merge manually performed through diff and patch. svn diff svn+ssh://svn/svn/linden/release@63615 svn+ssh://svn/svn/linden/branches/release-candidate@63637 | patch -p0 in release
Diffstat (limited to 'indra/llxml')
-rw-r--r--indra/llxml/llxmlnode.cpp60
-rw-r--r--indra/llxml/llxmlnode.h4
2 files changed, 64 insertions, 0 deletions
diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp
index 0b0385d92f..02c762cbe0 100644
--- a/indra/llxml/llxmlnode.cpp
+++ b/indra/llxml/llxmlnode.cpp
@@ -617,6 +617,66 @@ bool LLXMLNode::parseBuffer(
return true;
}
+// static
+bool LLXMLNode::parseStream(
+ std::istream& str,
+ LLXMLNodePtr& node,
+ LLXMLNode* defaults)
+{
+ // Init
+ XML_Parser my_parser = XML_ParserCreate(NULL);
+ XML_SetElementHandler(my_parser, StartXMLNode, EndXMLNode);
+ XML_SetCharacterDataHandler(my_parser, XMLData);
+
+ // Create a root node
+ LLXMLNode *file_node_ptr = new LLXMLNode("XML", FALSE);
+ LLXMLNodePtr file_node = file_node_ptr;
+
+ file_node->mParser = &my_parser;
+
+ XML_SetUserData(my_parser, (void *)file_node_ptr);
+
+ const int BUFSIZE = 1024;
+ U8* buffer = new U8[BUFSIZE];
+
+ while(str.good())
+ {
+ str.read((char*)buffer, BUFSIZE);
+ int count = str.gcount();
+
+ if (XML_Parse(my_parser, (const char *)buffer, count, !str.good()) != XML_STATUS_OK)
+ {
+ llwarns << "Error parsing xml error code: "
+ << XML_ErrorString(XML_GetErrorCode(my_parser))
+ << " on lne " << XML_GetCurrentLineNumber(my_parser)
+ << llendl;
+ break;
+ }
+ }
+
+ delete [] buffer;
+
+ // Deinit
+ XML_ParserFree(my_parser);
+
+ if (!file_node->mChildren || file_node->mChildren->map.size() != 1)
+ {
+ llwarns << "Parse failure - wrong number of top-level nodes xml."
+ << llendl;
+ node = new LLXMLNode();
+ return false;
+ }
+
+ LLXMLNode *return_node = file_node->mChildren->map.begin()->second;
+
+ return_node->setDefault(defaults);
+ return_node->updateDefault();
+
+ node = return_node;
+ return true;
+}
+
+
BOOL LLXMLNode::isFullyDefault()
{
if (mDefault.isNull())
diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h
index e95904dad8..24fccb72c6 100644
--- a/indra/llxml/llxmlnode.h
+++ b/indra/llxml/llxmlnode.h
@@ -97,6 +97,10 @@ public:
U32 length,
LLXMLNodePtr& node,
LLXMLNode* defaults);
+ static bool parseStream(
+ std::istream& str,
+ LLXMLNodePtr& node,
+ LLXMLNode* defaults);
static bool updateNode(
LLXMLNodePtr& node,
LLXMLNodePtr& update_node);