10 Memory::Memory(char *d, unsigned s)
15 Memory::Memory(char *b, char *e)
20 Memory::Memory(const char *cd, unsigned s)
22 char *d = const_cast<char *>(cd);
26 Memory::Memory(const char *b, const char *e)
28 init(const_cast<char *>(b), const_cast<char *>(e), M_READ);
31 void Memory::init(char *b, char *e, Mode m)
39 unsigned Memory::do_write(const char *buf, unsigned size)
43 size = min<unsigned>(size, end-pos);
44 memcpy(pos, buf, size);
49 unsigned Memory::do_read(char *buf, unsigned size)
57 size = min<unsigned>(size, end-pos);
58 memcpy(buf, pos, size);
63 unsigned Memory::put(char c)
70 bool Memory::getline(string &line)
72 char *nl = find(pos, end, '\n');
74 bool result = (nl!=pos);
87 return static_cast<unsigned char>(*pos++);
90 unsigned Memory::seek(int off, SeekType type)
100 throw invalid_argument("Memory::seek");
102 if(new_pos<begin || new_pos>end)
103 throw out_of_range("Memory::seek");
109 Handle Memory::get_event_handle()
111 throw logic_error("Memory doesn't support events");
114 void Memory::check_mode(Mode m) const
116 if(m==M_WRITE && !(mode&M_WRITE))
117 throw invalid_access(M_WRITE);