summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llsd.cpp')
-rw-r--r--indra/llcommon/llsd.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp
index 77fe545c3f..1058ab385b 100644
--- a/indra/llcommon/llsd.cpp
+++ b/indra/llcommon/llsd.cpp
@@ -974,6 +974,31 @@ void LLSD::clear() { Impl::assignUndefined(impl); }
LLSD::Type LLSD::type() const { return safe(impl).type(); }
+bool LLSD::isEmpty() const
+{
+ switch (type())
+ {
+ case TypeUndefined:
+ return true; // Always empty
+ case TypeBinary:
+ return !asBoolean(); // Empty when default
+ case TypeInteger:
+ return !asInteger(); // Empty when default
+ case TypeReal:
+ return !asReal(); // Empty when default
+ case TypeString:
+ case TypeURI:
+ return asString().empty(); // Empty natively
+ case TypeArray:
+ case TypeMap:
+ return !size(); // Empty natively
+ default:;
+ }
+ // All other value types (TypeDate) don't have default values so can't be empty
+ return false;
+}
+
+
// Scalar Constructors
LLSD::LLSD(Boolean v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }
LLSD::LLSD(Integer v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); }