]> git.tdb.fi Git - libs/core.git/blob - source/io/memory.h
Add a mode parameter to Memory constructor with non-const pointers
[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         virtual unsigned do_write(const char *, unsigned);
25         virtual unsigned do_read(char *, unsigned);
26 public:
27         virtual unsigned put(char);
28         virtual bool getline(std::string &);
29         virtual int get();
30
31         virtual SeekOffset seek(SeekOffset, SeekType);
32         virtual SeekOffset tell() const { return pos-begin; }
33 };
34
35 } // namespace IO
36 } // namespace Msp
37
38 #endif