diff options
author | Christian Goetze <cg@lindenlab.com> | 2007-12-01 01:29:28 +0000 |
---|---|---|
committer | Christian Goetze <cg@lindenlab.com> | 2007-12-01 01:29:28 +0000 |
commit | 7b7dd4e6f61aa731ef7f9f255014f5b76d5b9fec (patch) | |
tree | 08bf4cb9354f975940b83cd695a2aa8bb8d74870 /indra/llcommon/llsd.cpp | |
parent | 5c53c187fff573ef73a643949b3bded1084b0983 (diff) |
svn merge -r74808:74832 svn+ssh://svn/svn/linden/branches/qa-dpo-9a
Diffstat (limited to 'indra/llcommon/llsd.cpp')
-rw-r--r-- | indra/llcommon/llsd.cpp | 39 |
1 files changed, 39 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(); } |