]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/buffered.h
Move files to prepare for assimilation into core
[libs/core.git] / source / io / buffered.h
diff --git a/source/io/buffered.h b/source/io/buffered.h
new file mode 100644 (file)
index 0000000..36d2a11
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef MSP_IO_BUFFERED_H_
+#define MSP_IO_BUFFERED_H_
+
+#include "base.h"
+
+namespace Msp {
+namespace IO {
+
+class Buffered: public Base
+{
+private:
+       Base &below;
+       unsigned buf_size;
+       char *buf;
+       char *begin;
+       char *end;
+       Mode cur_op;
+
+public:
+       Buffered(Base &, unsigned =8192);
+       ~Buffered();
+
+       void flush();
+
+protected:
+       unsigned do_write(const char *, unsigned);
+       unsigned do_read(char *, unsigned);
+public:
+       unsigned put(char);
+
+       bool getline(std::string &);
+       int get();
+
+private:
+       void set_op(Mode);
+public:
+       Mode get_current_op() const { return cur_op; }
+       unsigned get_current_size() const;
+
+       virtual Handle get_event_handle();
+};
+
+} // namespace IO
+} // namespace Msp
+
+#endif