X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fbuffered.h;h=f078ea1094324d57d1533063aa457e019912ae2f;hp=095be0f01625eaac5672278a7f20ae724268b227;hb=HEAD;hpb=d16185720fa344263367dbd50c61bfc8183d99a4 diff --git a/source/io/buffered.h b/source/io/buffered.h index 095be0f..c05fc25 100644 --- a/source/io/buffered.h +++ b/source/io/buffered.h @@ -1,41 +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; + std::size_t get_current_size() const; }; } // namespace IO