libopenraw
stream.h
1 /*
2  * libopenraw - stream.h
3  *
4  * Copyright (C) 2006 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 
22 #ifndef __IO_STREAM_H__
23 #define __IO_STREAM_H__
24 
25 #include <sys/types.h>
26 #include <unistd.h>
27 
28 #include <string>
29 
30 #include <libopenraw/libopenraw.h>
31 
32 #include "exception.h"
33 
34 namespace OpenRaw {
35  namespace IO {
36 
40  class Stream
41  {
42  public:
46  Stream(const char *filename);
47  virtual ~Stream();
48 
52  typedef ::or_error Error;
53 
54 // file APIs
56  virtual Error open() = 0;
58  virtual int close() = 0;
60  virtual int seek(off_t offset, int whence) = 0;
62  virtual int read(void *buf, size_t count) = 0;
63  virtual off_t filesize() = 0;
64 // virtual void *mmap(size_t l, off_t offset) = 0;
65 // virtual int munmap(void *addr, size_t l) = 0;
66 
67  Error get_error()
68  {
69  return m_error;
70  }
71 
73  const std::string &get_path() const
74  {
75  return m_fileName;
76  }
77 
78  uint8_t readByte() throw(Internals::IOException);
79  protected:
80  void set_error(Error error)
81  {
82  m_error = error;
83  }
84 
85  private:
87  Stream(const Stream& f);
89  Stream & operator=(const Stream&);
90 
92  std::string m_fileName;
93  Error m_error;
94  };
95 
96  }
97 }
98 
99 
100 #endif
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
Definition: arwfile.cpp:33
virtual Error open()=0
virtual int seek(off_t offset, int whence)=0
virtual int close()=0
const std::string & get_path() const
Definition: stream.h:73
virtual int read(void *buf, size_t count)=0
Stream(const char *filename)
Definition: stream.cpp:28
::or_error Error
Definition: stream.h:52
base virtual class for IO
Definition: stream.h:40