summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2016-03-23 11:50:39 -0400
committerOz Linden <oz@lindenlab.com>2016-03-23 11:50:39 -0400
commit518f92126f18d5f4b8ee8eb287500fe5a7e17c99 (patch)
tree5d58fc3ba9ec7e0f6097b0644ec65fbbebd9cfbc
parent7bbf2ec9f82c9818d02493c7b877e68ca97261fc (diff)
improve settings error log, and make type conversion methods static
-rw-r--r--indra/llxml/llcontrol.cpp43
-rw-r--r--indra/llxml/llcontrol.h7
-rw-r--r--indra/newview/llpresetsmanager.cpp2
-rw-r--r--indra/newview/llviewercontrollistener.cpp6
4 files changed, 31 insertions, 27 deletions
diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp
index 4e3d0ab392..20ab1a7ad3 100644
--- a/indra/llxml/llcontrol.cpp
+++ b/indra/llxml/llcontrol.cpp
@@ -334,20 +334,23 @@ LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name)
////////////////////////////////////////////////////////////////////////////
+// Must match the type definition in llcontrol.h
+const std::string LLControlGroup::mTypeString[TYPE_COUNT] = { "U32"
+ ,"S32"
+ ,"F32"
+ ,"Boolean"
+ ,"String"
+ ,"Vector3"
+ ,"Vector3D"
+ ,"Rect"
+ ,"Color4"
+ ,"Color3"
+ ,"LLSD"
+ };
+
LLControlGroup::LLControlGroup(const std::string& name)
: LLInstanceTracker<LLControlGroup, std::string>(name)
{
- mTypeString[TYPE_U32] = "U32";
- mTypeString[TYPE_S32] = "S32";
- mTypeString[TYPE_F32] = "F32";
- mTypeString[TYPE_BOOLEAN] = "Boolean";
- mTypeString[TYPE_STRING] = "String";
- mTypeString[TYPE_VEC3] = "Vector3";
- mTypeString[TYPE_VEC3D] = "Vector3D";
- mTypeString[TYPE_RECT] = "Rect";
- mTypeString[TYPE_COL4] = "Color4";
- mTypeString[TYPE_COL3] = "Color3";
- mTypeString[TYPE_LLSD] = "LLSD";
}
LLControlGroup::~LLControlGroup()
@@ -1170,7 +1173,7 @@ bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::strin
return sd.asBoolean();
else
{
- CONTROL_ERRS << "Invalid BOOL value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid BOOL value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return FALSE;
}
}
@@ -1182,7 +1185,7 @@ S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string&
return sd.asInteger();
else
{
- CONTROL_ERRS << "Invalid S32 value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid S32 value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return 0;
}
}
@@ -1194,7 +1197,7 @@ U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string&
return sd.asInteger();
else
{
- CONTROL_ERRS << "Invalid U32 value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid U32 value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return 0;
}
}
@@ -1206,7 +1209,7 @@ F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string&
return (F32) sd.asReal();
else
{
- CONTROL_ERRS << "Invalid F32 value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid F32 value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return 0.0f;
}
}
@@ -1218,7 +1221,7 @@ std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, co
return sd.asString();
else
{
- CONTROL_ERRS << "Invalid string value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid string value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return LLStringUtil::null;
}
}
@@ -1236,7 +1239,7 @@ LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const
return (LLVector3)sd;
else
{
- CONTROL_ERRS << "Invalid LLVector3 value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid LLVector3 value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return LLVector3::zero;
}
}
@@ -1248,7 +1251,7 @@ LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, cons
return (LLVector3d)sd;
else
{
- CONTROL_ERRS << "Invalid LLVector3d value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid LLVector3d value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return LLVector3d::zero;
}
}
@@ -1260,7 +1263,7 @@ LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::s
return LLRect(sd);
else
{
- CONTROL_ERRS << "Invalid rect value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid rect value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return LLRect::null;
}
}
@@ -1305,7 +1308,7 @@ LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const st
return sd;
else
{
- CONTROL_ERRS << "Invalid LLColor3 value for " << control_name << ": " << sd << LL_ENDL;
+ CONTROL_ERRS << "Invalid LLColor3 value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
return LLColor3::white;
}
}
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index 04575d81e0..77065dcf8d 100644
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -70,6 +70,7 @@ class LLVector3d;
class LLColor4;
class LLColor3;
+// if this is changed, also modify mTypeString in llcontrol.h
typedef enum e_control_type
{
TYPE_U32 = 0,
@@ -190,11 +191,11 @@ class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string>
protected:
typedef std::map<std::string, LLControlVariablePtr > ctrl_name_table_t;
ctrl_name_table_t mNameTable;
- std::string mTypeString[TYPE_COUNT];
+ static const std::string mTypeString[TYPE_COUNT];
public:
- eControlType typeStringToEnum(const std::string& typestr);
- std::string typeEnumToString(eControlType typeenum);
+ static eControlType typeStringToEnum(const std::string& typestr);
+ static std::string typeEnumToString(eControlType typeenum);
LLControlGroup(const std::string& name);
~LLControlGroup();
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 152001eb46..d95546f11d 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -180,7 +180,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
std::string ctrl_name = *it;
LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
std::string comment = ctrl->getComment();
- std::string type = gSavedSettings.typeEnumToString(ctrl->type());
+ std::string type = LLControlGroup::typeEnumToString(ctrl->type());
LLSD value = ctrl->getValue();
paramsData[ctrl_name]["Comment"] = comment;
diff --git a/indra/newview/llviewercontrollistener.cpp b/indra/newview/llviewercontrollistener.cpp
index 361b96221c..d2484b2b23 100644
--- a/indra/newview/llviewercontrollistener.cpp
+++ b/indra/newview/llviewercontrollistener.cpp
@@ -121,7 +121,7 @@ struct Info
if (control)
{
response["name"] = control->getName();
- response["type"] = group->typeEnumToString(control->type());
+ response["type"] = LLControlGroup::typeEnumToString(control->type());
response["value"] = control->get();
response["comment"] = control->getComment();
}
@@ -167,7 +167,7 @@ void LLViewerControlListener::toggle(LLSD const & request)
info.response.error(STRINGIZE("toggle of non-boolean '" << info.groupname
<< "' control '" << info.key
<< "', type is "
- << info.group->typeEnumToString(info.control->type())));
+ << LLControlGroup::typeEnumToString(info.control->type())));
}
}
@@ -199,7 +199,7 @@ struct CollectVars: public LLControlGroup::ApplyFunctor
{
vars.append(LLSDMap
("name", name)
- ("type", mGroup->typeEnumToString(control->type()))
+ ("type", LLControlGroup::typeEnumToString(control->type()))
("value", control->get())
("comment", control->getComment()));
}