-/* $Id$
-
-This file is part of libmspio
-Copyright © 2009 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#include <algorithm>
#include <cstring>
#include "except.h"
mode = m;
}
+unsigned Memory::do_write(const char *buf, unsigned size)
+{
+ check_mode(M_WRITE);
+
+ size = min<unsigned>(size, end-pos);
+ memcpy(pos, buf, size);
+ pos += size;
+ return size;
+}
+
+unsigned Memory::do_read(char *buf, unsigned size)
+{
+ if(pos==end)
+ {
+ eof_flag = true;
+ return 0;
+ }
+
+ size = min<unsigned>(size, end-pos);
+ memcpy(buf, pos, size);
+ pos += size;
+ return size;
+}
+
unsigned Memory::put(char c)
{
check_mode(M_WRITE);
throw Exception("Memory doesn't support events");
}
-unsigned Memory::do_write(const char *buf, unsigned size)
-{
- check_mode(M_WRITE);
-
- size = min<unsigned>(size, end-pos);
- memcpy(pos, buf, size);
- pos += size;
- return size;
-}
-
-unsigned Memory::do_read(char *buf, unsigned size)
-{
- if(pos==end)
- {
- eof_flag = true;
- return 0;
- }
-
- size = min<unsigned>(size, end-pos);
- memcpy(buf, pos, size);
- pos += size;
- return size;
-}
-
void Memory::check_mode(Mode m) const
{
if(m==M_WRITE)