diff options
author | nat-goodspeed <nat@lindenlab.com> | 2023-02-22 12:12:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-22 12:12:34 -0500 |
commit | d9ef67187532f528a0a8072da55ac0237ec3e4ff (patch) | |
tree | 72debaca010a00b3d699bfe75f86ffd91cc5d14d /indra/llcommon/llstreamtools.h | |
parent | f84f1d8f44a32ffe62f3e429c5cba0f087e283ed (diff) | |
parent | 292bb3991b589d39d61cf721b82fe7bdae460785 (diff) |
Merge pull request #29 from secondlife/sl-18330
SL-18330: Send binary LLSD to LEAP plugins; extend LLSD compatibility.
Diffstat (limited to 'indra/llcommon/llstreamtools.h')
-rw-r--r-- | indra/llcommon/llstreamtools.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/indra/llcommon/llstreamtools.h b/indra/llcommon/llstreamtools.h index 1b04bf91d7..bb7bc20327 100644 --- a/indra/llcommon/llstreamtools.h +++ b/indra/llcommon/llstreamtools.h @@ -27,8 +27,10 @@ #ifndef LL_STREAM_TOOLS_H #define LL_STREAM_TOOLS_H +#include <deque> #include <iostream> #include <string> +#include <vector> // unless specifed otherwise these all return input_stream.good() @@ -113,6 +115,27 @@ LL_COMMON_API std::streamsize fullread( LL_COMMON_API std::istream& operator>>(std::istream& str, const char *tocheck); -#endif - +/** + * cat_streambuf is a std::streambuf subclass that accepts a variadic number + * of std::streambuf* (e.g. some_istream.rdbuf()) and virtually concatenates + * their contents. + */ +// derived from https://stackoverflow.com/a/49441066/5533635 +class cat_streambuf: public std::streambuf +{ +private: + std::deque<std::streambuf*> mInputs; + std::vector<char> mBuffer; + +public: + // only valid for std::streambuf* arguments + template <typename... Inputs> + cat_streambuf(Inputs... inputs): + mInputs{inputs...}, + mBuffer(1024) + {} + + int underflow() override; +}; +#endif |