]> git.tdb.fi Git - libs/core.git/blob - source/buffered.h
092be19e8f0ad00241d67f915d0931b2697cc9ce
[libs/core.git] / source / buffered.h
1 /* $Id$
2
3 This file is part of libmspio
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7 #ifndef MSP_IO_BUFFERED_H_
8 #define MSP_IO_BUFFERED_H_
9
10 #include "base.h"
11
12 namespace Msp {
13 namespace IO {
14
15 class Buffered: public Base
16 {
17 private:
18         Base     &below;
19         unsigned buf_size;
20         char     *buf;
21         char     *begin;
22         char     *end;
23         Mode     cur_op;
24
25 public:
26         Buffered(Base &, unsigned =8192);
27         ~Buffered();
28
29         unsigned put(char);
30         void flush();
31         bool getline(std::string &);
32         int  get();
33         Handle get_event_handle();
34         Mode get_current_op() const { return cur_op; }
35         unsigned get_current_size() const;
36 private:
37         void set_op(Mode);
38         unsigned do_write(const char *, unsigned);
39         unsigned do_read(char *, unsigned);
40 };
41
42 } // namespace IO
43 } // namespace Msp
44
45 #endif