diff options
Diffstat (limited to 'linden/indra/llcommon/llsd.cpp')
-rw-r--r-- | linden/indra/llcommon/llsd.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/linden/indra/llcommon/llsd.cpp b/linden/indra/llcommon/llsd.cpp index a6e504a..fa0531b 100644 --- a/linden/indra/llcommon/llsd.cpp +++ b/linden/indra/llcommon/llsd.cpp | |||
@@ -12,12 +12,12 @@ | |||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | 12 | * ("GPL"), unless you have obtained a separate licensing agreement |
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | 13 | * ("Other License"), formally executed by you and Linden Lab. Terms of |
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | 14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or |
15 | * online at http://secondlife.com/developers/opensource/gplv2 | 15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 |
16 | * | 16 | * |
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlife.com/developers/opensource/flossexception | 20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception |
21 | * | 21 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 22 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 23 | * that you have read and understood your obligations described above, |
@@ -35,6 +35,7 @@ | |||
35 | #include "llerror.h" | 35 | #include "llerror.h" |
36 | #include "../llmath/llmath.h" | 36 | #include "../llmath/llmath.h" |
37 | #include "llformat.h" | 37 | #include "llformat.h" |
38 | #include "llsdserialize.h" | ||
38 | 39 | ||
39 | #ifndef LL_RELEASE_FOR_DOWNLOAD | 40 | #ifndef LL_RELEASE_FOR_DOWNLOAD |
40 | #define NAME_UNNAMED_NAMESPACE | 41 | #define NAME_UNNAMED_NAMESPACE |
@@ -765,6 +766,44 @@ const LLSD& LLSD::operator[](Integer i) const | |||
765 | U32 LLSD::allocationCount() { return Impl::sAllocationCount; } | 766 | U32 LLSD::allocationCount() { return Impl::sAllocationCount; } |
766 | U32 LLSD::outstandingCount() { return Impl::sOutstandingCount; } | 767 | U32 LLSD::outstandingCount() { return Impl::sOutstandingCount; } |
767 | 768 | ||
769 | static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat) | ||
770 | { | ||
771 | // sStorage is used to hold the string representation of the llsd last | ||
772 | // passed into this function. If this function is never called (the | ||
773 | // normal case when not debugging), nothing is allocated. Otherwise | ||
774 | // sStorage will point to the result of the last call. This will actually | ||
775 | // be one leak, but since this is used only when running under the | ||
776 | // debugger, it should not be an issue. | ||
777 | static char *sStorage = NULL; | ||
778 | delete[] sStorage; | ||
779 | std::string out_string; | ||
780 | { | ||
781 | std::ostringstream out; | ||
782 | if (useXMLFormat) | ||
783 | out << LLSDXMLStreamer(llsd); | ||
784 | else | ||
785 | out << LLSDNotationStreamer(llsd); | ||
786 | out_string = out.str(); | ||
787 | } | ||
788 | int len = out_string.length(); | ||
789 | sStorage = new char[len + 1]; | ||
790 | memcpy(sStorage, out_string.c_str(), len); | ||
791 | sStorage[len] = '\0'; | ||
792 | return sStorage; | ||
793 | } | ||
794 | |||
795 | /// Returns XML version of llsd -- only to be called from debugger | ||
796 | const char *LLSD::dumpXML(const LLSD &llsd) | ||
797 | { | ||
798 | return llsd_dump(llsd, true); | ||
799 | } | ||
800 | |||
801 | /// Returns Notation version of llsd -- only to be called from debugger | ||
802 | const char *LLSD::dump(const LLSD &llsd) | ||
803 | { | ||
804 | return llsd_dump(llsd, false); | ||
805 | } | ||
806 | |||
768 | LLSD::map_iterator LLSD::beginMap() { return makeMap(impl).beginMap(); } | 807 | LLSD::map_iterator LLSD::beginMap() { return makeMap(impl).beginMap(); } |
769 | LLSD::map_iterator LLSD::endMap() { return makeMap(impl).endMap(); } | 808 | LLSD::map_iterator LLSD::endMap() { return makeMap(impl).endMap(); } |
770 | LLSD::map_const_iterator LLSD::beginMap() const { return safe(impl).beginMap(); } | 809 | LLSD::map_const_iterator LLSD::beginMap() const { return safe(impl).beginMap(); } |