summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llsd.cpp39
-rw-r--r--indra/llcommon/llsd.h10
2 files changed, 49 insertions, 0 deletions
diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp
index 829ea25e38..ecca4c9b71 100644
--- a/indra/llcommon/llsd.cpp
+++ b/indra/llcommon/llsd.cpp
@@ -35,6 +35,7 @@
#include "llerror.h"
#include "../llmath/llmath.h"
#include "llformat.h"
+#include "llsdserialize.h"
#ifndef LL_RELEASE_FOR_DOWNLOAD
#define NAME_UNNAMED_NAMESPACE
@@ -765,6 +766,44 @@ const LLSD& LLSD::operator[](Integer i) const
U32 LLSD::allocationCount() { return Impl::sAllocationCount; }
U32 LLSD::outstandingCount() { return Impl::sOutstandingCount; }
+static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat)
+{
+ // sStorage is used to hold the string representation of the llsd last
+ // passed into this function. If this function is never called (the
+ // normal case when not debugging), nothing is allocated. Otherwise
+ // sStorage will point to the result of the last call. This will actually
+ // be one leak, but since this is used only when running under the
+ // debugger, it should not be an issue.
+ static char *sStorage = NULL;
+ delete[] sStorage;
+ std::string out_string;
+ {
+ std::ostringstream out;
+ if (useXMLFormat)
+ out << LLSDXMLStreamer(llsd);
+ else
+ out << LLSDNotationStreamer(llsd);
+ out_string = out.str();
+ }
+ int len = out_string.length();
+ sStorage = new char[len + 1];
+ memcpy(sStorage, out_string.c_str(), len);
+ sStorage[len] = '\0';
+ return sStorage;
+}
+
+/// Returns XML version of llsd -- only to be called from debugger
+const char *LLSD::dumpXML(const LLSD &llsd)
+{
+ return llsd_dump(llsd, true);
+}
+
+/// Returns Notation version of llsd -- only to be called from debugger
+const char *LLSD::dump(const LLSD &llsd)
+{
+ return llsd_dump(llsd, false);
+}
+
LLSD::map_iterator LLSD::beginMap() { return makeMap(impl).beginMap(); }
LLSD::map_iterator LLSD::endMap() { return makeMap(impl).endMap(); }
LLSD::map_const_iterator LLSD::beginMap() const { return safe(impl).beginMap(); }
diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h
index 65ba7ddc4f..1ba57b1e95 100644
--- a/indra/llcommon/llsd.h
+++ b/indra/llcommon/llsd.h
@@ -331,6 +331,16 @@ public:
static U32 allocationCount(); ///< how many Impls have been made
static U32 outstandingCount(); ///< how many Impls are still alive
//@}
+
+private:
+ /** @name Debugging Interface */
+ //@{
+ /// Returns XML version of llsd -- only to be called from debugger
+ static const char *dumpXML(const LLSD &llsd);
+
+ /// Returns Notation version of llsd -- only to be called from debugger
+ static const char *dump(const LLSD &llsd);
+ //@}
};
struct llsd_select_bool : public std::unary_function<LLSD, LLSD::Boolean>