summaryrefslogtreecommitdiff
path: root/Source/Library/Common/OStream.proto.h
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-12-20 20:03:22 +0100
committerAlexis211 <alexis211@gmail.com>2009-12-20 20:03:22 +0100
commit09353da6e91a0968ae24d4b4d97ed434520e6217 (patch)
tree016694d12e9dfebc773cef629eb56556d0024b22 /Source/Library/Common/OStream.proto.h
parent247070cc7e5ae117fd0d1b551fafdf5c13f0dd6b (diff)
parent18454dc8be12827a84c2ebc58aa5d31bb44e1e6a (diff)
downloadMelon-09353da6e91a0968ae24d4b4d97ed434520e6217.tar.gz
Melon-09353da6e91a0968ae24d4b4d97ed434520e6217.zip
Merge branch 'framework'
Conflicts: .gitignore
Diffstat (limited to 'Source/Library/Common/OStream.proto.h')
-rw-r--r--Source/Library/Common/OStream.proto.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/Library/Common/OStream.proto.h b/Source/Library/Common/OStream.proto.h
new file mode 100644
index 0000000..ff19e7b
--- /dev/null
+++ b/Source/Library/Common/OStream.proto.h
@@ -0,0 +1,39 @@
+#ifndef DEF_ISTREAM_PROTO_H
+#define DEF_ISTREAM_PROTO_H
+
+#include <String.class.h>
+#include <SimpleList.class.h>
+#include <Mutex.class.h>
+
+enum ostream_modifiers_e {
+ FLUSH,
+ ENDL,
+ END
+};
+
+class OStream : private Mutex {
+ private:
+ SimpleList<String> *m_buffer;
+ SimpleList<String> *m_last;
+ void operator =(OStream& other);
+
+ protected:
+ virtual void write(const String &s) = 0;
+
+ public:
+ OStream();
+ OStream(const OStream& other);
+ virtual ~OStream() { flush(); }
+
+ void put(const String& s);
+ void flush();
+
+ //Formatting functions
+ OStream& operator << (const String& s) { put(s); if (s.contains("\n")) flush(); return *this; }
+ OStream& operator << (s64int i) { put(String::number(i)); return *this; }
+ OStream& operator << (s32int i) { put(String::number(i)); return *this; }
+ OStream& operator << (u32int i) { put(String::hex(i)); return *this; }
+ OStream& operator << (ostream_modifiers_e m);
+};
+
+#endif