X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fmemory.h;fp=source%2Fmemory.h;h=7ff531625bfa2313a1527af76949adc0b364ef13;hp=0000000000000000000000000000000000000000;hb=7c6c7369eb6a2e63c466e3823ea729c72d5c55d3;hpb=e0ebde8e33b1915860e6d253f5cefb33a8cd6ee0 diff --git a/source/memory.h b/source/memory.h new file mode 100644 index 0000000..7ff5316 --- /dev/null +++ b/source/memory.h @@ -0,0 +1,48 @@ +/* $Id$ + +This file is part of libmspio +Copyright © 2009 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#ifndef MSP_IO_MEMORY_H_ +#define MSP_IO_MEMORY_H_ + +#include "base.h" +#include "seek.h" + +namespace Msp { +namespace IO { + +class Memory: public Base +{ +private: + char *begin; + char *end; + char *pos; + +public: + Memory(char *, unsigned); + Memory(char *, char *); + Memory(const char *, unsigned); + Memory(const char *, const char *); +private: + void init(char *, char *, Mode); + +public: + virtual unsigned put(char); + virtual bool getline(std::string &); + virtual int get(); + unsigned seek(int, SeekType); + unsigned tell() const { return pos-begin; } + virtual Handle get_event_handle(); +private: + virtual unsigned do_write(const char *, unsigned); + virtual unsigned do_read(char *, unsigned); + void check_mode(Mode) const; +}; + +} // namespace IO +} // namespace Msp + +#endif