libopenraw
memstream.h
1 /*
2  * libopenraw - memstream.h
3  *
4  * Copyright (C) 2007 Hubert Figuière
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __IO_MEMSTREAM_H__
22 #define __IO_MEMSTREAM_H__
23 
24 
25 #include "io/stream.h"
26 
27 namespace OpenRaw {
28  namespace IO {
29 
30  class MemStream
31  : public Stream
32  {
33  public:
34  MemStream(void *ptr, size_t s);
35 
36  virtual ~MemStream()
37  {}
38 
39  virtual or_error open();
40  virtual int close();
41  virtual int seek(off_t offset, int whence);
42  virtual int read(void *buf, size_t count);
43  virtual off_t filesize();
44 
45 
46  private:
47  void * m_ptr;
48  size_t m_size;
49  unsigned char * m_current;
50 
52  MemStream(const MemStream& f);
54  MemStream & operator=(const MemStream&);
55 };
56 
57  }
58 }
59 
60 #endif
61 
virtual or_error open()
Definition: memstream.cpp:42
virtual int seek(off_t offset, int whence)
Definition: memstream.cpp:55
virtual int read(void *buf, size_t count)
Definition: memstream.cpp:88
virtual int close()
Definition: memstream.cpp:49
base virtual class for IO
Definition: stream.h:40