summaryrefslogtreecommitdiff
path: root/indra/llxml
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llxml')
-rw-r--r--indra/llxml/llcontrol.cpp166
-rw-r--r--indra/llxml/llcontrol.h106
-rw-r--r--indra/llxml/llxmlnode.cpp476
-rw-r--r--indra/llxml/llxmlnode.h117
-rw-r--r--indra/llxml/llxmlparser.cpp14
-rw-r--r--indra/llxml/llxmlparser.h2
-rw-r--r--indra/llxml/llxmltree.cpp118
-rw-r--r--indra/llxml/llxmltree.h80
-rw-r--r--indra/llxml/tests/llcontrol_test.cpp6
9 files changed, 612 insertions, 473 deletions
diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp
index 5b6d197e52..bb590ebd76 100644
--- a/indra/llxml/llcontrol.cpp
+++ b/indra/llxml/llcontrol.cpp
@@ -59,8 +59,6 @@ template <> eControlType get_control_type<U32>();
template <> eControlType get_control_type<S32>();
template <> eControlType get_control_type<F32>();
template <> eControlType get_control_type<bool>();
-// Yay BOOL, its really an S32.
-//template <> eControlType get_control_type<BOOL> () ;
template <> eControlType get_control_type<std::string>();
template <> eControlType get_control_type<LLVector3>();
@@ -79,19 +77,19 @@ template <> LLSD convert_to_llsd<LLColor4>(const LLColor4& in);
template <> LLSD convert_to_llsd<LLColor3>(const LLColor3& in);
template <> LLSD convert_to_llsd<LLColor4U>(const LLColor4U& in);
-template <> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> LLColor4U convert_from_llsd<LLColor4U>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const std::string& control_name);
-template <> LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, const std::string& control_name);
+template <> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> LLColor4U convert_from_llsd<LLColor4U>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, std::string_view control_name);
+template <> LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, std::string_view control_name);
//this defines the current version of the settings file
const S32 CURRENT_VERSION = 101;
@@ -178,10 +176,10 @@ LLSD LLControlVariable::getComparableValue(const LLSD& value)
LLSD storable_value;
if(TYPE_BOOLEAN == type() && value.isString())
{
- BOOL temp;
+ bool temp;
if(LLStringUtil::convertToBOOL(value.asString(), temp))
{
- storable_value = (bool)temp;
+ storable_value = temp;
}
else
{
@@ -212,7 +210,7 @@ LLSD LLControlVariable::getComparableValue(const LLSD& value)
void LLControlVariable::setValue(const LLSD& new_value, bool saved_value)
{
- if (mValidateSignal(this, new_value) == false)
+ if (!mValidateSignal(this, new_value))
{
// can not set new value, exit
return;
@@ -220,12 +218,12 @@ void LLControlVariable::setValue(const LLSD& new_value, bool saved_value)
LLSD storable_value = getComparableValue(new_value);
LLSD original_value = getValue();
- bool value_changed = llsd_compare(original_value, storable_value) == FALSE;
+ bool value_changed = !llsd_compare(original_value, storable_value);
if(saved_value)
{
// If we're going to save this value, return to default but don't fire
resetToDefault(false);
- if (llsd_compare(mValues.back(), storable_value) == FALSE)
+ if (!llsd_compare(mValues.back(), storable_value))
{
mValues.push_back(storable_value);
}
@@ -235,7 +233,7 @@ void LLControlVariable::setValue(const LLSD& new_value, bool saved_value)
// This is an unsaved value. Its needs to reside at
// mValues[2] (or greater). It must not affect
// the result of getSaveValue()
- if (llsd_compare(mValues.back(), storable_value) == FALSE)
+ if (!llsd_compare(mValues.back(), storable_value))
{
while(mValues.size() > 2)
{
@@ -269,10 +267,10 @@ void LLControlVariable::setDefaultValue(const LLSD& value)
LLSD comparable_value = getComparableValue(value);
LLSD original_value = getValue();
- bool value_changed = (llsd_compare(original_value, comparable_value) == FALSE);
+ bool value_changed = !llsd_compare(original_value, comparable_value);
resetToDefault(false);
mValues[0] = comparable_value;
- if(value_changed)
+ if (value_changed)
{
firePropertyChanged(original_value);
}
@@ -343,7 +341,7 @@ LLSD LLControlVariable::getSaveValue() const
return mValues[0];
}
-LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name)
+LLPointer<LLControlVariable> LLControlGroup::getControl(std::string_view name)
{
if (mSettingsProfile)
{
@@ -465,7 +463,7 @@ std::string LLControlGroup::typeEnumToString(eControlType typeenum)
return mTypeString[typeenum];
}
-LLControlVariable* LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, LLControlVariable::ePersist persist, BOOL hidefromsettingseditor)
+LLControlVariable* LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, LLControlVariable::ePersist persist, bool hidefromsettingseditor)
{
LLControlVariable* existing_control = getControl(name);
if (existing_control)
@@ -508,7 +506,7 @@ LLControlVariable* LLControlGroup::declareF32(const std::string& name, const F32
return declareControl(name, TYPE_F32, initial_val, comment, persist);
}
-LLControlVariable* LLControlGroup::declareBOOL(const std::string& name, const BOOL initial_val, const std::string& comment, LLControlVariable::ePersist persist)
+LLControlVariable* LLControlGroup::declareBOOL(const std::string& name, const bool initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_BOOLEAN, initial_val, comment, persist);
}
@@ -553,46 +551,46 @@ LLControlVariable* LLControlGroup::declareLLSD(const std::string& name, const LL
return declareControl(name, TYPE_LLSD, initial_val, comment, persist);
}
-void LLControlGroup::incrCount(const std::string& name)
+void LLControlGroup::incrCount(std::string_view name)
{
if (0.0 == start_time)
{
start_time = LLTimer::getTotalSeconds();
}
- getCount[name] = getCount[name].asInteger() + 1;
+ getCount[name.data()] = getCount[name.data()].asInteger() + 1;
}
-BOOL LLControlGroup::getBOOL(const std::string& name)
+bool LLControlGroup::getBOOL(std::string_view name)
{
- return (BOOL)get<bool>(name);
+ return get<bool>(name);
}
-S32 LLControlGroup::getS32(const std::string& name)
+S32 LLControlGroup::getS32(std::string_view name)
{
return get<S32>(name);
}
-U32 LLControlGroup::getU32(const std::string& name)
+U32 LLControlGroup::getU32(std::string_view name)
{
return get<U32>(name);
}
-F32 LLControlGroup::getF32(const std::string& name)
+F32 LLControlGroup::getF32(std::string_view name)
{
return get<F32>(name);
}
-std::string LLControlGroup::getString(const std::string& name)
+std::string LLControlGroup::getString(std::string_view name)
{
return get<std::string>(name);
}
-LLWString LLControlGroup::getWString(const std::string& name)
+LLWString LLControlGroup::getWString(std::string_view name)
{
return get<LLWString>(name);
}
-std::string LLControlGroup::getText(const std::string& name)
+std::string LLControlGroup::getText(std::string_view name)
{
std::string utf8_string = getString(name);
LLStringUtil::replaceChar(utf8_string, '^', '\n');
@@ -600,43 +598,43 @@ std::string LLControlGroup::getText(const std::string& name)
return (utf8_string);
}
-LLVector3 LLControlGroup::getVector3(const std::string& name)
+LLVector3 LLControlGroup::getVector3(std::string_view name)
{
return get<LLVector3>(name);
}
-LLVector3d LLControlGroup::getVector3d(const std::string& name)
+LLVector3d LLControlGroup::getVector3d(std::string_view name)
{
return get<LLVector3d>(name);
}
-LLQuaternion LLControlGroup::getQuaternion(const std::string& name)
+LLQuaternion LLControlGroup::getQuaternion(std::string_view name)
{
return get<LLQuaternion>(name);
}
-LLRect LLControlGroup::getRect(const std::string& name)
+LLRect LLControlGroup::getRect(std::string_view name)
{
return get<LLRect>(name);
}
-LLColor4 LLControlGroup::getColor(const std::string& name)
+LLColor4 LLControlGroup::getColor(std::string_view name)
{
return get<LLColor4>(name);
}
-LLColor4 LLControlGroup::getColor4(const std::string& name)
+LLColor4 LLControlGroup::getColor4(std::string_view name)
{
return get<LLColor4>(name);
}
-LLColor3 LLControlGroup::getColor3(const std::string& name)
+LLColor3 LLControlGroup::getColor3(std::string_view name)
{
return get<LLColor3>(name);
}
-LLSD LLControlGroup::getLLSD(const std::string& name)
+LLSD LLControlGroup::getLLSD(std::string_view name)
{
return get<LLSD>(name);
}
@@ -659,7 +657,7 @@ LLSD LLControlGroup::asLLSD(bool diffs_only)
return result;
}
-BOOL LLControlGroup::controlExists(const std::string& name)
+bool LLControlGroup::controlExists(std::string_view name)
{
ctrl_name_table_t::iterator iter = mNameTable.find(name);
return iter != mNameTable.end();
@@ -670,67 +668,67 @@ BOOL LLControlGroup::controlExists(const std::string& name)
// Set functions
//-------------------------------------------------------------------
-void LLControlGroup::setBOOL(const std::string& name, BOOL val)
+void LLControlGroup::setBOOL(std::string_view name, bool val)
{
set<bool>(name, val);
}
-void LLControlGroup::setS32(const std::string& name, S32 val)
+void LLControlGroup::setS32(std::string_view name, S32 val)
{
set(name, val);
}
-void LLControlGroup::setF32(const std::string& name, F32 val)
+void LLControlGroup::setF32(std::string_view name, F32 val)
{
set(name, val);
}
-void LLControlGroup::setU32(const std::string& name, U32 val)
+void LLControlGroup::setU32(std::string_view name, U32 val)
{
set(name, val);
}
-void LLControlGroup::setString(const std::string& name, const std::string &val)
+void LLControlGroup::setString(std::string_view name, const std::string &val)
{
set(name, val);
}
-void LLControlGroup::setVector3(const std::string& name, const LLVector3 &val)
+void LLControlGroup::setVector3(std::string_view name, const LLVector3 &val)
{
set(name, val);
}
-void LLControlGroup::setVector3d(const std::string& name, const LLVector3d &val)
+void LLControlGroup::setVector3d(std::string_view name, const LLVector3d &val)
{
set(name, val);
}
-void LLControlGroup::setQuaternion(const std::string& name, const LLQuaternion &val)
+void LLControlGroup::setQuaternion(std::string_view name, const LLQuaternion &val)
{
set(name, val);
}
-void LLControlGroup::setRect(const std::string& name, const LLRect &val)
+void LLControlGroup::setRect(std::string_view name, const LLRect &val)
{
set(name, val);
}
-void LLControlGroup::setColor4(const std::string& name, const LLColor4 &val)
+void LLControlGroup::setColor4(std::string_view name, const LLColor4 &val)
{
set(name, val);
}
-void LLControlGroup::setLLSD(const std::string& name, const LLSD& val)
+void LLControlGroup::setLLSD(std::string_view name, const LLSD& val)
{
set(name, val);
}
-void LLControlGroup::setUntypedValue(const std::string& name, const LLSD& val)
+void LLControlGroup::setUntypedValue(std::string_view name, const LLSD& val)
{
if (name.empty())
{
@@ -755,7 +753,7 @@ void LLControlGroup::setUntypedValue(const std::string& name, const LLSD& val)
//---------------------------------------------------------------
// Returns number of controls loaded, so 0 if failure
-U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require_declaration, eControlType declare_as)
+U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, bool require_declaration, eControlType declare_as)
{
std::string name;
@@ -791,7 +789,7 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
{
name = child_nodep->getName();
- BOOL declared = controlExists(name);
+ bool declared = controlExists(name);
if (require_declaration && !declared)
{
@@ -859,7 +857,7 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
break;
case TYPE_BOOLEAN:
{
- BOOL initial = FALSE;
+ bool initial = false;
child_nodep->getAttributeBOOL("value", initial);
control->set(initial);
@@ -952,7 +950,7 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
return validitems;
}
-U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only)
+U32 LLControlGroup::saveToFile(const std::string& filename, bool nondefault_only)
{
LLSD settings;
int num_saved = 0;
@@ -1004,7 +1002,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
{
infile.close();
LL_WARNS("Settings") << "Unable to parse LLSD control file " << filename << ". Trying Legacy Method." << LL_ENDL;
- return loadFromFileLegacy(filename, TRUE, TYPE_STRING);
+ return loadFromFileLegacy(filename, true, TYPE_STRING);
}
U32 validitems = 0;
@@ -1162,7 +1160,7 @@ void main()
bar = new LLControlVariable<S32>("gBar", 10, 2, 22);
gGlobals.addEntry("gBar", bar);
- baz = new LLControlVariable<BOOL>("gBaz", FALSE);
+ baz = new LLControlVariable<bool>("gBaz", false);
gGlobals.addEntry("gBaz", baz);
// test retrieval
@@ -1190,7 +1188,7 @@ void main()
// ...invalid data type
getfoo = (F32_CONTROL) gGlobals.resolveName("gFoo");
- getfoo->set(TRUE);
+ getfoo->set(true);
getfoo->dump();
// ...out of range data
@@ -1224,13 +1222,7 @@ template <> eControlType get_control_type<bool> ()
{
return TYPE_BOOLEAN;
}
-/*
-// Yay BOOL, its really an S32.
-template <> eControlType get_control_type<BOOL> ()
-{
- return TYPE_BOOLEAN;
-}
-*/
+
template <> eControlType get_control_type<std::string>()
{
return TYPE_STRING;
@@ -1313,19 +1305,19 @@ template <> LLSD convert_to_llsd<LLColor4U>(const LLColor4U& in)
template<>
-bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::string& control_name)
+bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_BOOLEAN)
return sd.asBoolean();
else
{
- CONTROL_ERRS << "Invalid BOOL value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
- return FALSE;
+ CONTROL_ERRS << "Invalid bool value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
+ return false;
}
}
template<>
-S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string& control_name)
+S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_S32)
return sd.asInteger();
@@ -1337,7 +1329,7 @@ S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string&
}
template<>
-U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string& control_name)
+U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_U32)
return sd.asInteger();
@@ -1349,7 +1341,7 @@ U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string&
}
template<>
-F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string& control_name)
+F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_F32)
return (F32) sd.asReal();
@@ -1361,7 +1353,7 @@ F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string&
}
template<>
-std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, const std::string& control_name)
+std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_STRING)
return sd.asString();
@@ -1373,13 +1365,13 @@ std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, co
}
template<>
-LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, const std::string& control_name)
+LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, std::string_view control_name)
{
return utf8str_to_wstring(convert_from_llsd<std::string>(sd, type, control_name));
}
template<>
-LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const std::string& control_name)
+LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_VEC3)
return (LLVector3)sd;
@@ -1391,7 +1383,7 @@ LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const
}
template<>
-LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, const std::string& control_name)
+LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_VEC3D)
return (LLVector3d)sd;
@@ -1403,7 +1395,7 @@ LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, cons
}
template<>
-LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, const std::string& control_name)
+LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_QUAT)
return (LLQuaternion)sd;
@@ -1415,7 +1407,7 @@ LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type,
}
template<>
-LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name)
+LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_RECT)
return LLRect(sd);
@@ -1428,7 +1420,7 @@ LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::s
template<>
-LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const std::string& control_name)
+LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_COL4)
{
@@ -1460,7 +1452,7 @@ LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const st
}
template<>
-LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const std::string& control_name)
+LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, std::string_view control_name)
{
if (type == TYPE_COL3)
return sd;
@@ -1472,7 +1464,7 @@ LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const st
}
template<>
-LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, const std::string& control_name)
+LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, std::string_view control_name)
{
return sd;
}
@@ -1485,7 +1477,6 @@ DECL_LLCC(U32, (U32)666);
DECL_LLCC(S32, (S32)-666);
DECL_LLCC(F32, (F32)-666.666);
DECL_LLCC(bool, true);
-DECL_LLCC(BOOL, FALSE);
static LLCachedControl<std::string> mySetting_string("TestCachedControlstring", "Default String Value");
DECL_LLCC(LLVector3, LLVector3(1.0f, 2.0f, 3.0f));
DECL_LLCC(LLVector3d, LLVector3d(6.0f, 5.0f, 4.0f));
@@ -1504,7 +1495,6 @@ void test_cached_control()
TEST_LLCC(S32, (S32)-666);
TEST_LLCC(F32, (F32)-666.666);
TEST_LLCC(bool, true);
- TEST_LLCC(BOOL, FALSE);
if((std::string)mySetting_string != "Default String Value") LL_ERRS() << "Fail string" << LL_ENDL;
TEST_LLCC(LLVector3, LLVector3(1.0f, 2.0f, 3.0f));
TEST_LLCC(LLVector3d, LLVector3d(6.0f, 5.0f, 4.0f));
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index 37663a6fb2..344352e980 100644
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -144,7 +144,7 @@ public:
LLSD getSaveValue() const;
void set(const LLSD& val) { setValue(val); }
- void setValue(const LLSD& value, bool saved_value = TRUE);
+ void setValue(const LLSD& value, bool saved_value = true);
void setDefaultValue(const LLSD& value);
void setPersist(ePersist);
void setHiddenFromSettingsEditor(bool hide);
@@ -177,7 +177,7 @@ LLSD convert_to_llsd(const T& in)
}
template <class T>
-T convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name)
+T convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name)
{
// needs specialization
return T(sd);
@@ -189,7 +189,7 @@ class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string>
LOG_CLASS(LLControlGroup);
protected:
- typedef std::map<std::string, LLControlVariablePtr > ctrl_name_table_t;
+ typedef std::map<std::string, LLControlVariablePtr, std::less<> > ctrl_name_table_t;
ctrl_name_table_t mNameTable;
static const std::string mTypeString[TYPE_COUNT];
@@ -201,7 +201,7 @@ public:
~LLControlGroup();
void cleanup();
- LLControlVariablePtr getControl(const std::string& name);
+ LLControlVariablePtr getControl(std::string_view name);
struct ApplyFunctor
{
@@ -210,11 +210,11 @@ public:
};
void applyToAll(ApplyFunctor* func);
- LLControlVariable* declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, LLControlVariable::ePersist persist, BOOL hidefromsettingseditor = FALSE);
+ LLControlVariable* declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, LLControlVariable::ePersist persist, bool hidefromsettingseditor = false);
LLControlVariable* declareU32(const std::string& name, U32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareS32(const std::string& name, S32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareF32(const std::string& name, F32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
- LLControlVariable* declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareBOOL(const std::string& name, bool initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareString(const std::string& name, const std::string &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
@@ -224,28 +224,28 @@ public:
LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
- std::string getString(const std::string& name);
- std::string getText(const std::string& name);
- BOOL getBOOL(const std::string& name);
- S32 getS32(const std::string& name);
- F32 getF32(const std::string& name);
- U32 getU32(const std::string& name);
+ std::string getString(std::string_view name);
+ std::string getText(std::string_view name);
+ bool getBOOL(std::string_view name);
+ S32 getS32(std::string_view name);
+ F32 getF32(std::string_view name);
+ U32 getU32(std::string_view name);
- LLWString getWString(const std::string& name);
- LLVector3 getVector3(const std::string& name);
- LLVector3d getVector3d(const std::string& name);
- LLRect getRect(const std::string& name);
- LLSD getLLSD(const std::string& name);
- LLQuaternion getQuaternion(const std::string& name);
+ LLWString getWString(std::string_view name);
+ LLVector3 getVector3(std::string_view name);
+ LLVector3d getVector3d(std::string_view name);
+ LLRect getRect(std::string_view name);
+ LLSD getLLSD(std::string_view name);
+ LLQuaternion getQuaternion(std::string_view name);
- LLColor4 getColor(const std::string& name);
- LLColor4 getColor4(const std::string& name);
- LLColor3 getColor3(const std::string& name);
+ LLColor4 getColor(std::string_view name);
+ LLColor4 getColor4(std::string_view name);
+ LLColor3 getColor3(std::string_view name);
LLSD asLLSD(bool diffs_only);
// generic getter
- template<typename T> T get(const std::string& name)
+ template<typename T> T get(std::string_view name)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD;
LLControlVariable* control = getControl(name);
@@ -265,23 +265,23 @@ public:
return convert_from_llsd<T>(value, type, name);
}
- void setBOOL(const std::string& name, BOOL val);
- void setS32(const std::string& name, S32 val);
- void setF32(const std::string& name, F32 val);
- void setU32(const std::string& name, U32 val);
- void setString(const std::string& name, const std::string& val);
- void setVector3(const std::string& name, const LLVector3 &val);
- void setVector3d(const std::string& name, const LLVector3d &val);
- void setQuaternion(const std::string& name, const LLQuaternion &val);
- void setRect(const std::string& name, const LLRect &val);
- void setColor4(const std::string& name, const LLColor4 &val);
- void setLLSD(const std::string& name, const LLSD& val);
+ void setBOOL(std::string_view name, bool val);
+ void setS32(std::string_view name, S32 val);
+ void setF32(std::string_view name, F32 val);
+ void setU32(std::string_view name, U32 val);
+ void setString(std::string_view name, const std::string& val);
+ void setVector3(std::string_view name, const LLVector3 &val);
+ void setVector3d(std::string_view name, const LLVector3d &val);
+ void setQuaternion(std::string_view name, const LLQuaternion &val);
+ void setRect(std::string_view name, const LLRect &val);
+ void setColor4(std::string_view name, const LLColor4 &val);
+ void setLLSD(std::string_view name, const LLSD& val);
// type agnostic setter that takes LLSD
- void setUntypedValue(const std::string& name, const LLSD& val);
+ void setUntypedValue(std::string_view name, const LLSD& val);
// generic setter
- template<typename T> void set(const std::string& name, const T& val)
+ template<typename T> void set(std::string_view name, const T& val)
{
LLControlVariable* control = getControl(name);
@@ -295,16 +295,16 @@ public:
}
}
- BOOL controlExists(const std::string& name);
+ bool controlExists(std::string_view name);
// Returns number of controls loaded, 0 if failed
// If require_declaration is false, will auto-declare controls it finds
// as the given type.
- U32 loadFromFileLegacy(const std::string& filename, BOOL require_declaration = TRUE, eControlType declare_as = TYPE_STRING);
- U32 saveToFile(const std::string& filename, BOOL nondefault_only);
+ U32 loadFromFileLegacy(const std::string& filename, bool require_declaration = true, eControlType declare_as = TYPE_STRING);
+ U32 saveToFile(const std::string& filename, bool nondefault_only);
U32 loadFromFile(const std::string& filename, bool default_values = false, bool save_values = true);
void resetToDefaults();
- void incrCount(const std::string& name);
+ void incrCount(std::string_view name);
bool mSettingsProfile;
};
@@ -435,8 +435,6 @@ template <> eControlType get_control_type<U32>();
template <> eControlType get_control_type<S32>();
template <> eControlType get_control_type<F32>();
template <> eControlType get_control_type<bool>();
-// Yay BOOL, its really an S32.
-//template <> eControlType get_control_type<BOOL> ()
template <> eControlType get_control_type<std::string>();
template <> eControlType get_control_type<LLVector3>();
template <> eControlType get_control_type<LLVector3d>();
@@ -454,19 +452,19 @@ template <> LLSD convert_to_llsd<LLRect>(const LLRect& in);
template <> LLSD convert_to_llsd<LLColor4>(const LLColor4& in);
template <> LLSD convert_to_llsd<LLColor3>(const LLColor3& in);
-template<> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const std::string& control_name);
-template<> LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, const std::string& control_name);
+template<> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, std::string_view control_name);
+template<> LLSD convert_from_llsd<LLSD>(const LLSD& sd, eControlType type, std::string_view control_name);
//#define TEST_CACHED_CONTROL 1
#ifdef TEST_CACHED_CONTROL
diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp
index 2298dc22e7..e695035461 100644
--- a/indra/llxml/llxmlnode.cpp
+++ b/indra/llxml/llxmlnode.cpp
@@ -38,19 +38,21 @@
#include "v3math.h"
#include "v3dmath.h"
#include "v4math.h"
+#include "llbase64.h"
#include "llquaternion.h"
+#include "llsd.h"
#include "llstring.h"
#include "lluuid.h"
#include "lldir.h"
// static
-BOOL LLXMLNode::sStripEscapedStrings = TRUE;
-BOOL LLXMLNode::sStripWhitespaceValues = FALSE;
+bool LLXMLNode::sStripEscapedStrings = true;
+bool LLXMLNode::sStripWhitespaceValues = false;
LLXMLNode::LLXMLNode() :
mID(""),
mParser(NULL),
- mIsAttribute(FALSE),
+ mIsAttribute(false),
mVersionMajor(0),
mVersionMinor(0),
mLength(0),
@@ -69,7 +71,7 @@ LLXMLNode::LLXMLNode() :
{
}
-LLXMLNode::LLXMLNode(const char* name, BOOL is_attribute) :
+LLXMLNode::LLXMLNode(const char* name, bool is_attribute) :
mID(""),
mParser(NULL),
mIsAttribute(is_attribute),
@@ -91,7 +93,7 @@ LLXMLNode::LLXMLNode(const char* name, BOOL is_attribute) :
mName = gStringTable.addStringEntry(name);
}
-LLXMLNode::LLXMLNode(LLStringTableEntry* name, BOOL is_attribute) :
+LLXMLNode::LLXMLNode(LLStringTableEntry* name, bool is_attribute) :
mID(""),
mParser(NULL),
mIsAttribute(is_attribute),
@@ -193,17 +195,17 @@ LLXMLNode::~LLXMLNode()
mDefault = NULL;
}
-BOOL LLXMLNode::isNull()
+bool LLXMLNode::isNull()
{
return (mName == NULL);
}
// protected
-BOOL LLXMLNode::removeChild(LLXMLNode *target_child)
+bool LLXMLNode::removeChild(LLXMLNode *target_child)
{
if (!target_child)
{
- return FALSE;
+ return false;
}
if (target_child->mIsAttribute)
{
@@ -212,7 +214,7 @@ BOOL LLXMLNode::removeChild(LLXMLNode *target_child)
{
target_child->mParent = NULL;
mAttributes.erase(children_itr);
- return TRUE;
+ return true;
}
}
else if (mChildren.notNull())
@@ -244,7 +246,7 @@ BOOL LLXMLNode::removeChild(LLXMLNode *target_child)
{
mChildren = NULL;
}
- return TRUE;
+ return true;
}
else if (children_itr->first != target_child->mName)
{
@@ -256,7 +258,7 @@ BOOL LLXMLNode::removeChild(LLXMLNode *target_child)
}
}
}
- return FALSE;
+ return false;
}
void LLXMLNode::addChild(LLXMLNodePtr& new_child)
@@ -302,13 +304,13 @@ void LLXMLNode::addChild(LLXMLNodePtr& new_child)
}
// virtual
-LLXMLNodePtr LLXMLNode::createChild(const char* name, BOOL is_attribute)
+LLXMLNodePtr LLXMLNode::createChild(const char* name, bool is_attribute)
{
return createChild(gStringTable.addStringEntry(name), is_attribute);
}
// virtual
-LLXMLNodePtr LLXMLNode::createChild(LLStringTableEntry* name, BOOL is_attribute)
+LLXMLNodePtr LLXMLNode::createChild(LLStringTableEntry* name, bool is_attribute)
{
LLXMLNodePtr ret(new LLXMLNode(name, is_attribute));
ret->mID.clear();
@@ -317,13 +319,13 @@ LLXMLNodePtr LLXMLNode::createChild(LLStringTableEntry* name, BOOL is_attribute)
return ret;
}
-BOOL LLXMLNode::deleteChild(LLXMLNode *child)
+bool LLXMLNode::deleteChild(LLXMLNode *child)
{
if (removeChild(child))
{
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void LLXMLNode::setParent(LLXMLNodePtr& new_parent)
@@ -375,7 +377,7 @@ void XMLCALL StartXMLNode(void *userData,
const XML_Char **atts)
{
// Create a new node
- LLXMLNode *new_node_ptr = new LLXMLNode(name, FALSE);
+ LLXMLNode *new_node_ptr = new LLXMLNode(name, false);
LLXMLNodePtr new_node = new_node_ptr;
new_node->mID.clear();
@@ -480,9 +482,9 @@ void XMLCALL StartXMLNode(void *userData,
// only one attribute child per description
LLXMLNodePtr attr_node;
- if (!new_node->getAttribute(attr_name.c_str(), attr_node, FALSE))
+ if (!new_node->getAttribute(attr_name.c_str(), attr_node, false))
{
- attr_node = new LLXMLNode(attr_name.c_str(), TRUE);
+ attr_node = new LLXMLNode(attr_name.c_str(), true);
attr_node->setLineNumber(XML_GetCurrentLineNumber(*new_node_ptr->mParser));
}
attr_node->setValue(attr_value);
@@ -508,13 +510,13 @@ void XMLCALL EndXMLNode(void *userData,
if (LLXMLNode::sStripWhitespaceValues)
{
std::string value = node->getValue();
- BOOL is_empty = TRUE;
+ bool is_empty = true;
for (std::string::size_type s = 0; s < value.length(); s++)
{
char c = value[s];
if (c != ' ' && c != '\t' && c != '\n')
{
- is_empty = FALSE;
+ is_empty = false;
break;
}
}
@@ -575,7 +577,7 @@ bool LLXMLNode::updateNode(
if (!node || !update_node)
{
LL_WARNS() << "Node invalid" << LL_ENDL;
- return FALSE;
+ return false;
}
//update the node value
@@ -647,38 +649,30 @@ bool LLXMLNode::updateNode(
}
}
- return TRUE;
+ return true;
}
// static
bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXMLNode* defaults_tree)
{
- // Read file
- LL_DEBUGS("XMLNode") << "parsing XML file: " << filename << LL_ENDL;
- LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
- if (fp == NULL)
+ std::string xml = LLFile::getContents(filename);
+ if (xml.empty())
{
- node = NULL ;
- return false;
+ LL_WARNS("XMLNode") << "no XML file: " << filename << LL_ENDL;
+ }
+ else if (parseBuffer(xml.data(), xml.size(), node, defaults_tree))
+ {
+ return true;
}
- fseek(fp, 0, SEEK_END);
- U32 length = ftell(fp);
- fseek(fp, 0, SEEK_SET);
-
- U8* buffer = new U8[length+1];
- size_t nread = fread(buffer, 1, length, fp);
- buffer[nread] = 0;
- fclose(fp);
- bool rv = parseBuffer(buffer, nread, node, defaults_tree);
- delete [] buffer;
- return rv;
+ node = nullptr;
+ return false;
}
// static
bool LLXMLNode::parseBuffer(
- U8* buffer,
- U32 length,
+ const char* buffer,
+ U64 length,
LLXMLNodePtr& node,
LLXMLNode* defaults)
{
@@ -688,25 +682,30 @@ bool LLXMLNode::parseBuffer(
XML_SetCharacterDataHandler(my_parser, XMLData);
// Create a root node
- LLXMLNode *file_node_ptr = new LLXMLNode("XML", FALSE);
+ 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);
+ XML_SetUserData(my_parser, file_node_ptr);
// Do the parsing
- if (XML_Parse(my_parser, (const char *)buffer, length, TRUE) != XML_STATUS_OK)
+ bool success = XML_STATUS_OK == XML_Parse(my_parser, buffer, (int)length, true);
+ if (!success)
{
LL_WARNS() << "Error parsing xml error code: "
<< XML_ErrorString(XML_GetErrorCode(my_parser))
<< " on line " << XML_GetCurrentLineNumber(my_parser)
+ << ", column " << XML_GetCurrentColumnNumber(my_parser)
<< LL_ENDL;
}
// Deinit
XML_ParserFree(my_parser);
+ if (!success)
+ return false;
+
if (!file_node->mChildren || file_node->mChildren->map.size() != 1)
{
LL_WARNS() << "Parse failure - wrong number of top-level nodes xml."
@@ -736,7 +735,7 @@ bool LLXMLNode::parseStream(
XML_SetCharacterDataHandler(my_parser, XMLData);
// Create a root node
- LLXMLNode *file_node_ptr = new LLXMLNode("XML", FALSE);
+ LLXMLNode *file_node_ptr = new LLXMLNode("XML", false);
LLXMLNodePtr file_node = file_node_ptr;
file_node->mParser = &my_parser;
@@ -784,18 +783,18 @@ bool LLXMLNode::parseStream(
}
-BOOL LLXMLNode::isFullyDefault()
+bool LLXMLNode::isFullyDefault()
{
if (mDefault.isNull())
{
- return FALSE;
+ return false;
}
- BOOL has_default_value = (mValue == mDefault->mValue);
- BOOL has_default_attribute = (mIsAttribute == mDefault->mIsAttribute);
- BOOL has_default_type = mIsAttribute || (mType == mDefault->mType);
- BOOL has_default_encoding = mIsAttribute || (mEncoding == mDefault->mEncoding);
- BOOL has_default_precision = mIsAttribute || (mPrecision == mDefault->mPrecision);
- BOOL has_default_length = mIsAttribute || (mLength == mDefault->mLength);
+ bool has_default_value = (mValue == mDefault->mValue);
+ bool has_default_attribute = (mIsAttribute == mDefault->mIsAttribute);
+ bool has_default_type = mIsAttribute || (mType == mDefault->mType);
+ bool has_default_encoding = mIsAttribute || (mEncoding == mDefault->mEncoding);
+ bool has_default_precision = mIsAttribute || (mPrecision == mDefault->mPrecision);
+ bool has_default_length = mIsAttribute || (mLength == mDefault->mLength);
if (has_default_value
&& has_default_type
@@ -813,14 +812,14 @@ BOOL LLXMLNode::isFullyDefault()
LLXMLNodePtr child = (*children_itr).second;
if (!child->isFullyDefault())
{
- return FALSE;
+ return false;
}
}
}
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
// static
@@ -908,10 +907,10 @@ void LLXMLNode::writeToOstream(std::ostream& output_stream, const std::string& i
return;
}
- BOOL has_default_type = mDefault.isNull()?FALSE:(mType == mDefault->mType);
- BOOL has_default_encoding = mDefault.isNull()?FALSE:(mEncoding == mDefault->mEncoding);
- BOOL has_default_precision = mDefault.isNull()?FALSE:(mPrecision == mDefault->mPrecision);
- BOOL has_default_length = mDefault.isNull()?FALSE:(mLength == mDefault->mLength);
+ bool has_default_type = mDefault.isNull()?false:(mType == mDefault->mType);
+ bool has_default_encoding = mDefault.isNull()?false:(mEncoding == mDefault->mEncoding);
+ bool has_default_precision = mDefault.isNull()?false:(mPrecision == mDefault->mPrecision);
+ bool has_default_length = mDefault.isNull()?false:(mLength == mDefault->mLength);
// stream the name
output_stream << indent << "<" << mName->mString << "\n";
@@ -1153,12 +1152,12 @@ void LLXMLNode::scrubToTree(LLXMLNode *tree)
}
}
-bool LLXMLNode::getChild(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing)
+bool LLXMLNode::getChild(const char* name, LLXMLNodePtr& node, bool use_default_if_missing)
{
return getChild(gStringTable.checkStringEntry(name), node, use_default_if_missing);
}
-bool LLXMLNode::getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing)
+bool LLXMLNode::getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, bool use_default_if_missing)
{
if (mChildren.notNull())
{
@@ -1171,18 +1170,18 @@ bool LLXMLNode::getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOO
}
if (use_default_if_missing && !mDefault.isNull())
{
- return mDefault->getChild(name, node, FALSE);
+ return mDefault->getChild(name, node, false);
}
node = NULL;
return false;
}
-void LLXMLNode::getChildren(const char* name, LLXMLNodeList &children, BOOL use_default_if_missing) const
+void LLXMLNode::getChildren(const char* name, LLXMLNodeList &children, bool use_default_if_missing) const
{
getChildren(gStringTable.checkStringEntry(name), children, use_default_if_missing);
}
-void LLXMLNode::getChildren(const LLStringTableEntry* name, LLXMLNodeList &children, BOOL use_default_if_missing) const
+void LLXMLNode::getChildren(const LLStringTableEntry* name, LLXMLNodeList &children, bool use_default_if_missing) const
{
if (mChildren.notNull())
{
@@ -1204,7 +1203,7 @@ void LLXMLNode::getChildren(const LLStringTableEntry* name, LLXMLNodeList &child
}
if (children.size() == 0 && use_default_if_missing && !mDefault.isNull())
{
- mDefault->getChildren(name, children, FALSE);
+ mDefault->getChildren(name, children, false);
}
}
@@ -1227,12 +1226,12 @@ void LLXMLNode::getDescendants(const LLStringTableEntry* name, LLXMLNodeList &ch
}
}
-bool LLXMLNode::getAttribute(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing)
+bool LLXMLNode::getAttribute(const char* name, LLXMLNodePtr& node, bool use_default_if_missing)
{
return getAttribute(gStringTable.checkStringEntry(name), node, use_default_if_missing);
}
-bool LLXMLNode::getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing)
+bool LLXMLNode::getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node, bool use_default_if_missing)
{
LLXMLAttribList::const_iterator child_itr = mAttributes.find(name);
if (child_itr != mAttributes.end())
@@ -1242,7 +1241,7 @@ bool LLXMLNode::getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node,
}
if (use_default_if_missing && !mDefault.isNull())
{
- return mDefault->getAttribute(name, node, FALSE);
+ return mDefault->getAttribute(name, node, false);
}
return false;
@@ -1261,42 +1260,25 @@ bool LLXMLNode::setAttributeString(const char* attr, const std::string& value)
return false;
}
-BOOL LLXMLNode::hasAttribute(const char* name )
+bool LLXMLNode::hasAttribute(const char* name )
{
LLXMLNodePtr node;
return getAttribute(name, node);
}
-// the structure of these getAttribute_ functions is ugly, but it's because the
-// underlying system is based on BOOL and LLString; if we change
-// so that they're based on more generic mechanisms, these will be
-// simplified.
-bool LLXMLNode::getAttribute_bool(const char* name, bool& value )
-{
- LLXMLNodePtr node;
- if (!getAttribute(name, node))
- {
- return false;
- }
- BOOL temp;
- bool retval = node->getBoolValue(1, &temp);
- value = temp;
- return retval;
-}
-
-BOOL LLXMLNode::getAttributeBOOL(const char* name, BOOL& value )
+bool LLXMLNode::getAttributeBOOL(const char* name, bool& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getBoolValue(1, &value));
}
-BOOL LLXMLNode::getAttributeU8(const char* name, U8& value )
+bool LLXMLNode::getAttributeU8(const char* name, U8& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getByteValue(1, &value));
}
-BOOL LLXMLNode::getAttributeS8(const char* name, S8& value )
+bool LLXMLNode::getAttributeS8(const char* name, S8& value )
{
LLXMLNodePtr node;
S32 val;
@@ -1308,7 +1290,7 @@ BOOL LLXMLNode::getAttributeS8(const char* name, S8& value )
return true;
}
-BOOL LLXMLNode::getAttributeU16(const char* name, U16& value )
+bool LLXMLNode::getAttributeU16(const char* name, U16& value )
{
LLXMLNodePtr node;
U32 val;
@@ -1320,7 +1302,7 @@ BOOL LLXMLNode::getAttributeU16(const char* name, U16& value )
return true;
}
-BOOL LLXMLNode::getAttributeS16(const char* name, S16& value )
+bool LLXMLNode::getAttributeS16(const char* name, S16& value )
{
LLXMLNodePtr node;
S32 val;
@@ -1332,73 +1314,73 @@ BOOL LLXMLNode::getAttributeS16(const char* name, S16& value )
return true;
}
-BOOL LLXMLNode::getAttributeU32(const char* name, U32& value )
+bool LLXMLNode::getAttributeU32(const char* name, U32& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getUnsignedValue(1, &value));
}
-BOOL LLXMLNode::getAttributeS32(const char* name, S32& value )
+bool LLXMLNode::getAttributeS32(const char* name, S32& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getIntValue(1, &value));
}
-BOOL LLXMLNode::getAttributeF32(const char* name, F32& value )
+bool LLXMLNode::getAttributeF32(const char* name, F32& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getFloatValue(1, &value));
}
-BOOL LLXMLNode::getAttributeF64(const char* name, F64& value )
+bool LLXMLNode::getAttributeF64(const char* name, F64& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getDoubleValue(1, &value));
}
-BOOL LLXMLNode::getAttributeColor(const char* name, LLColor4& value )
+bool LLXMLNode::getAttributeColor(const char* name, LLColor4& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getFloatValue(4, value.mV));
}
-BOOL LLXMLNode::getAttributeColor4(const char* name, LLColor4& value )
+bool LLXMLNode::getAttributeColor4(const char* name, LLColor4& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getFloatValue(4, value.mV));
}
-BOOL LLXMLNode::getAttributeColor4U(const char* name, LLColor4U& value )
+bool LLXMLNode::getAttributeColor4U(const char* name, LLColor4U& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getByteValue(4, value.mV));
}
-BOOL LLXMLNode::getAttributeVector3(const char* name, LLVector3& value )
+bool LLXMLNode::getAttributeVector3(const char* name, LLVector3& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getFloatValue(3, value.mV));
}
-BOOL LLXMLNode::getAttributeVector3d(const char* name, LLVector3d& value )
+bool LLXMLNode::getAttributeVector3d(const char* name, LLVector3d& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getDoubleValue(3, value.mdV));
}
-BOOL LLXMLNode::getAttributeQuat(const char* name, LLQuaternion& value )
+bool LLXMLNode::getAttributeQuat(const char* name, LLQuaternion& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getFloatValue(4, value.mQ));
}
-BOOL LLXMLNode::getAttributeUUID(const char* name, LLUUID& value )
+bool LLXMLNode::getAttributeUUID(const char* name, LLUUID& value )
{
LLXMLNodePtr node;
return (getAttribute(name, node) && node->getUUIDValue(1, &value));
}
-BOOL LLXMLNode::getAttributeString(const char* name, std::string& value )
+bool LLXMLNode::getAttributeString(const char* name, std::string& value )
{
LLXMLNodePtr node;
if (!getAttribute(name, node))
@@ -1435,10 +1417,10 @@ const char *LLXMLNode::skipNonWhitespace(const char *str)
}
/*static */
-const char *LLXMLNode::parseInteger(const char *str, U64 *dest, BOOL *is_negative, U32 precision, Encoding encoding)
+const char *LLXMLNode::parseInteger(const char *str, U64 *dest, bool *is_negative, U32 precision, Encoding encoding)
{
*dest = 0;
- *is_negative = FALSE;
+ *is_negative = false;
str = skipWhitespace(str);
@@ -1452,7 +1434,7 @@ const char *LLXMLNode::parseInteger(const char *str, U64 *dest, BOOL *is_negativ
}
if (str[0] == '-')
{
- *is_negative = TRUE;
+ *is_negative = true;
++str;
}
@@ -1653,7 +1635,7 @@ const char *LLXMLNode::parseFloat(const char *str, F64 *dest, U32 precision, Enc
// Scientific notation!
++str;
U64 exp;
- BOOL is_negative;
+ bool is_negative;
str = parseInteger(str, &exp, &is_negative, 64, ENCODING_DECIMAL);
if (str == NULL)
{
@@ -1677,7 +1659,7 @@ const char *LLXMLNode::parseFloat(const char *str, F64 *dest, U32 precision, Enc
if (encoding == ENCODING_HEX)
{
U64 bytes_dest;
- BOOL is_negative;
+ bool is_negative;
str = parseInteger(str, (U64 *)&bytes_dest, &is_negative, precision, ENCODING_HEX);
// Upcast to F64
switch (precision)
@@ -1700,7 +1682,7 @@ const char *LLXMLNode::parseFloat(const char *str, F64 *dest, U32 precision, Enc
return NULL;
}
-U32 LLXMLNode::getBoolValue(U32 expected_length, BOOL *array)
+U32 LLXMLNode::getBoolValue(U32 expected_length, bool *array)
{
llassert(array);
@@ -1720,11 +1702,11 @@ U32 LLXMLNode::getBoolValue(U32 expected_length, BOOL *array)
LLStringUtil::toLower(str_array[i]);
if (str_array[i] == "false")
{
- array[ret_length++] = FALSE;
+ array[ret_length++] = false;
}
else if (str_array[i] == "true")
{
- array[ret_length++] = TRUE;
+ array[ret_length++] = true;
}
}
@@ -1770,7 +1752,7 @@ U32 LLXMLNode::getByteValue(U32 expected_length, U8 *array, Encoding encoding)
for (i=0; i<expected_length; ++i)
{
U64 value;
- BOOL is_negative;
+ bool is_negative;
value_string = parseInteger(value_string, &value, &is_negative, 8, encoding);
if (value_string == NULL)
{
@@ -1822,7 +1804,7 @@ U32 LLXMLNode::getIntValue(U32 expected_length, S32 *array, Encoding encoding)
for (i=0; i<expected_length; ++i)
{
U64 value;
- BOOL is_negative;
+ bool is_negative;
value_string = parseInteger(value_string, &value, &is_negative, 32, encoding);
if (value_string == NULL)
{
@@ -1876,7 +1858,7 @@ U32 LLXMLNode::getUnsignedValue(U32 expected_length, U32 *array, Encoding encodi
for (i=0; i<expected_length; ++i)
{
U64 value;
- BOOL is_negative;
+ bool is_negative;
value_string = parseInteger(value_string, &value, &is_negative, 32, encoding);
if (value_string == NULL)
{
@@ -1930,7 +1912,7 @@ U32 LLXMLNode::getLongValue(U32 expected_length, U64 *array, Encoding encoding)
for (i=0; i<expected_length; ++i)
{
U64 value;
- BOOL is_negative;
+ bool is_negative;
value_string = parseInteger(value_string, &value, &is_negative, 64, encoding);
if (value_string == NULL)
{
@@ -2185,7 +2167,7 @@ U32 LLXMLNode::getNodeRefValue(U32 expected_length, LLXMLNode **array)
return num_returned_refs;
}
-void LLXMLNode::setBoolValue(U32 length, const BOOL *array)
+void LLXMLNode::setBoolValue(U32 length, const bool *array)
{
if (length == 0) return;
@@ -2614,7 +2596,7 @@ void LLXMLNode::findDefault(LLXMLNode *defaults_list)
mDefault = NULL;
}
-BOOL LLXMLNode::deleteChildren(const std::string& name)
+bool LLXMLNode::deleteChildren(const std::string& name)
{
U32 removed_count = 0;
LLXMLNodeList node_list;
@@ -2633,10 +2615,10 @@ BOOL LLXMLNode::deleteChildren(const std::string& name)
}
}
}
- return removed_count > 0 ? TRUE : FALSE;
+ return removed_count > 0;
}
-BOOL LLXMLNode::deleteChildren(LLStringTableEntry* name)
+bool LLXMLNode::deleteChildren(LLStringTableEntry* name)
{
U32 removed_count = 0;
LLXMLNodeList node_list;
@@ -2655,7 +2637,7 @@ BOOL LLXMLNode::deleteChildren(LLStringTableEntry* name)
}
}
}
- return removed_count > 0 ? TRUE : FALSE;
+ return removed_count > 0;
}
void LLXMLNode::setAttributes(LLXMLNode::ValueType type, U32 precision, LLXMLNode::Encoding encoding, U32 length)
@@ -2698,7 +2680,7 @@ U32 LLXMLNode::getChildCount() const
{
if (mChildren.notNull())
{
- return mChildren->map.size();
+ return static_cast<U32>(mChildren->map.size());
}
return 0;
}
@@ -2717,7 +2699,7 @@ LLXMLNode *get_rand_node(LLXMLNode *node)
{
if (node->mChildren.notNull())
{
- U32 num_children = node->mChildren->map.size();
+ U32 num_children = static_cast<U32>(node->mChildren->map.size());
if (get_rand(2) == 0)
{
while (true)
@@ -2778,7 +2760,7 @@ void LLXMLNode::createUnitTest(S32 max_num_children)
child_name.append(1, c);
}
- LLXMLNode *new_child = createChild(child_name.c_str(), FALSE);
+ LLXMLNode *new_child = createChild(child_name.c_str(), false);
// Random ID
std::string child_id;
@@ -2805,7 +2787,7 @@ void LLXMLNode::createUnitTest(S32 max_num_children)
break;
case 1: // TYPE_BOOLEAN
{
- BOOL random_bool_values[30];
+ bool random_bool_values[30];
for (U32 value=0; value<array_size; ++value)
{
random_bool_values[value] = get_rand(2);
@@ -2913,20 +2895,20 @@ void LLXMLNode::createUnitTest(S32 max_num_children)
}
}
- createChild("integer_checksum", TRUE)->setUnsignedValue(1, &integer_checksum, LLXMLNode::ENCODING_HEX);
- createChild("long_checksum", TRUE)->setLongValue(1, &long_checksum, LLXMLNode::ENCODING_HEX);
- createChild("bool_true_count", TRUE)->setUnsignedValue(1, &bool_true_count, LLXMLNode::ENCODING_HEX);
- createChild("uuid_checksum", TRUE)->setUUIDValue(1, &uuid_checksum);
- createChild("noderef_checksum", TRUE)->setUnsignedValue(1, &noderef_checksum, LLXMLNode::ENCODING_HEX);
- createChild("float_checksum", TRUE)->setUnsignedValue(1, &float_checksum, LLXMLNode::ENCODING_HEX);
+ createChild("integer_checksum", true)->setUnsignedValue(1, &integer_checksum, LLXMLNode::ENCODING_HEX);
+ createChild("long_checksum", true)->setLongValue(1, &long_checksum, LLXMLNode::ENCODING_HEX);
+ createChild("bool_true_count", true)->setUnsignedValue(1, &bool_true_count, LLXMLNode::ENCODING_HEX);
+ createChild("uuid_checksum", true)->setUUIDValue(1, &uuid_checksum);
+ createChild("noderef_checksum", true)->setUnsignedValue(1, &noderef_checksum, LLXMLNode::ENCODING_HEX);
+ createChild("float_checksum", true)->setUnsignedValue(1, &float_checksum, LLXMLNode::ENCODING_HEX);
}
-BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
+bool LLXMLNode::performUnitTest(std::string &error_buffer)
{
if (mChildren.isNull())
{
error_buffer.append(llformat("ERROR Node %s: No children found.\n", mName->mString));
- return FALSE;
+ return false;
}
// Checksums
@@ -2950,14 +2932,14 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
if (!node->performUnitTest(error_buffer))
{
error_buffer.append(llformat("Child test failed for %s.\n", mName->mString));
- //return FALSE;
+ //return false;
}
continue;
}
if (node->mLength < 1 || node->mLength > 30)
{
error_buffer.append(llformat("ERROR Node %s: Invalid array length %d, child %s.\n", mName->mString, node->mLength, node->mName->mString));
- return FALSE;
+ return false;
}
switch (node->mType)
{
@@ -2966,11 +2948,11 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
break;
case TYPE_BOOLEAN:
{
- BOOL bool_array[30];
+ bool bool_array[30];
if (node->getBoolValue(node->mLength, bool_array) < node->mLength)
{
error_buffer.append(llformat("ERROR Node %s: Could not read boolean array, child %s.\n", mName->mString, node->mName->mString));
- return FALSE;
+ return false;
}
for (U32 pos=0; pos<(U32)node->mLength; ++pos)
{
@@ -2989,7 +2971,7 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
if (node->getUnsignedValue(node->mLength, integer_array, node->mEncoding) < node->mLength)
{
error_buffer.append(llformat("ERROR Node %s: Could not read integer array, child %s.\n", mName->mString, node->mName->mString));
- return FALSE;
+ return false;
}
for (U32 pos=0; pos<(U32)node->mLength; ++pos)
{
@@ -3002,7 +2984,7 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
if (node->getLongValue(node->mLength, integer_array, node->mEncoding) < node->mLength)
{
error_buffer.append(llformat("ERROR Node %s: Could not read long integer array, child %s.\n", mName->mString, node->mName->mString));
- return FALSE;
+ return false;
}
for (U32 pos=0; pos<(U32)node->mLength; ++pos)
{
@@ -3019,7 +3001,7 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
if (node->getFloatValue(node->mLength, float_array, node->mEncoding) < node->mLength)
{
error_buffer.append(llformat("ERROR Node %s: Could not read float array, child %s.\n", mName->mString, node->mName->mString));
- return FALSE;
+ return false;
}
for (U32 pos=0; pos<(U32)node->mLength; ++pos)
{
@@ -3033,7 +3015,7 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
if (node->getDoubleValue(node->mLength, float_array, node->mEncoding) < node->mLength)
{
error_buffer.append(llformat("ERROR Node %s: Could not read float array, child %s.\n", mName->mString, node->mName->mString));
- return FALSE;
+ return false;
}
for (U32 pos=0; pos<(U32)node->mLength; ++pos)
{
@@ -3051,7 +3033,7 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
if (node->getUUIDValue(node->mLength, uuid_array) < node->mLength)
{
error_buffer.append(llformat("ERROR Node %s: Could not read uuid array, child %s.\n", mName->mString, node->mName->mString));
- return FALSE;
+ return false;
}
for (U32 pos=0; pos<(U32)node->mLength; ++pos)
{
@@ -3068,7 +3050,7 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
if (node->getNodeRefValue(node->mLength, node_array) < node->mLength)
{
error_buffer.append(llformat("ERROR Node %s: Could not read node ref array, child %s.\n", mName->mString, node->mName->mString));
- return FALSE;
+ return false;
}
for (U32 pos=0; pos<node->mLength; ++pos)
{
@@ -3089,97 +3071,97 @@ BOOL LLXMLNode::performUnitTest(std::string &error_buffer)
// Compare checksums
{
U32 node_integer_checksum = 0;
- if (!getAttribute("integer_checksum", checksum_node, FALSE) ||
+ if (!getAttribute("integer_checksum", checksum_node, false) ||
checksum_node->getUnsignedValue(1, &node_integer_checksum, ENCODING_HEX) != 1)
{
error_buffer.append(llformat("ERROR Node %s: Integer checksum missing.\n", mName->mString));
- return FALSE;
+ return false;
}
if (node_integer_checksum != integer_checksum)
{
error_buffer.append(llformat("ERROR Node %s: Integer checksum mismatch: read %X / calc %X.\n", mName->mString, node_integer_checksum, integer_checksum));
- return FALSE;
+ return false;
}
}
{
U64 node_long_checksum = 0;
- if (!getAttribute("long_checksum", checksum_node, FALSE) ||
+ if (!getAttribute("long_checksum", checksum_node, false) ||
checksum_node->getLongValue(1, &node_long_checksum, ENCODING_HEX) != 1)
{
error_buffer.append(llformat("ERROR Node %s: Long Integer checksum missing.\n", mName->mString));
- return FALSE;
+ return false;
}
if (node_long_checksum != long_checksum)
{
U32 *pp1 = (U32 *)&node_long_checksum;
U32 *pp2 = (U32 *)&long_checksum;
error_buffer.append(llformat("ERROR Node %s: Long Integer checksum mismatch: read %08X%08X / calc %08X%08X.\n", mName->mString, pp1[1], pp1[0], pp2[1], pp2[0]));
- return FALSE;
+ return false;
}
}
{
U32 node_bool_true_count = 0;
- if (!getAttribute("bool_true_count", checksum_node, FALSE) ||
+ if (!getAttribute("bool_true_count", checksum_node, false) ||
checksum_node->getUnsignedValue(1, &node_bool_true_count, ENCODING_HEX) != 1)
{
error_buffer.append(llformat("ERROR Node %s: Boolean checksum missing.\n", mName->mString));
- return FALSE;
+ return false;
}
if (node_bool_true_count != bool_true_count)
{
error_buffer.append(llformat("ERROR Node %s: Boolean checksum mismatch: read %X / calc %X.\n", mName->mString, node_bool_true_count, bool_true_count));
- return FALSE;
+ return false;
}
}
{
LLUUID node_uuid_checksum;
- if (!getAttribute("uuid_checksum", checksum_node, FALSE) ||
+ if (!getAttribute("uuid_checksum", checksum_node, false) ||
checksum_node->getUUIDValue(1, &node_uuid_checksum) != 1)
{
error_buffer.append(llformat("ERROR Node %s: UUID checksum missing.\n", mName->mString));
- return FALSE;
+ return false;
}
if (node_uuid_checksum != uuid_checksum)
{
error_buffer.append(llformat("ERROR Node %s: UUID checksum mismatch: read %s / calc %s.\n", mName->mString, node_uuid_checksum.asString().c_str(), uuid_checksum.asString().c_str()));
- return FALSE;
+ return false;
}
}
{
U32 node_noderef_checksum = 0;
- if (!getAttribute("noderef_checksum", checksum_node, FALSE) ||
+ if (!getAttribute("noderef_checksum", checksum_node, false) ||
checksum_node->getUnsignedValue(1, &node_noderef_checksum, ENCODING_HEX) != 1)
{
error_buffer.append(llformat("ERROR Node %s: Node Ref checksum missing.\n", mName->mString));
- return FALSE;
+ return false;
}
if (node_noderef_checksum != noderef_checksum)
{
error_buffer.append(llformat("ERROR Node %s: Node Ref checksum mismatch: read %X / calc %X.\n", mName->mString, node_noderef_checksum, noderef_checksum));
- return FALSE;
+ return false;
}
}
{
U32 node_float_checksum = 0;
- if (!getAttribute("float_checksum", checksum_node, FALSE) ||
+ if (!getAttribute("float_checksum", checksum_node, false) ||
checksum_node->getUnsignedValue(1, &node_float_checksum, ENCODING_HEX) != 1)
{
error_buffer.append(llformat("ERROR Node %s: Float checksum missing.\n", mName->mString));
- return FALSE;
+ return false;
}
if (node_float_checksum != float_checksum)
{
error_buffer.append(llformat("ERROR Node %s: Float checksum mismatch: read %X / calc %X.\n", mName->mString, node_float_checksum, float_checksum));
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
LLXMLNodePtr LLXMLNode::getFirstChild() const
@@ -3283,3 +3265,171 @@ S32 LLXMLNode::getLineNumber()
{
return mLineNumber;
}
+
+bool LLXMLNode::parseXmlRpcArrayValue(LLSD& target)
+{
+ LLXMLNode* datap = getFirstChild().get();
+ if (!datap)
+ {
+ LL_WARNS() << "No inner XML element." << LL_ENDL;
+ return false;
+ }
+ if (!datap->hasName("data"))
+ {
+ LL_WARNS() << "No inner XML element (<data> expected, got: "
+ << datap->mName->mString << ")" << LL_ENDL;
+ return false;
+ }
+ if (datap->getNextSibling().get())
+ {
+ LL_WARNS() << "Multiple inner XML elements (single <data> expected)"
+ << LL_ENDL;
+ return false;
+ }
+ for (LLXMLNode* itemp = datap->getFirstChild().get(); itemp;
+ itemp = itemp->getNextSibling().get())
+ {
+ LLSD value;
+ if (!itemp->fromXMLRPCValue(value))
+ {
+ return false;
+ }
+ target.append(value);
+ }
+ return true;
+}
+
+bool LLXMLNode::parseXmlRpcStructValue(LLSD& target)
+{
+ std::string name;
+ LLSD value;
+ for (LLXMLNode* itemp = getFirstChild().get(); itemp;
+ itemp = itemp->getNextSibling().get())
+ {
+ if (!itemp->hasName("member"))
+ {
+ LL_WARNS() << "Invalid inner XML element (<member> expected, got: <"
+ << itemp->mName->mString << ">" << LL_ENDL;
+ return false;
+ }
+ name.clear();
+ value.clear();
+ for (LLXMLNode* chilp = itemp->getFirstChild().get(); chilp;
+ chilp = chilp->getNextSibling().get())
+ {
+ if (chilp->hasName("name"))
+ {
+ name = LLStringFn::xml_decode(chilp->getTextContents());
+ }
+ else if (!chilp->fromXMLRPCValue(value))
+ {
+ return false;
+ }
+ }
+ if (name.empty())
+ {
+ LL_WARNS() << "Empty struct member name" << LL_ENDL;
+ return false;
+ }
+ target.insert(name, value);
+ }
+ return true;
+}
+
+bool LLXMLNode::fromXMLRPCValue(LLSD& target)
+{
+ target.clear();
+
+ if (!hasName("value"))
+ {
+ LL_WARNS() << "Invalid XML element (<value> expected), got: <"
+ << mName->mString << ">" << LL_ENDL;
+ return false;
+ }
+
+ LLXMLNode* childp = getFirstChild().get();
+ if (!childp)
+ {
+ LL_WARNS() << "No inner XML element (value type expected)" << LL_ENDL;
+ // Value with no type qualifier is treated as string
+ target.assign(LLStringFn::xml_decode(getTextContents()));
+ return true;
+ }
+
+ if (childp->getNextSibling())
+ {
+ LL_WARNS() << "Multiple inner XML elements (single expected)"
+ << LL_ENDL;
+ return false;
+ }
+
+ if (childp->hasName("string"))
+ {
+ target.assign(LLStringFn::xml_decode(childp->getTextContents()));
+ return true;
+ }
+
+ if (childp->hasName("int") || childp->hasName("i4"))
+ {
+ target.assign(std::stoi(childp->getTextContents()));
+ return true;
+ }
+
+ if (childp->hasName("double"))
+ {
+ target.assign(std::stod(childp->getTextContents()));
+ return true;
+ }
+
+ if (childp->hasName("boolean"))
+ {
+ target.assign(std::stoi(childp->getTextContents()) != 0);
+ return true;
+ }
+
+ if (childp->hasName("dateTime.iso8601"))
+ {
+ target.assign(LLSD::Date(childp->getTextContents()));
+ return true;
+ }
+
+ if (childp->hasName("base64"))
+ {
+ std::string decoded =
+ LLBase64::decodeAsString(childp->getTextContents());
+ size_t size = decoded.size();
+ LLSD::Binary binary(size);
+ if (size)
+ {
+ memcpy((void*)binary.data(), (void*)decoded.data(), size);
+ }
+ target.assign(binary);
+ return true;
+ }
+
+ if (childp->hasName("array"))
+ {
+ if (!childp->parseXmlRpcArrayValue(target))
+ {
+ target.clear();
+ return false;
+ }
+ return true;
+ }
+
+ if (childp->hasName("struct"))
+ {
+ if (!childp->parseXmlRpcStructValue(target))
+ {
+ target.clear();
+ return false;
+ }
+ return true;
+ }
+
+ LL_WARNS() << "Unknown inner XML element (known value type expected)"
+ << LL_ENDL;
+ // Value with unknown type qualifier is treated as string
+ target.assign(LLStringFn::xml_decode(childp->getTextContents()));
+ return true;
+}
diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h
index 62ab51fa8c..3769ec8293 100644
--- a/indra/llxml/llxmlnode.h
+++ b/indra/llxml/llxmlnode.h
@@ -50,6 +50,7 @@ class LLVector3d;
class LLQuaternion;
class LLColor4;
class LLColor4U;
+class LLSD;
struct CompareAttributes
@@ -57,9 +58,9 @@ struct CompareAttributes
bool operator()(const LLStringTableEntry* const lhs, const LLStringTableEntry* const rhs) const
{
if (lhs == NULL)
- return TRUE;
+ return true;
if (rhs == NULL)
- return FALSE;
+ return true;
return strcmp(lhs->mString, rhs->mString) < 0;
}
@@ -118,31 +119,31 @@ protected:
public:
LLXMLNode();
- LLXMLNode(const char* name, BOOL is_attribute);
- LLXMLNode(LLStringTableEntry* name, BOOL is_attribute);
+ LLXMLNode(const char* name, bool is_attribute);
+ LLXMLNode(LLStringTableEntry* name, bool is_attribute);
LLXMLNode(const LLXMLNode& rhs);
LLXMLNodePtr deepCopy();
- BOOL isNull();
+ bool isNull();
- BOOL deleteChild(LLXMLNode* child);
+ bool deleteChild(LLXMLNode* child);
void addChild(LLXMLNodePtr& new_child);
void setParent(LLXMLNodePtr& new_parent); // reparent if necessary
- // Serialization
+ // Deserialization
static bool parseFile(
const std::string& filename,
LLXMLNodePtr& node,
- LLXMLNode* defaults_tree);
+ LLXMLNode* defaults = nullptr);
static bool parseBuffer(
- U8* buffer,
- U32 length,
+ const char* buffer,
+ U64 length,
LLXMLNodePtr& node,
- LLXMLNode* defaults);
+ LLXMLNode* defaults = nullptr);
static bool parseStream(
std::istream& str,
LLXMLNodePtr& node,
- LLXMLNode* defaults);
+ LLXMLNode* defaults = nullptr);
static bool updateNode(
LLXMLNodePtr& node,
LLXMLNodePtr& update_node);
@@ -165,12 +166,12 @@ public:
void findID(const std::string& id, LLXMLNodeList &results);
- virtual LLXMLNodePtr createChild(const char* name, BOOL is_attribute);
- virtual LLXMLNodePtr createChild(LLStringTableEntry* name, BOOL is_attribute);
+ virtual LLXMLNodePtr createChild(const char* name, bool is_attribute);
+ virtual LLXMLNodePtr createChild(LLStringTableEntry* name, bool is_attribute);
// Getters
- U32 getBoolValue(U32 expected_length, BOOL *array);
+ U32 getBoolValue(U32 expected_length, bool *array);
U32 getByteValue(U32 expected_length, U8 *array, Encoding encoding = ENCODING_DEFAULT);
U32 getIntValue(U32 expected_length, S32 *array, Encoding encoding = ENCODING_DEFAULT);
U32 getUnsignedValue(U32 expected_length, U32 *array, Encoding encoding = ENCODING_DEFAULT);
@@ -181,29 +182,25 @@ public:
U32 getUUIDValue(U32 expected_length, LLUUID *array);
U32 getNodeRefValue(U32 expected_length, LLXMLNode **array);
- BOOL hasAttribute(const char* name );
-
- // these are designed to be more generic versions of the functions
- // rather than relying on LL-types
- bool getAttribute_bool(const char* name, bool& value );
-
- BOOL getAttributeBOOL(const char* name, BOOL& value );
- BOOL getAttributeU8(const char* name, U8& value );
- BOOL getAttributeS8(const char* name, S8& value );
- BOOL getAttributeU16(const char* name, U16& value );
- BOOL getAttributeS16(const char* name, S16& value );
- BOOL getAttributeU32(const char* name, U32& value );
- BOOL getAttributeS32(const char* name, S32& value );
- BOOL getAttributeF32(const char* name, F32& value );
- BOOL getAttributeF64(const char* name, F64& value );
- BOOL getAttributeColor(const char* name, LLColor4& value );
- BOOL getAttributeColor4(const char* name, LLColor4& value );
- BOOL getAttributeColor4U(const char* name, LLColor4U& value );
- BOOL getAttributeVector3(const char* name, LLVector3& value );
- BOOL getAttributeVector3d(const char* name, LLVector3d& value );
- BOOL getAttributeQuat(const char* name, LLQuaternion& value );
- BOOL getAttributeUUID(const char* name, LLUUID& value );
- BOOL getAttributeString(const char* name, std::string& value );
+ bool hasAttribute(const char* name );
+
+ bool getAttributeBOOL(const char* name, bool& value );
+ bool getAttributeU8(const char* name, U8& value );
+ bool getAttributeS8(const char* name, S8& value );
+ bool getAttributeU16(const char* name, U16& value );
+ bool getAttributeS16(const char* name, S16& value );
+ bool getAttributeU32(const char* name, U32& value );
+ bool getAttributeS32(const char* name, S32& value );
+ bool getAttributeF32(const char* name, F32& value );
+ bool getAttributeF64(const char* name, F64& value );
+ bool getAttributeColor(const char* name, LLColor4& value );
+ bool getAttributeColor4(const char* name, LLColor4& value );
+ bool getAttributeColor4U(const char* name, LLColor4U& value );
+ bool getAttributeVector3(const char* name, LLVector3& value );
+ bool getAttributeVector3d(const char* name, LLVector3d& value );
+ bool getAttributeQuat(const char* name, LLQuaternion& value );
+ bool getAttributeUUID(const char* name, LLUUID& value );
+ bool getAttributeString(const char* name, std::string& value );
const ValueType& getType() const { return mType; }
U32 getLength() const { return mLength; }
@@ -212,23 +209,23 @@ public:
std::string getSanitizedValue() const;
std::string getTextContents() const;
const LLStringTableEntry* getName() const { return mName; }
- BOOL hasName(const char* name) const { return mName == gStringTable.checkStringEntry(name); }
- BOOL hasName(const std::string& name) const { return mName == gStringTable.checkStringEntry(name.c_str()); }
+ bool hasName(const char* name) const { return mName == gStringTable.checkStringEntry(name); }
+ bool hasName(const std::string& name) const { return mName == gStringTable.checkStringEntry(name.c_str()); }
const std::string& getID() const { return mID; }
U32 getChildCount() const;
// getChild returns a Null LLXMLNode (not a NULL pointer) if there is no such child.
// This child has no value so any getTYPEValue() calls on it will return 0.
- bool getChild(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE);
- bool getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE);
- void getChildren(const char* name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const;
- void getChildren(const LLStringTableEntry* name, LLXMLNodeList &children, BOOL use_default_if_missing = TRUE) const;
+ bool getChild(const char* name, LLXMLNodePtr& node, bool use_default_if_missing = true);
+ bool getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, bool use_default_if_missing = true);
+ void getChildren(const char* name, LLXMLNodeList &children, bool use_default_if_missing = true) const;
+ void getChildren(const LLStringTableEntry* name, LLXMLNodeList &children, bool use_default_if_missing = true) const;
// recursively finds all children at any level matching name
void getDescendants(const LLStringTableEntry* name, LLXMLNodeList &children) const;
- bool getAttribute(const char* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE);
- bool getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node, BOOL use_default_if_missing = TRUE);
+ bool getAttribute(const char* name, LLXMLNodePtr& node, bool use_default_if_missing = true);
+ bool getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node, bool use_default_if_missing = true);
S32 getLineNumber();
@@ -242,7 +239,7 @@ public:
bool setAttributeString(const char* attr, const std::string& value);
- void setBoolValue(const BOOL value) { setBoolValue(1, &value); }
+ void setBoolValue(const bool value) { setBoolValue(1, &value); }
void setByteValue(const U8 value, Encoding encoding = ENCODING_DEFAULT) { setByteValue(1, &value, encoding); }
void setIntValue(const S32 value, Encoding encoding = ENCODING_DEFAULT) { setIntValue(1, &value, encoding); }
void setUnsignedValue(const U32 value, Encoding encoding = ENCODING_DEFAULT) { setUnsignedValue(1, &value, encoding); }
@@ -253,7 +250,7 @@ public:
void setUUIDValue(const LLUUID value) { setUUIDValue(1, &value); }
void setNodeRefValue(const LLXMLNode *value) { setNodeRefValue(1, &value); }
- void setBoolValue(U32 length, const BOOL *array);
+ void setBoolValue(U32 length, const bool *array);
void setByteValue(U32 length, const U8 *array, Encoding encoding = ENCODING_DEFAULT);
void setIntValue(U32 length, const S32 *array, Encoding encoding = ENCODING_DEFAULT);
void setUnsignedValue(U32 length, const U32* array, Encoding encoding = ENCODING_DEFAULT);
@@ -283,24 +280,30 @@ public:
// Delete any child nodes that aren't among the tree's children, recursive
void scrubToTree(LLXMLNode *tree);
- BOOL deleteChildren(const std::string& name);
- BOOL deleteChildren(LLStringTableEntry* name);
+ bool deleteChildren(const std::string& name);
+ bool deleteChildren(LLStringTableEntry* name);
void setAttributes(ValueType type, U32 precision, Encoding encoding, U32 length);
// void appendValue(const std::string& value); // Unused
+ bool fromXMLRPCValue(LLSD& target);
+
// Unit Testing
void createUnitTest(S32 max_num_children);
- BOOL performUnitTest(std::string &error_buffer);
+ bool performUnitTest(std::string &error_buffer);
protected:
- BOOL removeChild(LLXMLNode* child);
+ bool removeChild(LLXMLNode* child);
+ bool isFullyDefault();
+
+ bool parseXmlRpcArrayValue(LLSD& target);
+ bool parseXmlRpcStructValue(LLSD& target);
public:
std::string mID; // The ID attribute of this node
XML_Parser *mParser; // Temporary pointer while loading
- BOOL mIsAttribute; // Flag is only used for output formatting
+ bool mIsAttribute; // Flag is only used for output formatting
U32 mVersionMajor; // Version of this tag to use
U32 mVersionMinor;
U32 mLength; // If the length is nonzero, then only return arrays of this length
@@ -315,8 +318,8 @@ public:
LLXMLNodePtr mPrev; // Double-linked list previous node
LLXMLNodePtr mNext; // Double-linked list next node
- static BOOL sStripEscapedStrings;
- static BOOL sStripWhitespaceValues;
+ static bool sStripEscapedStrings;
+ static bool sStripWhitespaceValues;
protected:
LLStringTableEntry *mName; // The name of this node
@@ -330,10 +333,8 @@ protected:
static const char *skipWhitespace(const char *str);
static const char *skipNonWhitespace(const char *str);
- static const char *parseInteger(const char *str, U64 *dest, BOOL *is_negative, U32 precision, Encoding encoding);
+ static const char *parseInteger(const char *str, U64 *dest, bool *is_negative, U32 precision, Encoding encoding);
static const char *parseFloat(const char *str, F64 *dest, U32 precision, Encoding encoding);
-
- BOOL isFullyDefault();
};
#endif // LL_LLXMLNODE
diff --git a/indra/llxml/llxmlparser.cpp b/indra/llxml/llxmlparser.cpp
index ecd75bd410..e2c7d17e2a 100644
--- a/indra/llxml/llxmlparser.cpp
+++ b/indra/llxml/llxmlparser.cpp
@@ -66,17 +66,17 @@ LLXmlParser::~LLXmlParser()
}
-BOOL LLXmlParser::parseFile(const std::string &path)
+bool LLXmlParser::parseFile(const std::string &path)
{
llassert( !mDepth );
- BOOL success = TRUE;
+ bool success = true;
LLFILE* file = LLFile::fopen(path, "rb"); /* Flawfinder: ignore */
if( !file )
{
mAuxErrorString = llformat( "Couldn't open file %s", path.c_str());
- success = FALSE;
+ success = false;
}
else
{
@@ -90,7 +90,7 @@ BOOL LLXmlParser::parseFile(const std::string &path)
if( !buffer )
{
mAuxErrorString = llformat( "Unable to allocate XML buffer while reading file %s", path.c_str() );
- success = FALSE;
+ success = false;
goto exit_label;
}
@@ -98,14 +98,14 @@ BOOL LLXmlParser::parseFile(const std::string &path)
if( bytes_read <= 0 )
{
mAuxErrorString = llformat( "Error while reading file %s", path.c_str() );
- success = FALSE;
+ success = false;
goto exit_label;
}
- if( !XML_ParseBuffer(mParser, bytes_read, TRUE ) )
+ if( !XML_ParseBuffer(mParser, bytes_read, true ) )
{
mAuxErrorString = llformat( "Error while parsing file %s", path.c_str() );
- success = FALSE;
+ success = false;
}
exit_label:
diff --git a/indra/llxml/llxmlparser.h b/indra/llxml/llxmlparser.h
index 3a8a927350..0f64def6df 100644
--- a/indra/llxml/llxmlparser.h
+++ b/indra/llxml/llxmlparser.h
@@ -43,7 +43,7 @@ public:
virtual ~LLXmlParser();
// Parses entire file
- BOOL parseFile(const std::string &path);
+ bool parseFile(const std::string &path);
// Parses some input. Returns 0 if a fatal error is detected.
// The last call must have isFinal true;
diff --git a/indra/llxml/llxmltree.cpp b/indra/llxml/llxmltree.cpp
index baf2e6a951..164b3156e1 100644
--- a/indra/llxml/llxmltree.cpp
+++ b/indra/llxml/llxmltree.cpp
@@ -61,13 +61,13 @@ void LLXmlTree::cleanup()
}
-BOOL LLXmlTree::parseFile(const std::string &path, BOOL keep_contents)
+bool LLXmlTree::parseFile(const std::string &path, bool keep_contents)
{
delete mRoot;
mRoot = NULL;
LLXmlTreeParser parser(this);
- BOOL success = parser.parseFile( path, &mRoot, keep_contents );
+ bool success = parser.parseFile( path, &mRoot, keep_contents );
if( !success )
{
S32 line_number = parser.getCurrentLineNumber();
@@ -111,11 +111,11 @@ LLXmlTreeNode::~LLXmlTreeNode()
attribute_map_t::iterator iter;
for (iter=mAttributes.begin(); iter != mAttributes.end(); iter++)
delete iter->second;
- for(LLXmlTreeNode* node : mChildren)
- {
- delete node;
- }
- mChildren.clear();
+ for(LLXmlTreeNode* node : mChildren)
+ {
+ delete node;
+ }
+ mChildren.clear();
}
void LLXmlTreeNode::dump( const std::string& prefix )
@@ -135,16 +135,16 @@ void LLXmlTreeNode::dump( const std::string& prefix )
LL_CONT << LL_ENDL;
}
-BOOL LLXmlTreeNode::hasAttribute(const std::string& name)
+bool LLXmlTreeNode::hasAttribute(const std::string& name)
{
- LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
+ LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString(name);
attribute_map_t::iterator iter = mAttributes.find(canonical_name);
- return (iter == mAttributes.end()) ? false : true;
+ return iter != mAttributes.end();
}
void LLXmlTreeNode::addAttribute(const std::string& name, const std::string& value)
{
- LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
+ LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString(name);
const std::string *newstr = new std::string(value);
mAttributes[canonical_name] = newstr; // insert + copy
}
@@ -199,214 +199,214 @@ void LLXmlTreeNode::addChild(LLXmlTreeNode* child)
// These functions assume that name is already in mAttritrubteKeys
-BOOL LLXmlTreeNode::getFastAttributeBOOL(LLStdStringHandle canonical_name, BOOL& value)
+bool LLXmlTreeNode::getFastAttributeBOOL(LLStdStringHandle canonical_name, bool& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToBOOL( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeU8(LLStdStringHandle canonical_name, U8& value)
+bool LLXmlTreeNode::getFastAttributeU8(LLStdStringHandle canonical_name, U8& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToU8( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeS8(LLStdStringHandle canonical_name, S8& value)
+bool LLXmlTreeNode::getFastAttributeS8(LLStdStringHandle canonical_name, S8& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToS8( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeS16(LLStdStringHandle canonical_name, S16& value)
+bool LLXmlTreeNode::getFastAttributeS16(LLStdStringHandle canonical_name, S16& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToS16( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeU16(LLStdStringHandle canonical_name, U16& value)
+bool LLXmlTreeNode::getFastAttributeU16(LLStdStringHandle canonical_name, U16& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToU16( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeU32(LLStdStringHandle canonical_name, U32& value)
+bool LLXmlTreeNode::getFastAttributeU32(LLStdStringHandle canonical_name, U32& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToU32( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeS32(LLStdStringHandle canonical_name, S32& value)
+bool LLXmlTreeNode::getFastAttributeS32(LLStdStringHandle canonical_name, S32& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToS32( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeF32(LLStdStringHandle canonical_name, F32& value)
+bool LLXmlTreeNode::getFastAttributeF32(LLStdStringHandle canonical_name, F32& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToF32( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeF64(LLStdStringHandle canonical_name, F64& value)
+bool LLXmlTreeNode::getFastAttributeF64(LLStdStringHandle canonical_name, F64& value)
{
const std::string *s = getAttribute( canonical_name );
return s && LLStringUtil::convertToF64( *s, value );
}
-BOOL LLXmlTreeNode::getFastAttributeColor(LLStdStringHandle canonical_name, LLColor4& value)
+bool LLXmlTreeNode::getFastAttributeColor(LLStdStringHandle canonical_name, LLColor4& value)
{
const std::string *s = getAttribute( canonical_name );
- return s ? LLColor4::parseColor(*s, &value) : FALSE;
+ return s ? LLColor4::parseColor(*s, &value) : false;
}
-BOOL LLXmlTreeNode::getFastAttributeColor4(LLStdStringHandle canonical_name, LLColor4& value)
+bool LLXmlTreeNode::getFastAttributeColor4(LLStdStringHandle canonical_name, LLColor4& value)
{
const std::string *s = getAttribute( canonical_name );
- return s ? LLColor4::parseColor4(*s, &value) : FALSE;
+ return s ? LLColor4::parseColor4(*s, &value) : false;
}
-BOOL LLXmlTreeNode::getFastAttributeColor4U(LLStdStringHandle canonical_name, LLColor4U& value)
+bool LLXmlTreeNode::getFastAttributeColor4U(LLStdStringHandle canonical_name, LLColor4U& value)
{
const std::string *s = getAttribute( canonical_name );
- return s ? LLColor4U::parseColor4U(*s, &value ) : FALSE;
+ return s ? LLColor4U::parseColor4U(*s, &value ) : false;
}
-BOOL LLXmlTreeNode::getFastAttributeVector3(LLStdStringHandle canonical_name, LLVector3& value)
+bool LLXmlTreeNode::getFastAttributeVector3(LLStdStringHandle canonical_name, LLVector3& value)
{
const std::string *s = getAttribute( canonical_name );
- return s ? LLVector3::parseVector3(*s, &value ) : FALSE;
+ return s ? LLVector3::parseVector3(*s, &value ) : false;
}
-BOOL LLXmlTreeNode::getFastAttributeVector3d(LLStdStringHandle canonical_name, LLVector3d& value)
+bool LLXmlTreeNode::getFastAttributeVector3d(LLStdStringHandle canonical_name, LLVector3d& value)
{
const std::string *s = getAttribute( canonical_name );
- return s ? LLVector3d::parseVector3d(*s, &value ) : FALSE;
+ return s ? LLVector3d::parseVector3d(*s, &value ) : false;
}
-BOOL LLXmlTreeNode::getFastAttributeQuat(LLStdStringHandle canonical_name, LLQuaternion& value)
+bool LLXmlTreeNode::getFastAttributeQuat(LLStdStringHandle canonical_name, LLQuaternion& value)
{
const std::string *s = getAttribute( canonical_name );
- return s ? LLQuaternion::parseQuat(*s, &value ) : FALSE;
+ return s ? LLQuaternion::parseQuat(*s, &value ) : false;
}
-BOOL LLXmlTreeNode::getFastAttributeUUID(LLStdStringHandle canonical_name, LLUUID& value)
+bool LLXmlTreeNode::getFastAttributeUUID(LLStdStringHandle canonical_name, LLUUID& value)
{
const std::string *s = getAttribute( canonical_name );
- return s ? LLUUID::parseUUID(*s, &value ) : FALSE;
+ return s ? LLUUID::parseUUID(*s, &value ) : false;
}
-BOOL LLXmlTreeNode::getFastAttributeString(LLStdStringHandle canonical_name, std::string& value)
+bool LLXmlTreeNode::getFastAttributeString(LLStdStringHandle canonical_name, std::string& value)
{
const std::string *s = getAttribute( canonical_name );
if( !s )
{
- return FALSE;
+ return false;
}
value = *s;
- return TRUE;
+ return true;
}
//////////////////////////////////////////////////////////////
-BOOL LLXmlTreeNode::getAttributeBOOL(const std::string& name, BOOL& value)
+bool LLXmlTreeNode::getAttributeBOOL(const std::string& name, bool& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeBOOL(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeU8(const std::string& name, U8& value)
+bool LLXmlTreeNode::getAttributeU8(const std::string& name, U8& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeU8(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeS8(const std::string& name, S8& value)
+bool LLXmlTreeNode::getAttributeS8(const std::string& name, S8& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeS8(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeS16(const std::string& name, S16& value)
+bool LLXmlTreeNode::getAttributeS16(const std::string& name, S16& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeS16(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeU16(const std::string& name, U16& value)
+bool LLXmlTreeNode::getAttributeU16(const std::string& name, U16& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeU16(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeU32(const std::string& name, U32& value)
+bool LLXmlTreeNode::getAttributeU32(const std::string& name, U32& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeU32(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeS32(const std::string& name, S32& value)
+bool LLXmlTreeNode::getAttributeS32(const std::string& name, S32& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeS32(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeF32(const std::string& name, F32& value)
+bool LLXmlTreeNode::getAttributeF32(const std::string& name, F32& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeF32(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeF64(const std::string& name, F64& value)
+bool LLXmlTreeNode::getAttributeF64(const std::string& name, F64& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeF64(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeColor(const std::string& name, LLColor4& value)
+bool LLXmlTreeNode::getAttributeColor(const std::string& name, LLColor4& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeColor(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeColor4(const std::string& name, LLColor4& value)
+bool LLXmlTreeNode::getAttributeColor4(const std::string& name, LLColor4& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeColor4(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeColor4U(const std::string& name, LLColor4U& value)
+bool LLXmlTreeNode::getAttributeColor4U(const std::string& name, LLColor4U& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeColor4U(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeVector3(const std::string& name, LLVector3& value)
+bool LLXmlTreeNode::getAttributeVector3(const std::string& name, LLVector3& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeVector3(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeVector3d(const std::string& name, LLVector3d& value)
+bool LLXmlTreeNode::getAttributeVector3d(const std::string& name, LLVector3d& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeVector3d(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeQuat(const std::string& name, LLQuaternion& value)
+bool LLXmlTreeNode::getAttributeQuat(const std::string& name, LLQuaternion& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeQuat(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeUUID(const std::string& name, LLUUID& value)
+bool LLXmlTreeNode::getAttributeUUID(const std::string& name, LLUUID& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeUUID(canonical_name, value);
}
-BOOL LLXmlTreeNode::getAttributeString(const std::string& name, std::string& value)
+bool LLXmlTreeNode::getAttributeString(const std::string& name, std::string& value)
{
LLStdStringHandle canonical_name = LLXmlTree::sAttributeKeys.addString( name );
return getFastAttributeString(canonical_name, value);
@@ -506,8 +506,8 @@ LLXmlTreeParser::LLXmlTreeParser(LLXmlTree* tree)
: mTree(tree),
mRoot( NULL ),
mCurrent( NULL ),
- mDump( FALSE ),
- mKeepContents(FALSE)
+ mDump( false ),
+ mKeepContents(false)
{
}
@@ -515,14 +515,14 @@ LLXmlTreeParser::~LLXmlTreeParser()
{
}
-BOOL LLXmlTreeParser::parseFile(const std::string &path, LLXmlTreeNode** root, BOOL keep_contents)
+bool LLXmlTreeParser::parseFile(const std::string &path, LLXmlTreeNode** root, bool keep_contents)
{
llassert( !mRoot );
llassert( !mCurrent );
mKeepContents = keep_contents;
- BOOL success = LLXmlParser::parseFile(path);
+ bool success = LLXmlParser::parseFile(path);
*root = mRoot;
mRoot = NULL;
@@ -685,7 +685,7 @@ void LLXmlTreeParser::unparsedEntityDecl(
void test_llxmltree()
{
LLXmlTree tree;
- BOOL success = tree.parseFile( "test.xml" );
+ bool success = tree.parseFile( "test.xml" );
if( success )
{
tree.dump();
diff --git a/indra/llxml/llxmltree.h b/indra/llxml/llxmltree.h
index 0f7361c554..120d7d3e56 100644
--- a/indra/llxml/llxmltree.h
+++ b/indra/llxml/llxmltree.h
@@ -55,7 +55,7 @@ public:
virtual ~LLXmlTree();
void cleanup();
- virtual BOOL parseFile(const std::string &path, BOOL keep_contents = TRUE);
+ virtual bool parseFile(const std::string &path, bool keep_contents = true);
LLXmlTreeNode* getRoot() { return mRoot; }
@@ -97,50 +97,50 @@ public:
{
return mName;
}
- BOOL hasName( const std::string& name )
+ bool hasName( const std::string& name )
{
return mName == name;
}
- BOOL hasAttribute( const std::string& name );
+ bool hasAttribute( const std::string& name );
// Fast versions use cannonical_name handlee to entru in LLXmlTree::sAttributeKeys string table
- BOOL getFastAttributeBOOL( LLStdStringHandle cannonical_name, BOOL& value );
- BOOL getFastAttributeU8( LLStdStringHandle cannonical_name, U8& value );
- BOOL getFastAttributeS8( LLStdStringHandle cannonical_name, S8& value );
- BOOL getFastAttributeU16( LLStdStringHandle cannonical_name, U16& value );
- BOOL getFastAttributeS16( LLStdStringHandle cannonical_name, S16& value );
- BOOL getFastAttributeU32( LLStdStringHandle cannonical_name, U32& value );
- BOOL getFastAttributeS32( LLStdStringHandle cannonical_name, S32& value );
- BOOL getFastAttributeF32( LLStdStringHandle cannonical_name, F32& value );
- BOOL getFastAttributeF64( LLStdStringHandle cannonical_name, F64& value );
- BOOL getFastAttributeColor( LLStdStringHandle cannonical_name, LLColor4& value );
- BOOL getFastAttributeColor4( LLStdStringHandle cannonical_name, LLColor4& value );
- BOOL getFastAttributeColor4U( LLStdStringHandle cannonical_name, LLColor4U& value );
- BOOL getFastAttributeVector3( LLStdStringHandle cannonical_name, LLVector3& value );
- BOOL getFastAttributeVector3d( LLStdStringHandle cannonical_name, LLVector3d& value );
- BOOL getFastAttributeQuat( LLStdStringHandle cannonical_name, LLQuaternion& value );
- BOOL getFastAttributeUUID( LLStdStringHandle cannonical_name, LLUUID& value );
- BOOL getFastAttributeString( LLStdStringHandle cannonical_name, std::string& value );
+ bool getFastAttributeBOOL( LLStdStringHandle cannonical_name, bool& value );
+ bool getFastAttributeU8( LLStdStringHandle cannonical_name, U8& value );
+ bool getFastAttributeS8( LLStdStringHandle cannonical_name, S8& value );
+ bool getFastAttributeU16( LLStdStringHandle cannonical_name, U16& value );
+ bool getFastAttributeS16( LLStdStringHandle cannonical_name, S16& value );
+ bool getFastAttributeU32( LLStdStringHandle cannonical_name, U32& value );
+ bool getFastAttributeS32( LLStdStringHandle cannonical_name, S32& value );
+ bool getFastAttributeF32( LLStdStringHandle cannonical_name, F32& value );
+ bool getFastAttributeF64( LLStdStringHandle cannonical_name, F64& value );
+ bool getFastAttributeColor( LLStdStringHandle cannonical_name, LLColor4& value );
+ bool getFastAttributeColor4( LLStdStringHandle cannonical_name, LLColor4& value );
+ bool getFastAttributeColor4U( LLStdStringHandle cannonical_name, LLColor4U& value );
+ bool getFastAttributeVector3( LLStdStringHandle cannonical_name, LLVector3& value );
+ bool getFastAttributeVector3d( LLStdStringHandle cannonical_name, LLVector3d& value );
+ bool getFastAttributeQuat( LLStdStringHandle cannonical_name, LLQuaternion& value );
+ bool getFastAttributeUUID( LLStdStringHandle cannonical_name, LLUUID& value );
+ bool getFastAttributeString( LLStdStringHandle cannonical_name, std::string& value );
// Normal versions find 'name' in LLXmlTree::sAttributeKeys then call fast versions
- virtual BOOL getAttributeBOOL( const std::string& name, BOOL& value );
- virtual BOOL getAttributeU8( const std::string& name, U8& value );
- virtual BOOL getAttributeS8( const std::string& name, S8& value );
- virtual BOOL getAttributeU16( const std::string& name, U16& value );
- virtual BOOL getAttributeS16( const std::string& name, S16& value );
- virtual BOOL getAttributeU32( const std::string& name, U32& value );
- virtual BOOL getAttributeS32( const std::string& name, S32& value );
- virtual BOOL getAttributeF32( const std::string& name, F32& value );
- virtual BOOL getAttributeF64( const std::string& name, F64& value );
- virtual BOOL getAttributeColor( const std::string& name, LLColor4& value );
- virtual BOOL getAttributeColor4( const std::string& name, LLColor4& value );
- virtual BOOL getAttributeColor4U( const std::string& name, LLColor4U& value );
- virtual BOOL getAttributeVector3( const std::string& name, LLVector3& value );
- virtual BOOL getAttributeVector3d( const std::string& name, LLVector3d& value );
- virtual BOOL getAttributeQuat( const std::string& name, LLQuaternion& value );
- virtual BOOL getAttributeUUID( const std::string& name, LLUUID& value );
- virtual BOOL getAttributeString( const std::string& name, std::string& value );
+ virtual bool getAttributeBOOL( const std::string& name, bool& value );
+ virtual bool getAttributeU8( const std::string& name, U8& value );
+ virtual bool getAttributeS8( const std::string& name, S8& value );
+ virtual bool getAttributeU16( const std::string& name, U16& value );
+ virtual bool getAttributeS16( const std::string& name, S16& value );
+ virtual bool getAttributeU32( const std::string& name, U32& value );
+ virtual bool getAttributeS32( const std::string& name, S32& value );
+ virtual bool getAttributeF32( const std::string& name, F32& value );
+ virtual bool getAttributeF64( const std::string& name, F64& value );
+ virtual bool getAttributeColor( const std::string& name, LLColor4& value );
+ virtual bool getAttributeColor4( const std::string& name, LLColor4& value );
+ virtual bool getAttributeColor4U( const std::string& name, LLColor4U& value );
+ virtual bool getAttributeVector3( const std::string& name, LLVector3& value );
+ virtual bool getAttributeVector3d( const std::string& name, LLVector3d& value );
+ virtual bool getAttributeQuat( const std::string& name, LLQuaternion& value );
+ virtual bool getAttributeUUID( const std::string& name, LLUUID& value );
+ virtual bool getAttributeString( const std::string& name, std::string& value );
const std::string& getContents()
{
@@ -199,7 +199,7 @@ public:
LLXmlTreeParser(LLXmlTree* tree);
virtual ~LLXmlTreeParser();
- BOOL parseFile(const std::string &path, LLXmlTreeNode** root, BOOL keep_contents );
+ bool parseFile(const std::string &path, LLXmlTreeNode** root, bool keep_contents );
protected:
const std::string& tabs();
@@ -227,8 +227,8 @@ protected:
LLXmlTree* mTree;
LLXmlTreeNode* mRoot;
LLXmlTreeNode* mCurrent;
- BOOL mDump; // Dump parse tree to LL_INFOS() as it is read.
- BOOL mKeepContents;
+ bool mDump; // Dump parse tree to LL_INFOS() as it is read.
+ bool mKeepContents;
};
#endif // LL_LLXMLTREE_H
diff --git a/indra/llxml/tests/llcontrol_test.cpp b/indra/llxml/tests/llcontrol_test.cpp
index f5f8b285f7..4192e029c5 100644
--- a/indra/llxml/tests/llcontrol_test.cpp
+++ b/indra/llxml/tests/llcontrol_test.cpp
@@ -112,7 +112,7 @@ namespace tut
LLControlGroup test_cg("foo2");
std::string temp_test_file = (mTestConfigDir + "setting_llsd_temp.xml");
mCleanups.push_back(temp_test_file);
- mCG->saveToFile(temp_test_file.c_str(), TRUE);
+ mCG->saveToFile(temp_test_file.c_str(), true);
results = test_cg.loadFromFile(temp_test_file.c_str());
ensure("number of changed settings loaded", (results == 1));
ensure("value of changed settings loaded", (test_cg.getU32("TestSetting") == 13));
@@ -129,12 +129,12 @@ namespace tut
int results = mCG->loadFromFile(mTestConfigFile.c_str(), true);
LLControlVariable* control = mCG->getControl("TestSetting");
LLSD new_value = 13;
- control->setValue(new_value, FALSE);
+ control->setValue(new_value, false);
ensure_equals("value of changed setting", mCG->getU32("TestSetting"), 13);
LLControlGroup test_cg("foo3");
std::string temp_test_file = (mTestConfigDir + "setting_llsd_persist_temp.xml");
mCleanups.push_back(temp_test_file);
- mCG->saveToFile(temp_test_file.c_str(), TRUE);
+ mCG->saveToFile(temp_test_file.c_str(), true);
results = test_cg.loadFromFile(temp_test_file.c_str());
//If we haven't changed any settings, then we shouldn't have any settings to load
ensure("number of non-persisted changed settings loaded", (results == 0));