summaryrefslogtreecommitdiff
path: root/binparse/otreestream.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'binparse/otreestream.hpp')
-rw-r--r--binparse/otreestream.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/binparse/otreestream.hpp b/binparse/otreestream.hpp
new file mode 100644
index 0000000..3f57d4e
--- /dev/null
+++ b/binparse/otreestream.hpp
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <streambuf>
+#include <string>
+#include <ostream>
+
+namespace binparse {
+
+class treebuf : public std::streambuf
+{
+ std::string prefix;
+ std::streambuf* sbuf;
+ bool need_prefix;
+
+ int sync();
+ int overflow(int c);
+
+public:
+ treebuf(std::streambuf* sbuf);
+
+ void indent();
+
+ void unindent();
+};
+
+class otreestream : public virtual treebuf, public std::ostream
+{
+public:
+ otreestream(std::ostream& out);
+};
+
+class indent {
+
+ treebuf& tb;
+
+public:
+ indent(std::ostream& os);
+
+ ~indent();
+};
+
+} \ No newline at end of file