aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llxml/llxmlnode.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llxml/llxmlnode.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llxml/llxmlnode.cpp')
-rw-r--r--linden/indra/llxml/llxmlnode.cpp233
1 files changed, 116 insertions, 117 deletions
diff --git a/linden/indra/llxml/llxmlnode.cpp b/linden/indra/llxml/llxmlnode.cpp
index f9852d3..145e6e0 100644
--- a/linden/indra/llxml/llxmlnode.cpp
+++ b/linden/indra/llxml/llxmlnode.cpp
@@ -55,6 +55,7 @@ BOOL LLXMLNode::sStripWhitespaceValues = FALSE;
55 55
56LLXMLNode::LLXMLNode() : 56LLXMLNode::LLXMLNode() :
57 mID(""), 57 mID(""),
58 mParser(NULL),
58 mIsAttribute(FALSE), 59 mIsAttribute(FALSE),
59 mVersionMajor(0), 60 mVersionMajor(0),
60 mVersionMinor(0), 61 mVersionMinor(0),
@@ -70,8 +71,9 @@ LLXMLNode::LLXMLNode() :
70{ 71{
71} 72}
72 73
73LLXMLNode::LLXMLNode(const LLString& name, BOOL is_attribute) : 74LLXMLNode::LLXMLNode(const char* name, BOOL is_attribute) :
74 mID(""), 75 mID(""),
76 mParser(NULL),
75 mIsAttribute(is_attribute), 77 mIsAttribute(is_attribute),
76 mVersionMajor(0), 78 mVersionMajor(0),
77 mVersionMinor(0), 79 mVersionMinor(0),
@@ -89,6 +91,7 @@ LLXMLNode::LLXMLNode(const LLString& name, BOOL is_attribute) :
89 91
90LLXMLNode::LLXMLNode(LLStringTableEntry* name, BOOL is_attribute) : 92LLXMLNode::LLXMLNode(LLStringTableEntry* name, BOOL is_attribute) :
91 mID(""), 93 mID(""),
94 mParser(NULL),
92 mIsAttribute(is_attribute), 95 mIsAttribute(is_attribute),
93 mVersionMajor(0), 96 mVersionMajor(0),
94 mVersionMinor(0), 97 mVersionMinor(0),
@@ -212,7 +215,7 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child)
212 new_child->mParent = this; 215 new_child->mParent = this;
213 if (new_child->mIsAttribute) 216 if (new_child->mIsAttribute)
214 { 217 {
215 mAttributes.insert(std::pair<LLStringTableEntry*, LLXMLNodePtr>(new_child->mName, new_child)); 218 mAttributes.insert(std::make_pair(new_child->mName, new_child));
216 } 219 }
217 else 220 else
218 { 221 {
@@ -222,7 +225,7 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child)
222 mChildren->head = new_child; 225 mChildren->head = new_child;
223 mChildren->tail = new_child; 226 mChildren->tail = new_child;
224 } 227 }
225 mChildren->map.insert(std::pair<LLStringTableEntry*, LLXMLNodePtr>(new_child->mName, new_child)); 228 mChildren->map.insert(std::make_pair(new_child->mName, new_child));
226 229
227 if (mChildren->tail != new_child) 230 if (mChildren->tail != new_child)
228 { 231 {
@@ -236,7 +239,7 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child)
236} 239}
237 240
238// virtual 241// virtual
239LLXMLNodePtr LLXMLNode::createChild(const LLString& name, BOOL is_attribute) 242LLXMLNodePtr LLXMLNode::createChild(const char* name, BOOL is_attribute)
240{ 243{
241 return createChild(gStringTable.addStringEntry(name), is_attribute); 244 return createChild(gStringTable.addStringEntry(name), is_attribute);
242} 245}
@@ -245,7 +248,7 @@ LLXMLNodePtr LLXMLNode::createChild(const LLString& name, BOOL is_attribute)
245LLXMLNodePtr LLXMLNode::createChild(LLStringTableEntry* name, BOOL is_attribute) 248LLXMLNodePtr LLXMLNode::createChild(LLStringTableEntry* name, BOOL is_attribute)
246{ 249{
247 LLXMLNode* ret = new LLXMLNode(name, is_attribute); 250 LLXMLNode* ret = new LLXMLNode(name, is_attribute);
248 ret->mID = ""; 251 ret->mID.clear();
249 addChild(ret); 252 addChild(ret);
250 return ret; 253 return ret;
251} 254}
@@ -309,7 +312,7 @@ void XMLCALL StartXMLNode(void *userData,
309 // Create a new node 312 // Create a new node
310 LLXMLNode *new_node_ptr = new LLXMLNode(name, FALSE); 313 LLXMLNode *new_node_ptr = new LLXMLNode(name, FALSE);
311 LLXMLNodePtr new_node = new_node_ptr; 314 LLXMLNodePtr new_node = new_node_ptr;
312 new_node->mID = ""; 315 new_node->mID.clear();
313 LLXMLNodePtr ptr_new_node = new_node; 316 LLXMLNodePtr ptr_new_node = new_node;
314 317
315 // Set the parent-child relationship with the current active node 318 // Set the parent-child relationship with the current active node
@@ -331,8 +334,8 @@ void XMLCALL StartXMLNode(void *userData,
331 U32 pos = 0; 334 U32 pos = 0;
332 while (atts[pos] != NULL) 335 while (atts[pos] != NULL)
333 { 336 {
334 LLString attr_name = atts[pos]; 337 std::string attr_name = atts[pos];
335 LLString attr_value = atts[pos+1]; 338 std::string attr_value = atts[pos+1];
336 339
337 // Special cases 340 // Special cases
338 if ('i' == attr_name[0] && "id" == attr_name) 341 if ('i' == attr_name[0] && "id" == attr_name)
@@ -410,9 +413,9 @@ void XMLCALL StartXMLNode(void *userData,
410 413
411 // only one attribute child per description 414 // only one attribute child per description
412 LLXMLNodePtr attr_node; 415 LLXMLNodePtr attr_node;
413 if (!new_node->getAttribute(attr_name, attr_node, FALSE)) 416 if (!new_node->getAttribute(attr_name.c_str(), attr_node, FALSE))
414 { 417 {
415 attr_node = new LLXMLNode(attr_name, TRUE); 418 attr_node = new LLXMLNode(attr_name.c_str(), TRUE);
416 } 419 }
417 attr_node->setValue(attr_value); 420 attr_node->setValue(attr_value);
418 new_node->addChild(attr_node); 421 new_node->addChild(attr_node);
@@ -436,7 +439,7 @@ void XMLCALL EndXMLNode(void *userData,
436 // SJB: total hack: 439 // SJB: total hack:
437 if (LLXMLNode::sStripWhitespaceValues) 440 if (LLXMLNode::sStripWhitespaceValues)
438 { 441 {
439 LLString value = node->getValue(); 442 std::string value = node->getValue();
440 BOOL is_empty = TRUE; 443 BOOL is_empty = TRUE;
441 for (std::string::size_type s = 0; s < value.length(); s++) 444 for (std::string::size_type s = 0; s < value.length(); s++)
442 { 445 {
@@ -460,13 +463,13 @@ void XMLCALL XMLData(void *userData,
460 int len) 463 int len)
461{ 464{
462 LLXMLNode* current_node = (LLXMLNode *)userData; 465 LLXMLNode* current_node = (LLXMLNode *)userData;
463 LLString value = current_node->getValue(); 466 std::string value = current_node->getValue();
464 if (LLXMLNode::sStripEscapedStrings) 467 if (LLXMLNode::sStripEscapedStrings)
465 { 468 {
466 if (s[0] == '\"' && s[len-1] == '\"') 469 if (s[0] == '\"' && s[len-1] == '\"')
467 { 470 {
468 // Special-case: Escaped string. 471 // Special-case: Escaped string.
469 LLString unescaped_string; 472 std::string unescaped_string;
470 for (S32 pos=1; pos<len-1; ++pos) 473 for (S32 pos=1; pos<len-1; ++pos)
471 { 474 {
472 if (s[pos] == '\\' && s[pos+1] == '\\') 475 if (s[pos] == '\\' && s[pos+1] == '\\')
@@ -489,7 +492,7 @@ void XMLCALL XMLData(void *userData,
489 return; 492 return;
490 } 493 }
491 } 494 }
492 value.append(LLString(s, 0, len)); 495 value.append(std::string(s, len));
493 current_node->setValue(value); 496 current_node->setValue(value);
494} 497}
495 498
@@ -537,8 +540,8 @@ bool LLXMLNode::updateNode(
537 { 540 {
538 for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) 541 for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
539 { 542 {
540 LLString nodeName; 543 std::string nodeName;
541 LLString updateName; 544 std::string updateName;
542 545
543 updateChild->getAttributeString("name", updateName); 546 updateChild->getAttributeString("name", updateName);
544 child->getAttributeString("name", nodeName); 547 child->getAttributeString("name", nodeName);
@@ -566,13 +569,11 @@ bool LLXMLNode::updateNode(
566 569
567 570
568// static 571// static
569bool LLXMLNode::parseFile( 572bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXMLNode* defaults_tree)
570 LLString filename,
571 LLXMLNodePtr& node,
572 LLXMLNode* defaults_tree)
573{ 573{
574 // Read file 574 // Read file
575 LLFILE* fp = LLFile::fopen(filename.c_str(), "rb"); /* Flawfinder: ignore */ 575 LL_DEBUGS("XMLNode") << "parsing XML file: " << filename << LL_ENDL;
576 LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
576 if (fp == NULL) 577 if (fp == NULL)
577 { 578 {
578 node = new LLXMLNode(); 579 node = new LLXMLNode();
@@ -746,7 +747,7 @@ void LLXMLNode::writeHeaderToFile(LLFILE *fOut)
746 fprintf(fOut, "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n"); 747 fprintf(fOut, "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n");
747} 748}
748 749
749void LLXMLNode::writeToFile(LLFILE *fOut, LLString indent) 750void LLXMLNode::writeToFile(LLFILE *fOut, const std::string& indent)
750{ 751{
751 if (isFullyDefault()) 752 if (isFullyDefault())
752 { 753 {
@@ -756,14 +757,14 @@ void LLXMLNode::writeToFile(LLFILE *fOut, LLString indent)
756 757
757 std::ostringstream ostream; 758 std::ostringstream ostream;
758 writeToOstream(ostream, indent); 759 writeToOstream(ostream, indent);
759 LLString outstring = ostream.str(); 760 std::string outstring = ostream.str();
760 if (fwrite(outstring.c_str(), 1, outstring.length(), fOut) != outstring.length()) 761 if (fwrite(outstring.c_str(), 1, outstring.length(), fOut) != outstring.length())
761 { 762 {
762 llwarns << "Short write" << llendl; 763 llwarns << "Short write" << llendl;
763 } 764 }
764} 765}
765 766
766void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& indent) 767void LLXMLNode::writeToOstream(std::ostream& output_stream, const std::string& indent)
767{ 768{
768 if (isFullyDefault()) 769 if (isFullyDefault())
769 { 770 {
@@ -777,12 +778,12 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde
777 BOOL has_default_length = mDefault.isNull()?FALSE:(mLength == mDefault->mLength); 778 BOOL has_default_length = mDefault.isNull()?FALSE:(mLength == mDefault->mLength);
778 779
779 // stream the name 780 // stream the name
780 output_stream << indent.c_str() << "<" << mName->mString; 781 output_stream << indent << "<" << mName->mString;
781 782
782 // ID 783 // ID
783 if (mID != "") 784 if (mID != "")
784 { 785 {
785 output_stream << " id=\"" << mID.c_str() << "\""; 786 output_stream << " id=\"" << mID << "\"";
786 } 787 }
787 788
788 // Type 789 // Type
@@ -862,7 +863,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde
862 LLXMLNodePtr child = (*attr_itr).second; 863 LLXMLNodePtr child = (*attr_itr).second;
863 if (child->mDefault.isNull() || child->mDefault->mValue != child->mValue) 864 if (child->mDefault.isNull() || child->mDefault->mValue != child->mValue)
864 { 865 {
865 LLString attr = child->mName->mString; 866 std::string attr = child->mName->mString;
866 if (attr == "id" || 867 if (attr == "id" ||
867 attr == "type" || 868 attr == "type" ||
868 attr == "encoding" || 869 attr == "encoding" ||
@@ -873,7 +874,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde
873 continue; // skip built-in attributes 874 continue; // skip built-in attributes
874 } 875 }
875 876
876 LLString attr_str = llformat(" %s=\"%s\"", 877 std::string attr_str = llformat(" %s=\"%s\"",
877 attr.c_str(), 878 attr.c_str(),
878 escapeXML(child->mValue).c_str()); 879 escapeXML(child->mValue).c_str());
879 if (col_pos + (S32)attr_str.length() > MAX_COLUMN_WIDTH) 880 if (col_pos + (S32)attr_str.length() > MAX_COLUMN_WIDTH)
@@ -898,7 +899,7 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde
898 if (mChildren) 899 if (mChildren)
899 { 900 {
900 // stream non-attributes 901 // stream non-attributes
901 LLString next_indent = indent + "\t"; 902 std::string next_indent = indent + "\t";
902 for (LLXMLNode* child = getFirstChild(); child; child = child->getNextSibling()) 903 for (LLXMLNode* child = getFirstChild(); child; child = child->getNextSibling())
903 { 904 {
904 child->writeToOstream(output_stream, next_indent); 905 child->writeToOstream(output_stream, next_indent);
@@ -906,19 +907,19 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const LLString& inde
906 } 907 }
907 if (!mValue.empty()) 908 if (!mValue.empty())
908 { 909 {
909 LLString contents = getTextContents(); 910 std::string contents = getTextContents();
910 output_stream << indent.c_str() << "\t" << escapeXML(contents) << "\n"; 911 output_stream << indent << "\t" << escapeXML(contents) << "\n";
911 } 912 }
912 output_stream << indent.c_str() << "</" << mName->mString << ">\n"; 913 output_stream << indent << "</" << mName->mString << ">\n";
913 } 914 }
914} 915}
915 916
916void LLXMLNode::findName(const LLString& name, LLXMLNodeList &results) 917void LLXMLNode::findName(const std::string& name, LLXMLNodeList &results)
917{ 918{
918 LLStringTableEntry* name_entry = gStringTable.checkStringEntry(name); 919 LLStringTableEntry* name_entry = gStringTable.checkStringEntry(name);
919 if (name_entry == mName) 920 if (name_entry == mName)
920 { 921 {
921 results.insert(std::pair<LLString, LLXMLNode*>(this->mName->mString, this)); 922 results.insert(std::make_pair(this->mName->mString, this));
922 return; 923 return;
923 } 924 }
924 if (mChildren) 925 if (mChildren)
@@ -937,7 +938,7 @@ void LLXMLNode::findName(LLStringTableEntry* name, LLXMLNodeList &results)
937{ 938{
938 if (name == mName) 939 if (name == mName)
939 { 940 {
940 results.insert(std::pair<LLString, LLXMLNode*>(this->mName->mString, this)); 941 results.insert(std::make_pair(this->mName->mString, this));
941 return; 942 return;
942 } 943 }
943 if (mChildren) 944 if (mChildren)
@@ -952,11 +953,11 @@ void LLXMLNode::findName(LLStringTableEntry* name, LLXMLNodeList &results)
952 } 953 }
953} 954}
954 955
955void LLXMLNode::findID(const LLString& id, LLXMLNodeList &results) 956void LLXMLNode::findID(const std::string& id, LLXMLNodeList &results)
956{ 957{
957 if (id == mID) 958 if (id == mID)
958 { 959 {
959 results.insert(std::pair<LLString, LLXMLNode*>(this->mName->mString, this)); 960 results.insert(std::make_pair(this->mName->mString, this));
960 return; 961 return;
961 } 962 }
962 if (mChildren) 963 if (mChildren)
@@ -1015,7 +1016,7 @@ void LLXMLNode::scrubToTree(LLXMLNode *tree)
1015 } 1016 }
1016} 1017}
1017 1018
1018bool LLXMLNode::getChild(const LLString& name, LLXMLNodePtr& node, BOOL use_default_if_missing) 1019bool LLXMLNode::getChild(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing)
1019{ 1020{
1020 return getChild(gStringTable.checkStringEntry(name), node, use_default_if_missing); 1021 return getChild(gStringTable.checkStringEntry(name), node, use_default_if_missing);
1021} 1022}
@@ -1039,7 +1040,7 @@ bool LLXMLNode::getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOO
1039 return false; 1040 return false;
1040} 1041}
1041 1042
1042void LLXMLNode::getChildren(const LLString& name, LLXMLNodeList &children, BOOL use_default_if_missing) const 1043void LLXMLNode::getChildren(const char* name, LLXMLNodeList &children, BOOL use_default_if_missing) const
1043{ 1044{
1044 getChildren(gStringTable.checkStringEntry(name), children, use_default_if_missing); 1045 getChildren(gStringTable.checkStringEntry(name), children, use_default_if_missing);
1045} 1046}
@@ -1059,7 +1060,7 @@ void LLXMLNode::getChildren(const LLStringTableEntry* name, LLXMLNodeList &child
1059 { 1060 {
1060 break; 1061 break;
1061 } 1062 }
1062 children.insert(std::pair<LLString, LLXMLNodePtr>(child->mName->mString, child)); 1063 children.insert(std::make_pair(child->mName->mString, child));
1063 child_itr++; 1064 child_itr++;
1064 } 1065 }
1065 } 1066 }
@@ -1070,7 +1071,7 @@ void LLXMLNode::getChildren(const LLStringTableEntry* name, LLXMLNodeList &child
1070 } 1071 }
1071} 1072}
1072 1073
1073bool LLXMLNode::getAttribute(const LLString& name, LLXMLNodePtr& node, BOOL use_default_if_missing) 1074bool LLXMLNode::getAttribute(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing)
1074{ 1075{
1075 return getAttribute(gStringTable.checkStringEntry(name), node, use_default_if_missing); 1076 return getAttribute(gStringTable.checkStringEntry(name), node, use_default_if_missing);
1076} 1077}
@@ -1091,7 +1092,7 @@ bool LLXMLNode::getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node,
1091 return false; 1092 return false;
1092} 1093}
1093 1094
1094bool LLXMLNode::setAttributeString(const LLString& attr, const LLString& value) 1095bool LLXMLNode::setAttributeString(const char* attr, const std::string& value)
1095{ 1096{
1096 LLStringTableEntry* name = gStringTable.checkStringEntry(attr); 1097 LLStringTableEntry* name = gStringTable.checkStringEntry(attr);
1097 LLXMLAttribList::const_iterator child_itr = mAttributes.find(name); 1098 LLXMLAttribList::const_iterator child_itr = mAttributes.find(name);
@@ -1104,25 +1105,25 @@ bool LLXMLNode::setAttributeString(const LLString& attr, const LLString& value)
1104 return false; 1105 return false;
1105} 1106}
1106 1107
1107BOOL LLXMLNode::hasAttribute(const LLString& name ) 1108BOOL LLXMLNode::hasAttribute(const char* name )
1108{ 1109{
1109 LLXMLNodePtr node; 1110 LLXMLNodePtr node;
1110 return getAttribute(name, node); 1111 return getAttribute(name, node);
1111} 1112}
1112 1113
1113BOOL LLXMLNode::getAttributeBOOL(const LLString& name, BOOL& value ) 1114BOOL LLXMLNode::getAttributeBOOL(const char* name, BOOL& value )
1114{ 1115{
1115 LLXMLNodePtr node; 1116 LLXMLNodePtr node;
1116 return (getAttribute(name, node) && node->getBoolValue(1, &value)); 1117 return (getAttribute(name, node) && node->getBoolValue(1, &value));
1117} 1118}
1118 1119
1119BOOL LLXMLNode::getAttributeU8(const LLString& name, U8& value ) 1120BOOL LLXMLNode::getAttributeU8(const char* name, U8& value )
1120{ 1121{
1121 LLXMLNodePtr node; 1122 LLXMLNodePtr node;
1122 return (getAttribute(name, node) && node->getByteValue(1, &value)); 1123 return (getAttribute(name, node) && node->getByteValue(1, &value));
1123} 1124}
1124 1125
1125BOOL LLXMLNode::getAttributeS8(const LLString& name, S8& value ) 1126BOOL LLXMLNode::getAttributeS8(const char* name, S8& value )
1126{ 1127{
1127 LLXMLNodePtr node; 1128 LLXMLNodePtr node;
1128 S32 val; 1129 S32 val;
@@ -1134,7 +1135,7 @@ BOOL LLXMLNode::getAttributeS8(const LLString& name, S8& value )
1134 return true; 1135 return true;
1135} 1136}
1136 1137
1137BOOL LLXMLNode::getAttributeU16(const LLString& name, U16& value ) 1138BOOL LLXMLNode::getAttributeU16(const char* name, U16& value )
1138{ 1139{
1139 LLXMLNodePtr node; 1140 LLXMLNodePtr node;
1140 U32 val; 1141 U32 val;
@@ -1146,7 +1147,7 @@ BOOL LLXMLNode::getAttributeU16(const LLString& name, U16& value )
1146 return true; 1147 return true;
1147} 1148}
1148 1149
1149BOOL LLXMLNode::getAttributeS16(const LLString& name, S16& value ) 1150BOOL LLXMLNode::getAttributeS16(const char* name, S16& value )
1150{ 1151{
1151 LLXMLNodePtr node; 1152 LLXMLNodePtr node;
1152 S32 val; 1153 S32 val;
@@ -1158,73 +1159,73 @@ BOOL LLXMLNode::getAttributeS16(const LLString& name, S16& value )
1158 return true; 1159 return true;
1159} 1160}
1160 1161
1161BOOL LLXMLNode::getAttributeU32(const LLString& name, U32& value ) 1162BOOL LLXMLNode::getAttributeU32(const char* name, U32& value )
1162{ 1163{
1163 LLXMLNodePtr node; 1164 LLXMLNodePtr node;
1164 return (getAttribute(name, node) && node->getUnsignedValue(1, &value)); 1165 return (getAttribute(name, node) && node->getUnsignedValue(1, &value));
1165} 1166}
1166 1167
1167BOOL LLXMLNode::getAttributeS32(const LLString& name, S32& value ) 1168BOOL LLXMLNode::getAttributeS32(const char* name, S32& value )
1168{ 1169{
1169 LLXMLNodePtr node; 1170 LLXMLNodePtr node;
1170 return (getAttribute(name, node) && node->getIntValue(1, &value)); 1171 return (getAttribute(name, node) && node->getIntValue(1, &value));
1171} 1172}
1172 1173
1173BOOL LLXMLNode::getAttributeF32(const LLString& name, F32& value ) 1174BOOL LLXMLNode::getAttributeF32(const char* name, F32& value )
1174{ 1175{
1175 LLXMLNodePtr node; 1176 LLXMLNodePtr node;
1176 return (getAttribute(name, node) && node->getFloatValue(1, &value)); 1177 return (getAttribute(name, node) && node->getFloatValue(1, &value));
1177} 1178}
1178 1179
1179BOOL LLXMLNode::getAttributeF64(const LLString& name, F64& value ) 1180BOOL LLXMLNode::getAttributeF64(const char* name, F64& value )
1180{ 1181{
1181 LLXMLNodePtr node; 1182 LLXMLNodePtr node;
1182 return (getAttribute(name, node) && node->getDoubleValue(1, &value)); 1183 return (getAttribute(name, node) && node->getDoubleValue(1, &value));
1183} 1184}
1184 1185
1185BOOL LLXMLNode::getAttributeColor(const LLString& name, LLColor4& value ) 1186BOOL LLXMLNode::getAttributeColor(const char* name, LLColor4& value )
1186{ 1187{
1187 LLXMLNodePtr node; 1188 LLXMLNodePtr node;
1188 return (getAttribute(name, node) && node->getFloatValue(4, value.mV)); 1189 return (getAttribute(name, node) && node->getFloatValue(4, value.mV));
1189} 1190}
1190 1191
1191BOOL LLXMLNode::getAttributeColor4(const LLString& name, LLColor4& value ) 1192BOOL LLXMLNode::getAttributeColor4(const char* name, LLColor4& value )
1192{ 1193{
1193 LLXMLNodePtr node; 1194 LLXMLNodePtr node;
1194 return (getAttribute(name, node) && node->getFloatValue(4, value.mV)); 1195 return (getAttribute(name, node) && node->getFloatValue(4, value.mV));
1195} 1196}
1196 1197
1197BOOL LLXMLNode::getAttributeColor4U(const LLString& name, LLColor4U& value ) 1198BOOL LLXMLNode::getAttributeColor4U(const char* name, LLColor4U& value )
1198{ 1199{
1199 LLXMLNodePtr node; 1200 LLXMLNodePtr node;
1200 return (getAttribute(name, node) && node->getByteValue(4, value.mV)); 1201 return (getAttribute(name, node) && node->getByteValue(4, value.mV));
1201} 1202}
1202 1203
1203BOOL LLXMLNode::getAttributeVector3(const LLString& name, LLVector3& value ) 1204BOOL LLXMLNode::getAttributeVector3(const char* name, LLVector3& value )
1204{ 1205{
1205 LLXMLNodePtr node; 1206 LLXMLNodePtr node;
1206 return (getAttribute(name, node) && node->getFloatValue(3, value.mV)); 1207 return (getAttribute(name, node) && node->getFloatValue(3, value.mV));
1207} 1208}
1208 1209
1209BOOL LLXMLNode::getAttributeVector3d(const LLString& name, LLVector3d& value ) 1210BOOL LLXMLNode::getAttributeVector3d(const char* name, LLVector3d& value )
1210{ 1211{
1211 LLXMLNodePtr node; 1212 LLXMLNodePtr node;
1212 return (getAttribute(name, node) && node->getDoubleValue(3, value.mdV)); 1213 return (getAttribute(name, node) && node->getDoubleValue(3, value.mdV));
1213} 1214}
1214 1215
1215BOOL LLXMLNode::getAttributeQuat(const LLString& name, LLQuaternion& value ) 1216BOOL LLXMLNode::getAttributeQuat(const char* name, LLQuaternion& value )
1216{ 1217{
1217 LLXMLNodePtr node; 1218 LLXMLNodePtr node;
1218 return (getAttribute(name, node) && node->getFloatValue(4, value.mQ)); 1219 return (getAttribute(name, node) && node->getFloatValue(4, value.mQ));
1219} 1220}
1220 1221
1221BOOL LLXMLNode::getAttributeUUID(const LLString& name, LLUUID& value ) 1222BOOL LLXMLNode::getAttributeUUID(const char* name, LLUUID& value )
1222{ 1223{
1223 LLXMLNodePtr node; 1224 LLXMLNodePtr node;
1224 return (getAttribute(name, node) && node->getUUIDValue(1, &value)); 1225 return (getAttribute(name, node) && node->getUUIDValue(1, &value));
1225} 1226}
1226 1227
1227BOOL LLXMLNode::getAttributeString(const LLString& name, LLString& value ) 1228BOOL LLXMLNode::getAttributeString(const char* name, std::string& value )
1228{ 1229{
1229 LLXMLNodePtr node; 1230 LLXMLNodePtr node;
1230 if (!getAttribute(name, node)) 1231 if (!getAttribute(name, node))
@@ -1536,14 +1537,14 @@ U32 LLXMLNode::getBoolValue(U32 expected_length, BOOL *array)
1536 return 0; 1537 return 0;
1537 } 1538 }
1538 1539
1539 LLString *str_array = new LLString[expected_length]; 1540 std::string *str_array = new std::string[expected_length];
1540 1541
1541 U32 length = getStringValue(expected_length, str_array); 1542 U32 length = getStringValue(expected_length, str_array);
1542 1543
1543 U32 ret_length = 0; 1544 U32 ret_length = 0;
1544 for (U32 i=0; i<length; ++i) 1545 for (U32 i=0; i<length; ++i)
1545 { 1546 {
1546 LLString::toLower(str_array[i]); 1547 LLStringUtil::toLower(str_array[i]);
1547 if (str_array[i] == "false") 1548 if (str_array[i] == "false")
1548 { 1549 {
1549 array[ret_length++] = FALSE; 1550 array[ret_length++] = FALSE;
@@ -1872,7 +1873,7 @@ U32 LLXMLNode::getDoubleValue(U32 expected_length, F64 *array, Encoding encoding
1872 return i; 1873 return i;
1873} 1874}
1874 1875
1875U32 LLXMLNode::getStringValue(U32 expected_length, LLString *array) 1876U32 LLXMLNode::getStringValue(U32 expected_length, std::string *array)
1876{ 1877{
1877 llassert(array); 1878 llassert(array);
1878 1879
@@ -1947,7 +1948,7 @@ U32 LLXMLNode::getUUIDValue(U32 expected_length, LLUUID *array)
1947 memcpy(uuid_string, value_string, (UUID_STR_LENGTH-1)); /* Flawfinder: ignore */ 1948 memcpy(uuid_string, value_string, (UUID_STR_LENGTH-1)); /* Flawfinder: ignore */
1948 uuid_string[(UUID_STR_LENGTH-1)] = 0; 1949 uuid_string[(UUID_STR_LENGTH-1)] = 0;
1949 1950
1950 if (!LLUUID::parseUUID(uuid_string, &uuid_value)) 1951 if (!LLUUID::parseUUID(std::string(uuid_string), &uuid_value))
1951 { 1952 {
1952 break; 1953 break;
1953 } 1954 }
@@ -1975,7 +1976,7 @@ U32 LLXMLNode::getNodeRefValue(U32 expected_length, LLXMLNode **array)
1975 return 0; 1976 return 0;
1976 } 1977 }
1977 1978
1978 LLString *string_array = new LLString[expected_length]; 1979 std::string *string_array = new std::string[expected_length];
1979 1980
1980 U32 num_strings = getStringValue(expected_length, string_array); 1981 U32 num_strings = getStringValue(expected_length, string_array);
1981 1982
@@ -2015,7 +2016,7 @@ void LLXMLNode::setBoolValue(U32 length, const BOOL *array)
2015{ 2016{
2016 if (length == 0) return; 2017 if (length == 0) return;
2017 2018
2018 LLString new_value; 2019 std::string new_value;
2019 for (U32 pos=0; pos<length; ++pos) 2020 for (U32 pos=0; pos<length; ++pos)
2020 { 2021 {
2021 if (pos > 0) 2022 if (pos > 0)
@@ -2038,7 +2039,7 @@ void LLXMLNode::setByteValue(U32 length, const U8* const array, Encoding encodin
2038{ 2039{
2039 if (length == 0) return; 2040 if (length == 0) return;
2040 2041
2041 LLString new_value; 2042 std::string new_value;
2042 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) 2043 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL)
2043 { 2044 {
2044 for (U32 pos=0; pos<length; ++pos) 2045 for (U32 pos=0; pos<length; ++pos)
@@ -2081,7 +2082,7 @@ void LLXMLNode::setIntValue(U32 length, const S32 *array, Encoding encoding)
2081{ 2082{
2082 if (length == 0) return; 2083 if (length == 0) return;
2083 2084
2084 LLString new_value; 2085 std::string new_value;
2085 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) 2086 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL)
2086 { 2087 {
2087 for (U32 pos=0; pos<length; ++pos) 2088 for (U32 pos=0; pos<length; ++pos)
@@ -2128,7 +2129,7 @@ void LLXMLNode::setUnsignedValue(U32 length, const U32* array, Encoding encoding
2128{ 2129{
2129 if (length == 0) return; 2130 if (length == 0) return;
2130 2131
2131 LLString new_value; 2132 std::string new_value;
2132 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) 2133 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL)
2133 { 2134 {
2134 for (U32 pos=0; pos<length; ++pos) 2135 for (U32 pos=0; pos<length; ++pos)
@@ -2177,7 +2178,7 @@ void LLXMLNode::setLongValue(U32 length, const U64* array, Encoding encoding)
2177{ 2178{
2178 if (length == 0) return; 2179 if (length == 0) return;
2179 2180
2180 LLString new_value; 2181 std::string new_value;
2181 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) 2182 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL)
2182 { 2183 {
2183 for (U32 pos=0; pos<length; ++pos) 2184 for (U32 pos=0; pos<length; ++pos)
@@ -2226,21 +2227,21 @@ void LLXMLNode::setFloatValue(U32 length, const F32 *array, Encoding encoding, U
2226{ 2227{
2227 if (length == 0) return; 2228 if (length == 0) return;
2228 2229
2229 LLString new_value; 2230 std::string new_value;
2230 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) 2231 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL)
2231 { 2232 {
2232 char format_string[10]; /* Flawfinder: ignore */ 2233 std::string format_string;
2233 if (precision > 0) 2234 if (precision > 0)
2234 { 2235 {
2235 if (precision > 25) 2236 if (precision > 25)
2236 { 2237 {
2237 precision = 25; 2238 precision = 25;
2238 } 2239 }
2239 snprintf(format_string, sizeof(format_string), "%%.%dg", precision); /* Flawfinder: ignore */ 2240 format_string = llformat( "%%.%dg", precision);
2240 } 2241 }
2241 else 2242 else
2242 { 2243 {
2243 snprintf(format_string, sizeof(format_string), "%%g"); /* Flawfinder: ignore */ 2244 format_string = llformat( "%%g");
2244 } 2245 }
2245 2246
2246 for (U32 pos=0; pos<length; ++pos) 2247 for (U32 pos=0; pos<length; ++pos)
@@ -2248,11 +2249,11 @@ void LLXMLNode::setFloatValue(U32 length, const F32 *array, Encoding encoding, U
2248 if (pos > 0) 2249 if (pos > 0)
2249 { 2250 {
2250 new_value.append(" "); 2251 new_value.append(" ");
2251 new_value.append(llformat(format_string, array[pos])); 2252 new_value.append(llformat(format_string.c_str(), array[pos]));
2252 } 2253 }
2253 else 2254 else
2254 { 2255 {
2255 new_value.assign(llformat(format_string, array[pos])); 2256 new_value.assign(llformat(format_string.c_str(), array[pos]));
2256 } 2257 }
2257 } 2258 }
2258 mValue = new_value; 2259 mValue = new_value;
@@ -2277,32 +2278,32 @@ void LLXMLNode::setDoubleValue(U32 length, const F64 *array, Encoding encoding,
2277{ 2278{
2278 if (length == 0) return; 2279 if (length == 0) return;
2279 2280
2280 LLString new_value; 2281 std::string new_value;
2281 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL) 2282 if (encoding == ENCODING_DEFAULT || encoding == ENCODING_DECIMAL)
2282 { 2283 {
2283 char format_string[10]; /* Flawfinder: ignore */ 2284 std::string format_string;
2284 if (precision > 0) 2285 if (precision > 0)
2285 { 2286 {
2286 if (precision > 25) 2287 if (precision > 25)
2287 { 2288 {
2288 precision = 25; 2289 precision = 25;
2289 } 2290 }
2290 snprintf(format_string, sizeof(format_string), "%%.%dg", precision); /* Flawfinder: ignore */ 2291 format_string = llformat( "%%.%dg", precision);
2291 } 2292 }
2292 else 2293 else
2293 { 2294 {
2294 snprintf(format_string, sizeof(format_string), "%%g"); /* Flawfinder: ignore */ 2295 format_string = llformat( "%%g");
2295 } 2296 }
2296 for (U32 pos=0; pos<length; ++pos) 2297 for (U32 pos=0; pos<length; ++pos)
2297 { 2298 {
2298 if (pos > 0) 2299 if (pos > 0)
2299 { 2300 {
2300 new_value.append(" "); 2301 new_value.append(" ");
2301 new_value.append(llformat(format_string, array[pos])); 2302 new_value.append(llformat(format_string.c_str(), array[pos]));
2302 } 2303 }
2303 else 2304 else
2304 { 2305 {
2305 new_value.assign(llformat(format_string, array[pos])); 2306 new_value.assign(llformat(format_string.c_str(), array[pos]));
2306 } 2307 }
2307 } 2308 }
2308 mValue = new_value; 2309 mValue = new_value;
@@ -2325,10 +2326,10 @@ void LLXMLNode::setDoubleValue(U32 length, const F64 *array, Encoding encoding,
2325} 2326}
2326 2327
2327// static 2328// static
2328LLString LLXMLNode::escapeXML(const LLString& xml) 2329std::string LLXMLNode::escapeXML(const std::string& xml)
2329{ 2330{
2330 LLString out; 2331 std::string out;
2331 for (LLString::size_type i = 0; i < xml.size(); ++i) 2332 for (std::string::size_type i = 0; i < xml.size(); ++i)
2332 { 2333 {
2333 char c = xml[i]; 2334 char c = xml[i];
2334 switch(c) 2335 switch(c)
@@ -2344,11 +2345,11 @@ LLString LLXMLNode::escapeXML(const LLString& xml)
2344 return out; 2345 return out;
2345} 2346}
2346 2347
2347void LLXMLNode::setStringValue(U32 length, const LLString *array) 2348void LLXMLNode::setStringValue(U32 length, const std::string *array)
2348{ 2349{
2349 if (length == 0) return; 2350 if (length == 0) return;
2350 2351
2351 LLString new_value; 2352 std::string new_value;
2352 for (U32 pos=0; pos<length; ++pos) 2353 for (U32 pos=0; pos<length; ++pos)
2353 { 2354 {
2354 new_value.append(escapeXML(array[pos])); 2355 new_value.append(escapeXML(array[pos]));
@@ -2365,7 +2366,7 @@ void LLXMLNode::setUUIDValue(U32 length, const LLUUID *array)
2365{ 2366{
2366 if (length == 0) return; 2367 if (length == 0) return;
2367 2368
2368 LLString new_value; 2369 std::string new_value;
2369 for (U32 pos=0; pos<length; ++pos) 2370 for (U32 pos=0; pos<length; ++pos)
2370 { 2371 {
2371 new_value.append(array[pos].asString()); 2372 new_value.append(array[pos].asString());
@@ -2382,7 +2383,7 @@ void LLXMLNode::setNodeRefValue(U32 length, const LLXMLNode **array)
2382{ 2383{
2383 if (length == 0) return; 2384 if (length == 0) return;
2384 2385
2385 LLString new_value; 2386 std::string new_value;
2386 for (U32 pos=0; pos<length; ++pos) 2387 for (U32 pos=0; pos<length; ++pos)
2387 { 2388 {
2388 if (array[pos]->mID != "") 2389 if (array[pos]->mID != "")
@@ -2402,7 +2403,7 @@ void LLXMLNode::setNodeRefValue(U32 length, const LLXMLNode **array)
2402 mType = TYPE_NODEREF; 2403 mType = TYPE_NODEREF;
2403} 2404}
2404 2405
2405void LLXMLNode::setValue(const LLString& value) 2406void LLXMLNode::setValue(const std::string& value)
2406{ 2407{
2407 if (TYPE_CONTAINER == mType) 2408 if (TYPE_CONTAINER == mType)
2408 { 2409 {
@@ -2439,7 +2440,7 @@ void LLXMLNode::findDefault(LLXMLNode *defaults_list)
2439 mDefault = NULL; 2440 mDefault = NULL;
2440} 2441}
2441 2442
2442BOOL LLXMLNode::deleteChildren(const LLString& name) 2443BOOL LLXMLNode::deleteChildren(const std::string& name)
2443{ 2444{
2444 U32 removed_count = 0; 2445 U32 removed_count = 0;
2445 LLXMLNodeList node_list; 2446 LLXMLNodeList node_list;
@@ -2491,7 +2492,7 @@ void LLXMLNode::setAttributes(LLXMLNode::ValueType type, U32 precision, LLXMLNod
2491 mLength = length; 2492 mLength = length;
2492} 2493}
2493 2494
2494void LLXMLNode::setName(const LLString& name) 2495void LLXMLNode::setName(const std::string& name)
2495{ 2496{
2496 setName(gStringTable.addStringEntry(name)); 2497 setName(gStringTable.addStringEntry(name));
2497} 2498}
@@ -2512,10 +2513,11 @@ void LLXMLNode::setName(LLStringTableEntry* name)
2512 } 2513 }
2513} 2514}
2514 2515
2515void LLXMLNode::appendValue(const LLString& value) 2516// Unused
2516{ 2517// void LLXMLNode::appendValue(const std::string& value)
2517 mValue.append(value); 2518// {
2518} 2519// mValue.append(value);
2520// }
2519 2521
2520U32 LLXMLNode::getChildCount() const 2522U32 LLXMLNode::getChildCount() const
2521{ 2523{
@@ -2565,14 +2567,13 @@ LLXMLNode *get_rand_node(LLXMLNode *node)
2565void LLXMLNode::createUnitTest(S32 max_num_children) 2567void LLXMLNode::createUnitTest(S32 max_num_children)
2566{ 2568{
2567 // Random ID 2569 // Random ID
2568 char rand_id[20]; /* Flawfinder: ignore */ 2570 std::string rand_id;
2569 U32 rand_id_len = get_rand(10)+5; 2571 U32 rand_id_len = get_rand(10)+5;
2570 U32 pos = 0; 2572 for (U32 pos = 0; pos<rand_id_len; ++pos)
2571 for (; pos<rand_id_len; ++pos)
2572 { 2573 {
2573 rand_id[pos] = get_rand(26)+'a'; 2574 char c = 'a' + get_rand(26);
2575 rand_id.append(1, c);
2574 } 2576 }
2575 rand_id[pos] = 0;
2576 mID = rand_id; 2577 mID = rand_id;
2577 2578
2578 if (max_num_children < 2) 2579 if (max_num_children < 2)
@@ -2594,26 +2595,24 @@ void LLXMLNode::createUnitTest(S32 max_num_children)
2594 for (U32 child_num=0; child_num<num_children; ++child_num) 2595 for (U32 child_num=0; child_num<num_children; ++child_num)
2595 { 2596 {
2596 // Random Name 2597 // Random Name
2597 char child_name[20]; /* Flawfinder: ignore */ 2598 std::string child_name;
2598 U32 child_name_len = get_rand(10)+5; 2599 U32 child_name_len = get_rand(10)+5;
2599 pos = 0; 2600 for (U32 pos = 0; pos<child_name_len; ++pos)
2600 for (; pos<child_name_len; ++pos)
2601 { 2601 {
2602 child_name[pos] = get_rand(26)+'a'; 2602 char c = 'a' + get_rand(26);
2603 child_name.append(1, c);
2603 } 2604 }
2604 child_name[pos] = 0;
2605 2605
2606 LLXMLNode *new_child = createChild(child_name, FALSE); 2606 LLXMLNode *new_child = createChild(child_name.c_str(), FALSE);
2607 2607
2608 // Random ID 2608 // Random ID
2609 char child_id[20]; /* Flawfinder: ignore */ 2609 std::string child_id;
2610 U32 child_id_len = get_rand(10)+5; 2610 U32 child_id_len = get_rand(10)+5;
2611 pos = 0; 2611 for (U32 pos=0; pos<child_id_len; ++pos)
2612 for (; pos<child_id_len; ++pos)
2613 { 2612 {
2614 child_id[pos] = get_rand(26)+'a'; 2613 char c = 'a' + get_rand(26);
2614 child_id.append(1, c);
2615 } 2615 }
2616 child_id[pos] = 0;
2617 new_child->mID = child_id; 2616 new_child->mID = child_id;
2618 2617
2619 // Random Length 2618 // Random Length
@@ -2747,7 +2746,7 @@ void LLXMLNode::createUnitTest(S32 max_num_children)
2747 createChild("float_checksum", TRUE)->setUnsignedValue(1, &float_checksum, LLXMLNode::ENCODING_HEX); 2746 createChild("float_checksum", TRUE)->setUnsignedValue(1, &float_checksum, LLXMLNode::ENCODING_HEX);
2748} 2747}
2749 2748
2750BOOL LLXMLNode::performUnitTest(LLString &error_buffer) 2749BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
2751{ 2750{
2752 if (!mChildren) 2751 if (!mChildren)
2753 { 2752 {
@@ -3021,10 +3020,10 @@ LLXMLNodePtr LLXMLNode::getNextSibling()
3021 return ret; 3020 return ret;
3022} 3021}
3023 3022
3024LLString LLXMLNode::getTextContents() const 3023std::string LLXMLNode::getTextContents() const
3025{ 3024{
3026 std::string msg; 3025 std::string msg;
3027 LLString contents = mValue; 3026 std::string contents = mValue;
3028 std::string::size_type n = contents.find_first_not_of(" \t\n"); 3027 std::string::size_type n = contents.find_first_not_of(" \t\n");
3029 if (n != std::string::npos && contents[n] == '\"') 3028 if (n != std::string::npos && contents[n] == '\"')
3030 { 3029 {
@@ -3068,10 +3067,10 @@ LLString LLXMLNode::getTextContents() const
3068 else 3067 else
3069 { 3068 {
3070 // Case 2: node has embedded text (beginning and trailing whitespace trimmed) 3069 // Case 2: node has embedded text (beginning and trailing whitespace trimmed)
3071 LLString::size_type start = mValue.find_first_not_of(" \t\n"); 3070 std::string::size_type start = mValue.find_first_not_of(" \t\n");
3072 if (start != mValue.npos) 3071 if (start != mValue.npos)
3073 { 3072 {
3074 LLString::size_type end = mValue.find_last_not_of(" \t\n"); 3073 std::string::size_type end = mValue.find_last_not_of(" \t\n");
3075 if (end != mValue.npos) 3074 if (end != mValue.npos)
3076 { 3075 {
3077 msg = mValue.substr(start, end+1-start); 3076 msg = mValue.substr(start, end+1-start);