From 518f92126f18d5f4b8ee8eb287500fe5a7e17c99 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Wed, 23 Mar 2016 11:50:39 -0400
Subject: improve settings error log, and make type conversion methods static

---
 indra/llxml/llcontrol.cpp | 43 +++++++++++++++++++++++--------------------
 indra/llxml/llcontrol.h   |  7 ++++---
 2 files changed, 27 insertions(+), 23 deletions(-)

(limited to 'indra/llxml')

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();
-- 
cgit v1.2.3