]> git.tdb.fi Git - libs/core.git/blob - source/buffered.h
Rename error.h to except.h
[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 public:
18         Buffered(Base &, unsigned =8192);
19         unsigned put(char);
20         void flush();
21         bool getline(std::string &);
22         int  get();
23         int  tell() const;
24         Handle get_event_handle();
25         ~Buffered();
26 private:
27         Base     &below;
28         unsigned buf_size;
29         char     *in_buf;
30         char     *in_ptr;
31         unsigned in_avail;
32         char     *out_buf;
33         unsigned out_used;
34
35         void  below_closing();
36         unsigned do_write(const char *, unsigned);
37         unsigned do_read(char *, unsigned);
38 };
39
40 } // namespace IO
41 } // namespace Msp
42
43 #endif