X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fbuffered.h;h=eeae3e4008bb3bc46629c6927323e3570bfa2747;hp=36d2a1165a3e52b7413397bf01575984efa3ac49;hb=8223c2aabe26469b6c580a223555496c5c5c5df5;hpb=c7afef88380ebebc8c2b04e48664d73281ec8848 diff --git a/source/io/buffered.h b/source/io/buffered.h index 36d2a11..eeae3e4 100644 --- a/source/io/buffered.h +++ b/source/io/buffered.h @@ -1,43 +1,47 @@ #ifndef MSP_IO_BUFFERED_H_ #define MSP_IO_BUFFERED_H_ +#include #include "base.h" namespace Msp { namespace IO { -class Buffered: public Base +class Buffered: public Base, public sigc::trackable { private: Base &below; - unsigned buf_size; + std::size_t buf_size; char *buf; char *begin; char *end; Mode cur_op; public: - Buffered(Base &, unsigned =8192); + Buffered(Base &, unsigned = 8192); ~Buffered(); + virtual void set_block(bool); + virtual void set_inherit(bool); + void flush(); protected: - unsigned do_write(const char *, unsigned); - unsigned do_read(char *, unsigned); + virtual std::size_t do_write(const char *, std::size_t); + virtual std::size_t do_read(char *, std::size_t); public: - unsigned put(char); + virtual std::size_t put(char); bool getline(std::string &); int get(); + virtual const Handle &get_handle(Mode); + private: void set_op(Mode); public: Mode get_current_op() const { return cur_op; } - unsigned get_current_size() const; - - virtual Handle get_event_handle(); + std::size_t get_current_size() const; }; } // namespace IO