]> git.tdb.fi Git - libs/core.git/blob - source/io/buffered.h
Use vectors for storage in Poller
[libs/core.git] / source / io / buffered.h
1 #ifndef MSP_IO_BUFFERED_H_
2 #define MSP_IO_BUFFERED_H_
3
4 #include <sigc++/trackable.h>
5 #include "base.h"
6
7 namespace Msp {
8 namespace IO {
9
10 class Buffered: public Base, public sigc::trackable
11 {
12 private:
13         Base &below;
14         unsigned buf_size;
15         char *buf;
16         char *begin;
17         char *end;
18         Mode cur_op;
19
20 public:
21         Buffered(Base &, unsigned =8192);
22         ~Buffered();
23
24         virtual void set_block(bool);
25         virtual void set_inherit(bool);
26
27         void flush();
28
29 protected:
30         unsigned do_write(const char *, unsigned);
31         unsigned do_read(char *, unsigned);
32 public:
33         unsigned put(char);
34
35         bool getline(std::string &);
36         int get();
37
38         virtual const Handle &get_handle(Mode);
39
40 private:
41         void set_op(Mode);
42 public:
43         Mode get_current_op() const { return cur_op; }
44         unsigned get_current_size() const;
45 };
46
47 } // namespace IO
48 } // namespace Msp
49
50 #endif