X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fbuffered.h;fp=source%2Fio%2Fbuffered.h;h=36d2a1165a3e52b7413397bf01575984efa3ac49;hp=0000000000000000000000000000000000000000;hb=6e0fd758970bcb5bad5e3f2454b694cc4d7b4b66;hpb=b97d4e9f86e90254ab9edef7ee62a910f6333c78 diff --git a/source/io/buffered.h b/source/io/buffered.h new file mode 100644 index 0000000..36d2a11 --- /dev/null +++ b/source/io/buffered.h @@ -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