diff options
author | Jacek Antonelli | 2008-08-15 23:44:58 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:58 -0500 |
commit | 089fc07d207c71ce1401e72f09c31ad8c45872e2 (patch) | |
tree | 0028955add042c6f45b47a7b774adeeac9c592cb /linden/indra/llxml/llxmlnode.cpp | |
parent | Second Life viewer sources 1.16.0.5 (diff) | |
download | meta-impy-089fc07d207c71ce1401e72f09c31ad8c45872e2.zip meta-impy-089fc07d207c71ce1401e72f09c31ad8c45872e2.tar.gz meta-impy-089fc07d207c71ce1401e72f09c31ad8c45872e2.tar.bz2 meta-impy-089fc07d207c71ce1401e72f09c31ad8c45872e2.tar.xz |
Second Life viewer sources 1.17.0.12
Diffstat (limited to 'linden/indra/llxml/llxmlnode.cpp')
-rw-r--r-- | linden/indra/llxml/llxmlnode.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/linden/indra/llxml/llxmlnode.cpp b/linden/indra/llxml/llxmlnode.cpp index b83555a..26906a4 100644 --- a/linden/indra/llxml/llxmlnode.cpp +++ b/linden/indra/llxml/llxmlnode.cpp | |||
@@ -637,6 +637,66 @@ bool LLXMLNode::parseBuffer( | |||
637 | return true; | 637 | return true; |
638 | } | 638 | } |
639 | 639 | ||
640 | // static | ||
641 | bool LLXMLNode::parseStream( | ||
642 | std::istream& str, | ||
643 | LLXMLNodePtr& node, | ||
644 | LLXMLNode* defaults) | ||
645 | { | ||
646 | // Init | ||
647 | XML_Parser my_parser = XML_ParserCreate(NULL); | ||
648 | XML_SetElementHandler(my_parser, StartXMLNode, EndXMLNode); | ||
649 | XML_SetCharacterDataHandler(my_parser, XMLData); | ||
650 | |||
651 | // Create a root node | ||
652 | LLXMLNode *file_node_ptr = new LLXMLNode("XML", FALSE); | ||
653 | LLXMLNodePtr file_node = file_node_ptr; | ||
654 | |||
655 | file_node->mParser = &my_parser; | ||
656 | |||
657 | XML_SetUserData(my_parser, (void *)file_node_ptr); | ||
658 | |||
659 | const int BUFSIZE = 1024; | ||
660 | U8* buffer = new U8[BUFSIZE]; | ||
661 | |||
662 | while(str.good()) | ||
663 | { | ||
664 | str.read((char*)buffer, BUFSIZE); | ||
665 | int count = str.gcount(); | ||
666 | |||
667 | if (XML_Parse(my_parser, (const char *)buffer, count, !str.good()) != XML_STATUS_OK) | ||
668 | { | ||
669 | llwarns << "Error parsing xml error code: " | ||
670 | << XML_ErrorString(XML_GetErrorCode(my_parser)) | ||
671 | << " on lne " << XML_GetCurrentLineNumber(my_parser) | ||
672 | << llendl; | ||
673 | break; | ||
674 | } | ||
675 | } | ||
676 | |||
677 | delete [] buffer; | ||
678 | |||
679 | // Deinit | ||
680 | XML_ParserFree(my_parser); | ||
681 | |||
682 | if (!file_node->mChildren || file_node->mChildren->map.size() != 1) | ||
683 | { | ||
684 | llwarns << "Parse failure - wrong number of top-level nodes xml." | ||
685 | << llendl; | ||
686 | node = new LLXMLNode(); | ||
687 | return false; | ||
688 | } | ||
689 | |||
690 | LLXMLNode *return_node = file_node->mChildren->map.begin()->second; | ||
691 | |||
692 | return_node->setDefault(defaults); | ||
693 | return_node->updateDefault(); | ||
694 | |||
695 | node = return_node; | ||
696 | return true; | ||
697 | } | ||
698 | |||
699 | |||
640 | BOOL LLXMLNode::isFullyDefault() | 700 | BOOL LLXMLNode::isFullyDefault() |
641 | { | 701 | { |
642 | if (mDefault.isNull()) | 702 | if (mDefault.isNull()) |