libopenraw
|
00001 /* 00002 * libopenraw - memstream.h 00003 * 00004 * Copyright (C) 2007 Hubert Figuière 00005 * 00006 * This library is free software: you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation, either version 3 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library. If not, see 00018 * <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef __IO_MEMSTREAM_H__ 00022 #define __IO_MEMSTREAM_H__ 00023 00024 00025 #include "io/stream.h" 00026 00027 namespace OpenRaw { 00028 namespace IO { 00029 00030 class MemStream 00031 : public Stream 00032 { 00033 public: 00034 MemStream(void *ptr, size_t s); 00035 00036 virtual ~MemStream() 00037 {} 00038 00039 virtual or_error open(); 00040 virtual int close(); 00041 virtual int seek(off_t offset, int whence); 00042 virtual int read(void *buf, size_t count); 00043 virtual off_t filesize(); 00044 00045 00046 private: 00047 void * m_ptr; 00048 size_t m_size; 00049 unsigned char * m_current; 00050 00052 MemStream(const MemStream& f); 00054 MemStream & operator=(const MemStream&); 00055 }; 00056 00057 } 00058 } 00059 00060 #endif 00061