This makes it possible to explicitly set the mode for a Memory, and in
particular to create a write-only Memory. ZlibCompressed does not work
with M_RDWR so writing compressed data to memory was impossible before
this commit.
namespace Msp {
namespace IO {
-Memory::Memory(char *d, unsigned s)
+Memory::Memory(char *d, unsigned s, Mode m)
{
- init(d, d+s, M_RDWR);
+ init(d, d+s, m);
}
-Memory::Memory(char *b, char *e)
+Memory::Memory(char *b, char *e, Mode m)
{
- init(b, e, M_RDWR);
+ init(b, e, m);
}
Memory::Memory(const char *cd, unsigned s)
unsigned Memory::do_read(char *buf, unsigned size)
{
+ check_access(M_READ);
+
if(pos==end)
{
set_eof();
bool Memory::getline(string &line)
{
+ check_access(M_READ);
+
if(pos==end)
{
set_eof();
int Memory::get()
{
+ check_access(M_READ);
+
if(pos==end)
{
set_eof();
char *pos;
public:
- Memory(char *, unsigned);
- Memory(char *, char *);
+ Memory(char *, unsigned, Mode = M_RDWR);
+ Memory(char *, char *, Mode = M_RDWR);
Memory(const char *, unsigned);
Memory(const char *, const char *);
private: