summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
authorWilliam Todd Stinson <stinson@lindenlab.com>2012-12-04 15:46:10 -0800
committerWilliam Todd Stinson <stinson@lindenlab.com>2012-12-04 15:46:10 -0800
commite2b5e11820cf234d035bdb07f4b145c397fdf67b (patch)
tree4147194fa9f652ede4d08e035cee3e3bdd88d872 /indra/llprimitive
parent1bfeddc0039c7a18cdd878c4fcc3a51529eb1019 (diff)
Implementing string conversion and comparison operator overrides for the LLMaterialID class.
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/llmaterialid.cpp40
-rw-r--r--indra/llprimitive/llmaterialid.h9
2 files changed, 49 insertions, 0 deletions
diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp
index 7df23e5ee0..5c810ddf12 100644
--- a/indra/llprimitive/llmaterialid.cpp
+++ b/indra/llprimitive/llmaterialid.cpp
@@ -29,6 +29,10 @@
#include "llmaterialid.h"
+#include <string>
+
+#include "llformat.h"
+
const LLMaterialID LLMaterialID::null;
LLMaterialID::LLMaterialID()
@@ -71,6 +75,26 @@ bool LLMaterialID::operator != (const LLMaterialID& pOtherMaterialID) const
return (compareToOtherMaterialID(pOtherMaterialID) != 0);
}
+bool LLMaterialID::operator < (const LLMaterialID& pOtherMaterialID) const
+{
+ return (compareToOtherMaterialID(pOtherMaterialID) < 0);
+}
+
+bool LLMaterialID::operator <= (const LLMaterialID& pOtherMaterialID) const
+{
+ return (compareToOtherMaterialID(pOtherMaterialID) <= 0);
+}
+
+bool LLMaterialID::operator > (const LLMaterialID& pOtherMaterialID) const
+{
+ return (compareToOtherMaterialID(pOtherMaterialID) > 0);
+}
+
+bool LLMaterialID::operator >= (const LLMaterialID& pOtherMaterialID) const
+{
+ return (compareToOtherMaterialID(pOtherMaterialID) >= 0);
+}
+
LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID)
{
copyFromOtherMaterialID(pOtherMaterialID);
@@ -111,6 +135,22 @@ LLSD LLMaterialID::asLLSD() const
return materialID;
}
+std::string LLMaterialID::asString() const
+{
+ std::string materialID(reinterpret_cast<const char *>(get()), MATERIAL_ID_SIZE);
+ std::string materialIDString;
+ for (unsigned int i = 0U; i < static_cast<unsigned int>(MATERIAL_ID_SIZE / sizeof(U32)); ++i)
+ {
+ if (i != 0U)
+ {
+ materialIDString += "-";
+ }
+ const U32 *value = reinterpret_cast<const U32*>(&materialID.c_str()[i * sizeof(U32)]);
+ materialIDString += llformat("%08x", *value);
+ }
+ return materialIDString;
+}
+
void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID)
{
llassert(pMaterialID.size() == (MATERIAL_ID_SIZE * sizeof(U8)));
diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h
index 1578172aec..9db4065302 100644
--- a/indra/llprimitive/llmaterialid.h
+++ b/indra/llprimitive/llmaterialid.h
@@ -29,6 +29,8 @@
#define MATERIAL_ID_SIZE 16
+#include <string>
+
class LLMaterialID
{
public:
@@ -41,6 +43,12 @@ public:
bool operator == (const LLMaterialID& pOtherMaterialID) const;
bool operator != (const LLMaterialID& pOtherMaterialID) const;
+
+ bool operator < (const LLMaterialID& pOtherMaterialID) const;
+ bool operator <= (const LLMaterialID& pOtherMaterialID) const;
+ bool operator > (const LLMaterialID& pOtherMaterialID) const;
+ bool operator >= (const LLMaterialID& pOtherMaterialID) const;
+
LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID);
bool isNull() const;
@@ -50,6 +58,7 @@ public:
void clear();
LLSD asLLSD() const;
+ std::string asString() const;
static const LLMaterialID null;