]> git.tdb.fi Git - libs/core.git/blob - source/io/memory.h
Use vectors for storage in Poller
[libs/core.git] / source / io / memory.h
1 #ifndef MSP_IO_MEMORY_H_
2 #define MSP_IO_MEMORY_H_
3
4 #include "seekable.h"
5
6 namespace Msp {
7 namespace IO {
8
9 class Memory: public Seekable
10 {
11 private:
12         char *begin;
13         char *end;
14         char *pos;
15
16 public:
17         Memory(char *, unsigned, Mode = M_RDWR);
18         Memory(char *, char *, Mode = M_RDWR);
19         Memory(const char *, unsigned);
20         Memory(const char *, const char *);
21 private:
22         void init(char *, char *, Mode);
23
24 public:
25         virtual void set_block(bool);
26         virtual void set_inherit(bool);
27
28 private:
29         virtual unsigned do_write(const char *, unsigned);
30         virtual unsigned do_read(char *, unsigned);
31 public:
32         virtual unsigned put(char);
33         virtual bool getline(std::string &);
34         virtual int get();
35
36         virtual const Handle &get_handle(Mode);
37
38         virtual SeekOffset seek(SeekOffset, SeekType);
39         virtual SeekOffset tell() const { return pos-begin; }
40 };
41
42 } // namespace IO
43 } // namespace Msp
44
45 #endif