summaryrefslogtreecommitdiff
path: root/indra/llprimitive
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llprimitive')
-rw-r--r--indra/llprimitive/llmaterialid.cpp46
-rw-r--r--indra/llprimitive/llmaterialid.h9
2 files changed, 45 insertions, 10 deletions
diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp
index bbbbf0ced3..590f5cd91f 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,15 +75,30 @@ bool LLMaterialID::operator != (const LLMaterialID& pOtherMaterialID) const
return (compareToOtherMaterialID(pOtherMaterialID) != 0);
}
-LLMaterialID& LLMaterialID::operator = (const LLMaterialID& pOtherMaterialID)
+bool LLMaterialID::operator < (const LLMaterialID& pOtherMaterialID) const
{
- copyFromOtherMaterialID(pOtherMaterialID);
- return (*this);
+ return (compareToOtherMaterialID(pOtherMaterialID) < 0);
}
-bool LLMaterialID::operator < (const LLMaterialID& pOtherMaterialID) const
+bool LLMaterialID::operator <= (const LLMaterialID& pOtherMaterialID) const
{
- return (compareToOtherMaterialID(pOtherMaterialID) < 0);
+ 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);
+ return (*this);
}
bool LLMaterialID::isNull() const
@@ -119,13 +138,13 @@ LLSD LLMaterialID::asLLSD() const
std::string LLMaterialID::asString() const
{
std::string materialIDString;
- for (unsigned int i = 0U; i < 4; ++i)
+ 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*>(&mID[i * 4]);
+ const U32 *value = reinterpret_cast<const U32*>(&get()[i * sizeof(U32)]);
materialIDString += llformat("%08x", *value);
}
return materialIDString;
@@ -139,10 +158,19 @@ void LLMaterialID::parseFromBinary (const LLSD::Binary& pMaterialID)
void LLMaterialID::copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID)
{
- memcpy(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8));
+ memcpy(mID, pOtherMaterialID.get(), MATERIAL_ID_SIZE * sizeof(U8));
}
int LLMaterialID::compareToOtherMaterialID(const LLMaterialID& pOtherMaterialID) const
{
- return memcmp(mID, pOtherMaterialID.mID, MATERIAL_ID_SIZE * sizeof(U8));
+ int retVal = 0;
+
+ for (unsigned int i = 0U; (retVal == 0) && (i < static_cast<unsigned int>(MATERIAL_ID_SIZE / sizeof(U32))); ++i)
+ {
+ const U32 *thisValue = reinterpret_cast<const U32*>(&get()[i * sizeof(U32)]);
+ const U32 *otherValue = reinterpret_cast<const U32*>(&pOtherMaterialID.get()[i * sizeof(U32)]);
+ retVal = ((*thisValue < *otherValue) ? -1 : ((*thisValue > *otherValue) ? 1 : 0));
+ }
+
+ return retVal;
}
diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h
index ffefc9f11c..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,8 +43,13 @@ public:
bool operator == (const LLMaterialID& pOtherMaterialID) const;
bool operator != (const LLMaterialID& pOtherMaterialID) const;
- LLMaterialID& operator = (const LLMaterialID& pOtherMaterialID);
+
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;