diff options
Diffstat (limited to 'linden/indra/llcommon/llsdserialize.h')
-rw-r--r-- | linden/indra/llcommon/llsdserialize.h | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/linden/indra/llcommon/llsdserialize.h b/linden/indra/llcommon/llsdserialize.h index f5282b4..94ad824 100644 --- a/linden/indra/llcommon/llsdserialize.h +++ b/linden/indra/llcommon/llsdserialize.h | |||
@@ -83,6 +83,18 @@ public: | |||
83 | */ | 83 | */ |
84 | S32 parse(std::istream& istr, LLSD& data, S32 max_bytes); | 84 | S32 parse(std::istream& istr, LLSD& data, S32 max_bytes); |
85 | 85 | ||
86 | /** Like parse(), but uses a different call (istream.getline()) to read by lines | ||
87 | * This API is better suited for XML, where the parse cannot tell | ||
88 | * where the document actually ends. | ||
89 | */ | ||
90 | S32 parseLines(std::istream& istr, LLSD& data); | ||
91 | |||
92 | /** | ||
93 | * @brief Resets the parser so parse() or parseLines() can be called again for another <llsd> chunk. | ||
94 | */ | ||
95 | void reset() { doReset(); }; | ||
96 | |||
97 | |||
86 | protected: | 98 | protected: |
87 | /** | 99 | /** |
88 | * @brief Pure virtual base for doing the parse. | 100 | * @brief Pure virtual base for doing the parse. |
@@ -100,6 +112,11 @@ protected: | |||
100 | */ | 112 | */ |
101 | virtual S32 doParse(std::istream& istr, LLSD& data) const = 0; | 113 | virtual S32 doParse(std::istream& istr, LLSD& data) const = 0; |
102 | 114 | ||
115 | /** | ||
116 | * @brief Virtual default function for resetting the parser | ||
117 | */ | ||
118 | virtual void doReset() {}; | ||
119 | |||
103 | /* @name Simple istream helper methods | 120 | /* @name Simple istream helper methods |
104 | * | 121 | * |
105 | * These helper methods exist to help correctly use the | 122 | * These helper methods exist to help correctly use the |
@@ -191,6 +208,11 @@ protected: | |||
191 | * @brief The maximum number of bytes left to be parsed. | 208 | * @brief The maximum number of bytes left to be parsed. |
192 | */ | 209 | */ |
193 | mutable S32 mMaxBytesLeft; | 210 | mutable S32 mMaxBytesLeft; |
211 | |||
212 | /** | ||
213 | * @brief Use line-based reading to get text | ||
214 | */ | ||
215 | bool mParseLines; | ||
194 | }; | 216 | }; |
195 | 217 | ||
196 | /** | 218 | /** |
@@ -301,6 +323,11 @@ protected: | |||
301 | */ | 323 | */ |
302 | virtual S32 doParse(std::istream& istr, LLSD& data) const; | 324 | virtual S32 doParse(std::istream& istr, LLSD& data) const; |
303 | 325 | ||
326 | /** | ||
327 | * @brief Virtual default function for resetting the parser | ||
328 | */ | ||
329 | virtual void doReset(); | ||
330 | |||
304 | private: | 331 | private: |
305 | class Impl; | 332 | class Impl; |
306 | Impl& impl; | 333 | Impl& impl; |
@@ -674,7 +701,7 @@ public: | |||
674 | U32 options = LLSDFormatter::OPTIONS_NONE); | 701 | U32 options = LLSDFormatter::OPTIONS_NONE); |
675 | 702 | ||
676 | /** | 703 | /** |
677 | * @breif Examine a stream, and parse 1 sd object out based on contents. | 704 | * @brief Examine a stream, and parse 1 sd object out based on contents. |
678 | * | 705 | * |
679 | * @param sd [out] The data found on the stream | 706 | * @param sd [out] The data found on the stream |
680 | * @param str The incoming stream | 707 | * @param str The incoming stream |
@@ -718,13 +745,23 @@ public: | |||
718 | return f->format(sd, str, LLSDFormatter::OPTIONS_PRETTY); | 745 | return f->format(sd, str, LLSDFormatter::OPTIONS_PRETTY); |
719 | } | 746 | } |
720 | 747 | ||
721 | static S32 fromXML(LLSD& sd, std::istream& str) | 748 | static S32 fromXMLEmbedded(LLSD& sd, std::istream& str) |
722 | { | 749 | { |
723 | // no need for max_bytes since xml formatting is not | 750 | // no need for max_bytes since xml formatting is not |
724 | // subvertable by bad sizes. | 751 | // subvertable by bad sizes. |
725 | LLPointer<LLSDXMLParser> p = new LLSDXMLParser; | 752 | LLPointer<LLSDXMLParser> p = new LLSDXMLParser; |
726 | return p->parse(str, sd, LLSDSerialize::SIZE_UNLIMITED); | 753 | return p->parse(str, sd, LLSDSerialize::SIZE_UNLIMITED); |
727 | } | 754 | } |
755 | static S32 fromXMLDocument(LLSD& sd, std::istream& str) | ||
756 | { | ||
757 | LLPointer<LLSDXMLParser> p = new LLSDXMLParser(); | ||
758 | return p->parseLines(str, sd); | ||
759 | } | ||
760 | static S32 fromXML(LLSD& sd, std::istream& str) | ||
761 | { | ||
762 | return fromXMLEmbedded(sd, str); | ||
763 | // return fromXMLDocument(sd, str); | ||
764 | } | ||
728 | 765 | ||
729 | /* | 766 | /* |
730 | * Binary Methods | 767 | * Binary Methods |