diff options
Diffstat (limited to 'indra/llxml/llxmltree.cpp')
-rw-r--r-- | indra/llxml/llxmltree.cpp | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/indra/llxml/llxmltree.cpp b/indra/llxml/llxmltree.cpp index be3bcf2a66..38321847c3 100644 --- a/indra/llxml/llxmltree.cpp +++ b/indra/llxml/llxmltree.cpp @@ -35,6 +35,7 @@ #include "v4math.h" #include "llquaternion.h" #include "lluuid.h" +#include "lldir.h" ////////////////////////////////////////////////////////////// // LLXmlTree @@ -60,20 +61,37 @@ void LLXmlTree::cleanup() mNodeNames.cleanup(); } +bool LLXmlTree::parseFile(const std::string & filename, bool keep_contents) +{ + delete mRoot; + mRoot = NULL; + + std::string xml = gDirUtilp->getFileContents(filename); + if (xml.empty()) + { + LL_WARNS() << "LLXmlTree parse failed. No XML file: " << filename << LL_ENDL; + return false; + } + + bool success = parseString(xml, keep_contents); -bool LLXmlTree::parseFile(const std::string &path, bool keep_contents) + return success; +} + +bool LLXmlTree::parseString(const std::string &xml, bool keep_contents) { delete mRoot; mRoot = NULL; LLXmlTreeParser parser(this); - bool success = parser.parseFile( path, &mRoot, keep_contents ); - if( !success ) + bool success = parser.parseString(xml, &mRoot, keep_contents); + if (!success) { S32 line_number = parser.getCurrentLineNumber(); const char* error = parser.getErrorString(); LL_WARNS() << "LLXmlTree parse failed. Line " << line_number << ": " << error << LL_ENDL; } + return success; } @@ -536,6 +554,27 @@ bool LLXmlTreeParser::parseFile(const std::string &path, LLXmlTreeNode** root, b return success; } +bool LLXmlTreeParser::parseString(const std::string& xml, LLXmlTreeNode** root, bool keep_contents) +{ + llassert( !mRoot ); + llassert( !mCurrent ); + + mKeepContents = keep_contents; + + bool success = LLXmlParser::parse(xml.data(), (int)xml.size(), true); + + *root = mRoot; + mRoot = NULL; + + if (success) + { + llassert(!mCurrent); + } + + mCurrent = NULL; + + return success; +} const std::string& LLXmlTreeParser::tabs() { |