X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fbuffered.h;h=f078ea1094324d57d1533063aa457e019912ae2f;hp=36d2a1165a3e52b7413397bf01575984efa3ac49;hb=HEAD;hpb=c7afef88380ebebc8c2b04e48664d73281ec8848 diff --git a/source/io/buffered.h b/source/io/buffered.h index 36d2a11..c05fc25 100644 --- a/source/io/buffered.h +++ b/source/io/buffered.h @@ -1,43 +1,48 @@ #ifndef MSP_IO_BUFFERED_H_ #define MSP_IO_BUFFERED_H_ +#include +#include #include "base.h" namespace Msp { namespace IO { -class Buffered: public Base +class MSPCORE_API Buffered: public Base, public sigc::trackable { private: Base &below; - unsigned buf_size; - char *buf; - char *begin; - char *end; - Mode cur_op; + std::size_t buf_size = 0; + char *buf = nullptr; + char *begin = nullptr; + char *end = nullptr; + Mode cur_op = M_NONE; public: - Buffered(Base &, unsigned =8192); + Buffered(Base &, unsigned = 8192); ~Buffered(); + void set_block(bool) override; + void set_inherit(bool) override; + void flush(); protected: - unsigned do_write(const char *, unsigned); - unsigned do_read(char *, unsigned); + std::size_t do_write(const char *, std::size_t) override; + std::size_t do_read(char *, std::size_t) override; public: - unsigned put(char); + std::size_t put(char) override; + + bool getline(std::string &) override; + int get() override; - bool getline(std::string &); - int get(); + const Handle &get_handle(Mode) override; 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