11 Memory::Memory(char *d, unsigned s)
16 Memory::Memory(char *b, char *e)
21 Memory::Memory(const char *cd, unsigned s)
23 char *d = const_cast<char *>(cd);
27 Memory::Memory(const char *b, const char *e)
29 init(const_cast<char *>(b), const_cast<char *>(e), M_READ);
32 void Memory::init(char *b, char *e, Mode m)
40 unsigned Memory::do_write(const char *buf, unsigned size)
44 size = min<unsigned>(size, end-pos);
45 memcpy(pos, buf, size);
50 unsigned Memory::do_read(char *buf, unsigned size)
58 size = min<unsigned>(size, end-pos);
59 memcpy(buf, pos, size);
64 unsigned Memory::put(char c)
71 bool Memory::getline(string &line)
73 char *nl = find(pos, end, '\n');
75 bool result = (nl!=pos);
88 return static_cast<unsigned char>(*pos++);
91 unsigned Memory::seek(int off, SeekType type)
101 throw InvalidParameterValue("Invalid seek type");
103 if(new_pos<begin || new_pos>end)
104 throw InvalidParameterValue("Invalid seek offset");
110 Handle Memory::get_event_handle()
112 throw Exception("Memory doesn't support events");
115 void Memory::check_mode(Mode m) const
120 throw InvalidState("Memory is not writable");
122 throw InvalidState("Attempt to write past end of Memory");