From 2b31dad40026d8078ea30d0da0656a4078d0f5b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Fri, 9 Feb 2024 22:26:02 +0100 Subject: miscellaneous: BOOL (int) to real bool --- indra/llxml/llcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llxml/llcontrol.cpp') diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 2960ecf829..b53d573bae 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -508,7 +508,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); } -- cgit v1.2.3 From 70f8dc7a4f4be217fea5439e474fc75e567c23c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Sat, 10 Feb 2024 22:37:52 +0100 Subject: miscellaneous: BOOL (int) to real bool --- indra/llxml/llcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llxml/llcontrol.cpp') diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index b53d573bae..1abf6832fb 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -179,7 +179,7 @@ LLSD LLControlVariable::getComparableValue(const LLSD& value) if(TYPE_BOOLEAN == type() && value.isString()) { BOOL temp; - if(LLStringUtil::convertToBOOL(value.asString(), temp)) + if(LLStringUtil::convertToBOOL(value.asString(), temp)) { storable_value = (bool)temp; } -- cgit v1.2.3 From 9e854b697a06abed2a0917fb6120445f176764f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Fri, 16 Feb 2024 19:29:51 +0100 Subject: misc: BOOL to bool --- indra/llxml/llcontrol.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llxml/llcontrol.cpp') diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 1abf6832fb..2c04147a5a 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -178,10 +178,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 { @@ -859,7 +859,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); -- cgit v1.2.3 From 8c16ec2b53153a10f40181e0e8108d24331451d4 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 13:57:07 +0100 Subject: Convert BOOL to bool in LLControlGroup and related classes --- indra/llxml/llcontrol.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'indra/llxml/llcontrol.cpp') diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 2c04147a5a..e215ff57fb 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -59,8 +59,6 @@ template <> eControlType get_control_type(); template <> eControlType get_control_type(); template <> eControlType get_control_type(); template <> eControlType get_control_type(); -// Yay BOOL, its really an S32. -//template <> eControlType get_control_type () ; template <> eControlType get_control_type(); template <> eControlType get_control_type(); @@ -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) @@ -562,9 +560,9 @@ void LLControlGroup::incrCount(const std::string& name) getCount[name] = getCount[name].asInteger() + 1; } -BOOL LLControlGroup::getBOOL(const std::string& name) +bool LLControlGroup::getBOOL(const std::string& name) { - return (BOOL)get(name); + return get(name); } S32 LLControlGroup::getS32(const std::string& name) @@ -659,7 +657,7 @@ LLSD LLControlGroup::asLLSD(bool diffs_only) return result; } -BOOL LLControlGroup::controlExists(const std::string& name) +bool LLControlGroup::controlExists(const std::string& name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter != mNameTable.end(); @@ -670,7 +668,7 @@ BOOL LLControlGroup::controlExists(const std::string& name) // Set functions //------------------------------------------------------------------- -void LLControlGroup::setBOOL(const std::string& name, BOOL val) +void LLControlGroup::setBOOL(const std::string& name, bool val) { set(name, val); } @@ -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) { @@ -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; @@ -1162,7 +1160,7 @@ void main() bar = new LLControlVariable("gBar", 10, 2, 22); gGlobals.addEntry("gBar", bar); - baz = new LLControlVariable("gBaz", FALSE); + baz = new LLControlVariable("gBaz", false); gGlobals.addEntry("gBaz", baz); // test retrieval @@ -1224,13 +1222,7 @@ template <> eControlType get_control_type () { return TYPE_BOOLEAN; } -/* -// Yay BOOL, its really an S32. -template <> eControlType get_control_type () -{ - return TYPE_BOOLEAN; -} -*/ + template <> eControlType get_control_type() { return TYPE_STRING; @@ -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 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)); @@ -1506,7 +1497,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)); -- cgit v1.2.3 From 3ffe63b8a4e8a3ceda3f6d204e4b5bb0c80d0870 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Feb 2024 16:49:48 +0100 Subject: Convert remaining BOOLs in llxml and introduce std::string_view --- indra/llxml/llcontrol.cpp | 124 +++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 62 deletions(-) (limited to 'indra/llxml/llcontrol.cpp') diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index e215ff57fb..f665621b66 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -77,19 +77,19 @@ template <> LLSD convert_to_llsd(const LLColor4& in); template <> LLSD convert_to_llsd(const LLColor3& in); template <> LLSD convert_to_llsd(const LLColor4U& in); -template <> bool convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> S32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> U32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> F32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> std::string convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLWString convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLVector3 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLRect convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLColor4 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLColor4U convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLColor3 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); -template <> LLSD convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name); +template <> bool convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> S32 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> U32 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> F32 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> std::string convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLWString convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLVector3 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLRect convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLColor4 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLColor4U convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLColor3 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name); +template <> LLSD convert_from_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; @@ -218,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) == false; 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) == false) { mValues.push_back(storable_value); } @@ -233,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) == false) { while(mValues.size() > 2) { @@ -267,7 +267,7 @@ 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) == false); resetToDefault(false); mValues[0] = comparable_value; if(value_changed) @@ -341,14 +341,14 @@ LLSD LLControlVariable::getSaveValue() const return mValues[0]; } -LLPointer LLControlGroup::getControl(const std::string& name) +LLPointer LLControlGroup::getControl(std::string_view name) { if (mSettingsProfile) { incrCount(name); } - ctrl_name_table_t::iterator iter = mNameTable.find(name); + ctrl_name_table_t::iterator iter = mNameTable.find(name.data()); return iter == mNameTable.end() ? LLPointer() : iter->second; } @@ -551,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 get(name); } -S32 LLControlGroup::getS32(const std::string& name) +S32 LLControlGroup::getS32(std::string_view name) { return get(name); } -U32 LLControlGroup::getU32(const std::string& name) +U32 LLControlGroup::getU32(std::string_view name) { return get(name); } -F32 LLControlGroup::getF32(const std::string& name) +F32 LLControlGroup::getF32(std::string_view name) { return get(name); } -std::string LLControlGroup::getString(const std::string& name) +std::string LLControlGroup::getString(std::string_view name) { return get(name); } -LLWString LLControlGroup::getWString(const std::string& name) +LLWString LLControlGroup::getWString(std::string_view name) { return get(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'); @@ -598,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(name); } -LLVector3d LLControlGroup::getVector3d(const std::string& name) +LLVector3d LLControlGroup::getVector3d(std::string_view name) { return get(name); } -LLQuaternion LLControlGroup::getQuaternion(const std::string& name) +LLQuaternion LLControlGroup::getQuaternion(std::string_view name) { return get(name); } -LLRect LLControlGroup::getRect(const std::string& name) +LLRect LLControlGroup::getRect(std::string_view name) { return get(name); } -LLColor4 LLControlGroup::getColor(const std::string& name) +LLColor4 LLControlGroup::getColor(std::string_view name) { return get(name); } -LLColor4 LLControlGroup::getColor4(const std::string& name) +LLColor4 LLControlGroup::getColor4(std::string_view name) { return get(name); } -LLColor3 LLControlGroup::getColor3(const std::string& name) +LLColor3 LLControlGroup::getColor3(std::string_view name) { return get(name); } -LLSD LLControlGroup::getLLSD(const std::string& name) +LLSD LLControlGroup::getLLSD(std::string_view name) { return get(name); } @@ -668,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(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()) { @@ -1305,19 +1305,19 @@ template <> LLSD convert_to_llsd(const LLColor4U& in) template<> -bool convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +bool convert_from_llsd(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; + return false; } } template<> -S32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +S32 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_S32) return sd.asInteger(); @@ -1329,7 +1329,7 @@ S32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& } template<> -U32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +U32 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_U32) return sd.asInteger(); @@ -1341,7 +1341,7 @@ U32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& } template<> -F32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +F32 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_F32) return (F32) sd.asReal(); @@ -1353,7 +1353,7 @@ F32 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& } template<> -std::string convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +std::string convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_STRING) return sd.asString(); @@ -1365,13 +1365,13 @@ std::string convert_from_llsd(const LLSD& sd, eControlType type, co } template<> -LLWString convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +LLWString convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { return utf8str_to_wstring(convert_from_llsd(sd, type, control_name)); } template<> -LLVector3 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +LLVector3 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_VEC3) return (LLVector3)sd; @@ -1383,7 +1383,7 @@ LLVector3 convert_from_llsd(const LLSD& sd, eControlType type, const } template<> -LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_VEC3D) return (LLVector3d)sd; @@ -1395,7 +1395,7 @@ LLVector3d convert_from_llsd(const LLSD& sd, eControlType type, cons } template<> -LLQuaternion convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +LLQuaternion convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_QUAT) return (LLQuaternion)sd; @@ -1407,7 +1407,7 @@ LLQuaternion convert_from_llsd(const LLSD& sd, eControlType type, } template<> -LLRect convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +LLRect convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_RECT) return LLRect(sd); @@ -1420,7 +1420,7 @@ LLRect convert_from_llsd(const LLSD& sd, eControlType type, const std::s template<> -LLColor4 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +LLColor4 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_COL4) { @@ -1452,7 +1452,7 @@ LLColor4 convert_from_llsd(const LLSD& sd, eControlType type, const st } template<> -LLColor3 convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +LLColor3 convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { if (type == TYPE_COL3) return sd; @@ -1464,7 +1464,7 @@ LLColor3 convert_from_llsd(const LLSD& sd, eControlType type, const st } template<> -LLSD convert_from_llsd(const LLSD& sd, eControlType type, const std::string& control_name) +LLSD convert_from_llsd(const LLSD& sd, eControlType type, std::string_view control_name) { return sd; } -- cgit v1.2.3 From e160758b5c32f7b4b9622a5c25c7c53070395c7d Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 1 Mar 2024 13:48:46 +0100 Subject: Convert remaining TRUE/FALSE to true/false --- indra/llxml/llcontrol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llxml/llcontrol.cpp') diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index f665621b66..e626bac7d0 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -1002,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; @@ -1188,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 -- cgit v1.2.3 From a865d423974ea06dffa47798c81e98e7570b02ec Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Tue, 5 Mar 2024 17:03:11 +0100 Subject: viewer#819 Avoid reading the same XML file multiple times --- indra/llxml/llcontrol.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/llxml/llcontrol.cpp') diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index e626bac7d0..71ba2b88bc 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -753,13 +753,13 @@ void LLControlGroup::setUntypedValue(std::string_view 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, const std::string& xml, bool require_declaration, eControlType declare_as) { std::string name; LLXmlTree xml_controls; - if (!xml_controls.parseFile(filename)) + if (!xml_controls.parseString(xml)) { LL_WARNS("Settings") << "Unable to open control file " << filename << LL_ENDL; return 0; @@ -772,7 +772,7 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, bool require return 0; } - U32 validitems = 0; + U32 validitems = 0; S32 version; rootp->getAttributeS32("version", version); @@ -990,24 +990,24 @@ U32 LLControlGroup::saveToFile(const std::string& filename, bool nondefault_only U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values, bool save_values) { LLSD settings; - llifstream infile; - infile.open(filename.c_str()); - if(!infile.is_open()) + + std::string xml = gDirUtilp->getFileContents(filename); + if (xml.empty()) { LL_WARNS("Settings") << "Cannot find file " << filename << " to load." << LL_ENDL; return 0; } - if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(settings, infile)) + std::stringstream stream(xml); + if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(settings, stream)) { - 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, xml, true, TYPE_STRING); } U32 validitems = 0; bool hidefromsettingseditor = false; - + for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr) { LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT; @@ -1019,7 +1019,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v persist = control_map["Persist"].asInteger()? LLControlVariable::PERSIST_NONDFT : LLControlVariable::PERSIST_NO; } - + // Sometimes we want to use the settings system to provide cheap persistence, but we // don't want the settings themselves to be easily manipulated in the UI because // doing so can cause support problems. So we have this option: @@ -1031,7 +1031,7 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v { hidefromsettingseditor = false; } - + // If the control exists just set the value from the input file. LLControlVariable* existing_control = getControl(name); if(existing_control) -- cgit v1.2.3