summaryrefslogtreecommitdiff
path: root/indra/llxml
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llxml')
-rw-r--r--indra/llxml/CMakeLists.txt1
-rw-r--r--indra/llxml/llcontrol.cpp69
-rw-r--r--indra/llxml/llcontrol.h21
-rw-r--r--indra/llxml/llcontrolgroupreader.h80
-rw-r--r--indra/llxml/llxmltree.cpp16
-rw-r--r--indra/llxml/llxmltree.h8
6 files changed, 95 insertions, 100 deletions
diff --git a/indra/llxml/CMakeLists.txt b/indra/llxml/CMakeLists.txt
index 17400a203e..013a422d35 100644
--- a/indra/llxml/CMakeLists.txt
+++ b/indra/llxml/CMakeLists.txt
@@ -28,7 +28,6 @@ set(llxml_HEADER_FILES
CMakeLists.txt
llcontrol.h
- llcontrolgroupreader.h
llxmlnode.h
llxmlparser.h
llxmltree.h
diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp
index ccf4f3ddf5..ead8634df4 100644
--- a/indra/llxml/llcontrol.cpp
+++ b/indra/llxml/llcontrol.cpp
@@ -40,6 +40,7 @@
#include "v4coloru.h"
#include "v4color.h"
#include "v3color.h"
+#include "llquaternion.h"
#include "llrect.h"
#include "llxmltree.h"
#include "llsdserialize.h"
@@ -125,6 +126,9 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b)
case TYPE_VEC3D:
result = LLVector3d(a) == LLVector3d(b);
break;
+ case TYPE_QUAT:
+ result = LLQuaternion(a) == LLQuaternion(b);
+ break;
case TYPE_RECT:
result = LLRect(a) == LLRect(b);
break;
@@ -361,6 +365,7 @@ const std::string LLControlGroup::mTypeString[TYPE_COUNT] = { "U32"
,"String"
,"Vector3"
,"Vector3D"
+ ,"Quaternion"
,"Rect"
,"Color4"
,"Color3"
@@ -523,6 +528,11 @@ LLControlVariable* LLControlGroup::declareVec3d(const std::string& name, const L
return declareControl(name, TYPE_VEC3D, initial_val.getValue(), comment, persist);
}
+LLControlVariable* LLControlGroup::declareQuat(const std::string& name, const LLQuaternion &initial_val, const std::string& comment, LLControlVariable::ePersist persist)
+{
+ return declareControl(name, TYPE_QUAT, initial_val.getValue(), comment, persist);
+}
+
LLControlVariable* LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_RECT, initial_val.getValue(), comment, persist);
@@ -600,6 +610,11 @@ LLVector3d LLControlGroup::getVector3d(const std::string& name)
return get<LLVector3d>(name);
}
+LLQuaternion LLControlGroup::getQuaternion(const std::string& name)
+{
+ return get<LLQuaternion>(name);
+}
+
LLRect LLControlGroup::getRect(const std::string& name)
{
return get<LLRect>(name);
@@ -626,6 +641,24 @@ LLSD LLControlGroup::getLLSD(const std::string& name)
return get<LLSD>(name);
}
+LLSD LLControlGroup::asLLSD(bool diffs_only)
+{
+ // Dump all stored values as LLSD
+ LLSD result = LLSD::emptyArray();
+ for (ctrl_name_table_t::iterator iter = mNameTable.begin();
+ iter != mNameTable.end(); iter++)
+ {
+ LLControlVariable *control = iter->second;
+ if (!control || control->isType(TYPE_STRING) || (diffs_only && control->isDefault()))
+ {
+ continue;
+ }
+ const std::string& name = iter->first;
+ result[name] = getLLSD(name);
+ }
+ return result;
+}
+
BOOL LLControlGroup::controlExists(const std::string& name)
{
ctrl_name_table_t::iterator iter = mNameTable.find(name);
@@ -677,6 +710,11 @@ void LLControlGroup::setVector3d(const std::string& name, const LLVector3d &val)
set(name, val);
}
+void LLControlGroup::setQuaternion(const std::string& name, const LLQuaternion &val)
+{
+ set(name, val);
+}
+
void LLControlGroup::setRect(const std::string& name, const LLRect &val)
{
set(name, val);
@@ -859,6 +897,16 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
validitems++;
}
break;
+ case TYPE_QUAT:
+ {
+ LLQuaternion quat;
+
+ child_nodep->getAttributeQuat("value", quat);
+
+ control->set(quat.getValue());
+ validitems++;
+ }
+ break;
case TYPE_RECT:
{
//RN: hack to support reading rectangles from a string
@@ -1201,6 +1249,11 @@ template <> eControlType get_control_type<LLVector3d>()
return TYPE_VEC3D;
}
+template <> eControlType get_control_type<LLQuaternion>()
+{
+ return TYPE_QUAT;
+}
+
template <> eControlType get_control_type<LLRect>()
{
return TYPE_RECT;
@@ -1236,6 +1289,10 @@ template <> LLSD convert_to_llsd<LLVector3d>(const LLVector3d& in)
{
return in.getValue();
}
+template <> LLSD convert_to_llsd<LLQuaternion>(const LLQuaternion& in)
+{
+ return in.getValue();
+}
template <> LLSD convert_to_llsd<LLRect>(const LLRect& in)
{
@@ -1349,6 +1406,18 @@ 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)
+{
+ if (type == TYPE_QUAT)
+ return (LLQuaternion)sd;
+ else
+ {
+ CONTROL_ERRS << "Invalid LLQuaternion value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
+ return LLQuaternion();
+ }
+}
+
+template<>
LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name)
{
if (type == TYPE_RECT)
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index de0d366492..19508becc3 100644
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -34,8 +34,6 @@
#include "llrefcount.h"
#include "llinstancetracker.h"
-#include "llcontrolgroupreader.h"
-
#include <vector>
// *NOTE: boost::visit_each<> generates warning 4675 on .net 2003
@@ -67,6 +65,7 @@
class LLVector3;
class LLVector3d;
+class LLQuaternion;
class LLColor4;
class LLColor3;
@@ -80,6 +79,7 @@ typedef enum e_control_type
TYPE_STRING,
TYPE_VEC3,
TYPE_VEC3D,
+ TYPE_QUAT,
TYPE_RECT,
TYPE_COL4,
TYPE_COL3,
@@ -200,8 +200,6 @@ public:
LLControlGroup(const std::string& name);
~LLControlGroup();
void cleanup();
-
- typedef LLInstanceTracker<LLControlGroup, std::string>::instance_iter instance_iter;
LLControlVariablePtr getControl(const std::string& name);
@@ -220,6 +218,7 @@ public:
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);
+ LLControlVariable* declareQuat(const std::string& name, const LLQuaternion &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
@@ -234,15 +233,17 @@ public:
LLWString getWString(const std::string& name);
LLVector3 getVector3(const std::string& name);
- LLVector3d getVector3d(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);
LLColor4 getColor(const std::string& name);
LLColor4 getColor4(const std::string& name);
LLColor3 getColor3(const std::string& name);
+ LLSD asLLSD(bool diffs_only);
+
// generic getter
template<typename T> T get(const std::string& name)
{
@@ -270,6 +271,7 @@ public:
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);
@@ -436,7 +438,8 @@ template <> eControlType get_control_type<bool>();
//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>();
+template <> eControlType get_control_type<LLVector3d>();
+template <> eControlType get_control_type<LLQuaternion>();
template <> eControlType get_control_type<LLRect>();
template <> eControlType get_control_type<LLColor4>();
template <> eControlType get_control_type<LLColor3>();
@@ -444,7 +447,8 @@ template <> eControlType get_control_type<LLSD>();
template <> LLSD convert_to_llsd<U32>(const U32& in);
template <> LLSD convert_to_llsd<LLVector3>(const LLVector3& in);
-template <> LLSD convert_to_llsd<LLVector3d>(const LLVector3d& in);
+template <> LLSD convert_to_llsd<LLVector3d>(const LLVector3d& in);
+template <> LLSD convert_to_llsd<LLQuaternion>(const LLQuaternion& in);
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);
@@ -453,6 +457,7 @@ template<> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlTy
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);
diff --git a/indra/llxml/llcontrolgroupreader.h b/indra/llxml/llcontrolgroupreader.h
deleted file mode 100644
index 6a27a65499..0000000000
--- a/indra/llxml/llcontrolgroupreader.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * @file llcontrolgroupreader.h
- * @brief Interface providing readonly access to LLControlGroup (intended for unit testing)
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLCONTROLGROUPREADER_H
-#define LL_LLCONTROLGROUPREADER_H
-
-#include "stdtypes.h"
-#include <string>
-
-#include "v3math.h"
-#include "v3dmath.h"
-#include "v3color.h"
-#include "v4color.h"
-#include "llrect.h"
-
-class LLControlGroupReader
-{
-public:
- LLControlGroupReader() {}
- virtual ~LLControlGroupReader() {}
-
- virtual std::string getString(const std::string& name) { return ""; }
- virtual LLWString getWString(const std::string& name) { return LLWString(); }
- virtual std::string getText(const std::string& name) { return ""; }
- virtual LLVector3 getVector3(const std::string& name) { return LLVector3(); }
- virtual LLVector3d getVector3d(const std::string& name) { return LLVector3d(); }
- virtual LLRect getRect(const std::string& name) { return LLRect(); }
- virtual BOOL getBOOL(const std::string& name) { return FALSE; }
- virtual S32 getS32(const std::string& name) { return 0; }
- virtual F32 getF32(const std::string& name) {return 0.0f; }
- virtual U32 getU32(const std::string& name) {return 0; }
- virtual LLSD getLLSD(const std::string& name) { return LLSD(); }
-
- virtual LLColor4 getColor(const std::string& name) { return LLColor4(); }
- virtual LLColor4 getColor4(const std::string& name) { return LLColor4(); }
- virtual LLColor3 getColor3(const std::string& name) { return LLColor3(); }
-
- virtual void setBOOL(const std::string& name, BOOL val) {}
- virtual void setS32(const std::string& name, S32 val) {}
- virtual void setF32(const std::string& name, F32 val) {}
- virtual void setU32(const std::string& name, U32 val) {}
- virtual void setString(const std::string& name, const std::string& val) {}
- virtual void setVector3(const std::string& name, const LLVector3 &val) {}
- virtual void setVector3d(const std::string& name, const LLVector3d &val) {}
- virtual void setRect(const std::string& name, const LLRect &val) {}
- virtual void setColor4(const std::string& name, const LLColor4 &val) {}
- virtual void setLLSD(const std::string& name, const LLSD& val) {}
-};
-
-#endif /* LL_LLCONTROLGROUPREADER_H */
-
-
-
-
-
-
-
diff --git a/indra/llxml/llxmltree.cpp b/indra/llxml/llxmltree.cpp
index ca98953f92..ed9c07e1db 100644
--- a/indra/llxml/llxmltree.cpp
+++ b/indra/llxml/llxmltree.cpp
@@ -111,9 +111,11 @@ LLXmlTreeNode::~LLXmlTreeNode()
attribute_map_t::iterator iter;
for (iter=mAttributes.begin(); iter != mAttributes.end(); iter++)
delete iter->second;
- child_list_t::iterator child_iter;
- for (child_iter=mChildList.begin(); child_iter != mChildList.end(); child_iter++)
- delete *child_iter;
+ for(LLXmlTreeNode* node : mChildren)
+ {
+ delete node;
+ }
+ mChildren.clear();
}
void LLXmlTreeNode::dump( const std::string& prefix )
@@ -149,15 +151,15 @@ void LLXmlTreeNode::addAttribute(const std::string& name, const std::string& val
LLXmlTreeNode* LLXmlTreeNode::getFirstChild()
{
- mChildListIter = mChildList.begin();
+ mChildrenIter = mChildren.begin();
return getNextChild();
}
LLXmlTreeNode* LLXmlTreeNode::getNextChild()
{
- if (mChildListIter == mChildList.end())
+ if (mChildrenIter == mChildren.end())
return 0;
else
- return *mChildListIter++;
+ return *mChildrenIter++;
}
LLXmlTreeNode* LLXmlTreeNode::getChildByName(const std::string& name)
@@ -184,7 +186,7 @@ void LLXmlTreeNode::appendContents(const std::string& str)
void LLXmlTreeNode::addChild(LLXmlTreeNode* child)
{
llassert( child );
- mChildList.push_back( child );
+ mChildren.push_back( child );
// Add a name mapping to this node
LLStdStringHandle tableptr = mTree->mNodeNames.insert(child->mName);
diff --git a/indra/llxml/llxmltree.h b/indra/llxml/llxmltree.h
index a82fee0416..3e425c3870 100644
--- a/indra/llxml/llxmltree.h
+++ b/indra/llxml/llxmltree.h
@@ -151,7 +151,7 @@ public:
LLXmlTreeNode* getParent() { return mParent; }
LLXmlTreeNode* getFirstChild();
LLXmlTreeNode* getNextChild();
- S32 getChildCount() { return (S32)mChildList.size(); }
+ S32 getChildCount() { return (S32)mChildren.size(); }
LLXmlTreeNode* getChildByName( const std::string& name ); // returns first child with name, NULL if none
LLXmlTreeNode* getNextNamedChild(); // returns next child with name, NULL if none
@@ -177,9 +177,9 @@ private:
std::string mName;
std::string mContents;
- typedef std::list<class LLXmlTreeNode *> child_list_t;
- child_list_t mChildList;
- child_list_t::iterator mChildListIter;
+ typedef std::vector<class LLXmlTreeNode *> children_t;
+ children_t mChildren;
+ children_t::iterator mChildrenIter;
typedef std::multimap<LLStdStringHandle, LLXmlTreeNode *> child_map_t;
child_map_t mChildMap; // for fast name lookups