X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fmemory.cpp;h=fa8f9053de029e3965f1fd4c261a43e6c4a69c1c;hp=79956cdafecae37a113b7421d10cb30fadd1d2c1;hb=82d74297d5b469b0a506d7010a84ab5115cd88ee;hpb=8f2711fba7a2817840038630d9cf9a2060ecbe8e diff --git a/source/io/memory.cpp b/source/io/memory.cpp index 79956cd..fa8f905 100644 --- a/source/io/memory.cpp +++ b/source/io/memory.cpp @@ -1,5 +1,6 @@ #include #include +#include "handle.h" #include "memory.h" using namespace std; @@ -38,7 +39,7 @@ void Memory::init(char *b, char *e, Mode m) unsigned Memory::do_write(const char *buf, unsigned size) { - check_mode(M_WRITE); + check_access(M_WRITE); size = min(size, end-pos); memcpy(pos, buf, size); @@ -50,7 +51,7 @@ unsigned Memory::do_read(char *buf, unsigned size) { if(pos==end) { - eof_flag = true; + set_eof(); return 0; } @@ -62,7 +63,7 @@ unsigned Memory::do_read(char *buf, unsigned size) unsigned Memory::put(char c) { - check_mode(M_WRITE); + check_access(M_WRITE); *pos++ = c; return 1; } @@ -80,14 +81,14 @@ int Memory::get() { if(pos==end) { - eof_flag = true; + set_eof(); return -1; } return static_cast(*pos++); } -unsigned Memory::seek(int off, SeekType type) +SeekOffset Memory::seek(SeekOffset off, SeekType type) { char *new_pos; if(type==S_BEG) @@ -106,16 +107,5 @@ unsigned Memory::seek(int off, SeekType type) return pos-begin; } -Handle Memory::get_event_handle() -{ - throw logic_error("Memory doesn't support events"); -} - -void Memory::check_mode(Mode m) const -{ - if(m==M_WRITE && !(mode&M_WRITE)) - throw invalid_access(M_WRITE); -} - } // namespace IO } // namespace Msp