X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fio%2Fmemory.cpp;h=616150f0ab72937e40989ae19dcdd401d5a95981;hb=f24e7b96e76b63c9b9b8a6bce4c7a9db64276ea8;hp=37954cca5bea6bb95a62a5afdfc094009584ba83;hpb=1a6331551a025ddcc1772ae447c326ec70e0e107;p=libs%2Fcore.git diff --git a/source/io/memory.cpp b/source/io/memory.cpp index 37954cc..616150f 100644 --- a/source/io/memory.cpp +++ b/source/io/memory.cpp @@ -8,7 +8,7 @@ using namespace std; namespace Msp { namespace IO { -Memory::Memory(char *d, unsigned s, Mode m) +Memory::Memory(char *d, size_t s, Mode m) { init(d, d+s, m); } @@ -18,7 +18,7 @@ Memory::Memory(char *b, char *e, Mode m) init(b, e, m); } -Memory::Memory(const char *cd, unsigned s) +Memory::Memory(const char *cd, size_t s) { char *d = const_cast(cd); init(d, d+s, M_READ); @@ -37,17 +37,27 @@ void Memory::init(char *b, char *e, Mode m) mode = m; } -unsigned Memory::do_write(const char *buf, unsigned size) +void Memory::set_block(bool) +{ + throw logic_error("Memory::set_block"); +} + +void Memory::set_inherit(bool) +{ + throw logic_error("Memory::set_inherit"); +} + +size_t Memory::do_write(const char *buf, size_t size) { check_access(M_WRITE); - size = min(size, end-pos); + size = min(size, end-pos); memcpy(pos, buf, size); pos += size; return size; } -unsigned Memory::do_read(char *buf, unsigned size) +size_t Memory::do_read(char *buf, size_t size) { check_access(M_READ); @@ -57,13 +67,13 @@ unsigned Memory::do_read(char *buf, unsigned size) return 0; } - size = min(size, end-pos); + size = min(size, end-pos); memcpy(buf, pos, size); pos += size; return size; } -unsigned Memory::put(char c) +size_t Memory::put(char c) { check_access(M_WRITE); @@ -103,6 +113,11 @@ int Memory::get() return static_cast(*pos++); } +const Handle &Memory::get_handle(Mode) +{ + throw logic_error("Memory::get_handle"); +} + SeekOffset Memory::seek(SeekOffset off, SeekType type) { char *new_pos;