diff options
| author | RunitaiLinden <davep@lindenlab.com> | 2023-09-11 11:51:20 -0500 |
|---|---|---|
| committer | RunitaiLinden <davep@lindenlab.com> | 2023-09-11 11:51:20 -0500 |
| commit | 74940194fa5cd4c5182f141ef262e5568156bdce (patch) | |
| tree | 8d3a8e779d34a94b4df3dc4517dfa598b4b98367 /indra/llcommon/llstreamtools.h | |
| parent | e3e1d42ab3021cf6e6ac68fff54c9185fd3a0ad1 (diff) | |
| parent | 0b02bf5d262fe9a6de968686420c4d525ac04077 (diff) | |
Merge remote-tracking branch 'remotes/origin/DRTVWR-559' into davep/SL-19842
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 |
