summaryrefslogtreecommitdiff
path: root/indra/llcommon/llstreamtools.h
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2023-08-23 22:28:01 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2023-08-23 22:28:01 +0300
commitd08859f3f4ba8ed68d018fba033b652926d1bf6b (patch)
treefd62430b9a2987ca2eab8a8f08114f113de84120 /indra/llcommon/llstreamtools.h
parentf40b85c4f495b9079991c41a26b76d397a6168ae (diff)
parentd454512050e636a19e4b7545515dea4f4b1bbf0d (diff)
Merge branch 'main' into DRTVWR-587-maint-V
# Conflicts: # autobuild.xml
Diffstat (limited to 'indra/llcommon/llstreamtools.h')
-rw-r--r--indra/llcommon/llstreamtools.h27
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