libopenraw
stream.hpp
1/*
2 * libopenraw - stream.h
3 *
4 * Copyright (C) 2006-2015 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 OR_INTERNALS_IO_STREAM_H_
23#define OR_INTERNALS_IO_STREAM_H_
24
25#include <sys/types.h>
26#include <stddef.h>
27#include <stdint.h>
28
29#include <memory>
30#include <string>
31
32#include <libopenraw/consts.h>
33
34
35namespace OpenRaw {
36namespace IO {
37
41class Stream
42{
43public:
44 typedef std::shared_ptr<Stream> Ptr;
48 Stream(const char *filename);
49 virtual ~Stream();
50
54 typedef ::or_error Error;
55
56// file APIs
58 virtual Error open() = 0;
60 virtual int close() = 0;
62 virtual int seek(off_t offset, int whence) = 0;
64 virtual int read(void *buf, size_t count) = 0;
65 virtual off_t filesize() = 0;
66// virtual void *mmap(size_t l, off_t offset) = 0;
67// virtual int munmap(void *addr, size_t l) = 0;
68
69 Error get_error()
70 {
71 return m_error;
72 }
73
75 const std::string &get_path() const
76 {
77 return m_fileName;
78 }
79
80 uint8_t readByte() noexcept(false);
81protected:
82 void set_error(Error error)
83 {
84 m_error = error;
85 }
86
87private:
89 Stream(const Stream& f);
91 Stream & operator=(const Stream&);
92
94 std::string m_fileName;
95 Error m_error;
96};
97
98}
99}
100
101
102#endif
103/*
104 Local Variables:
105 mode:c++
106 c-file-style:"stroustrup"
107 c-file-offsets:((innamespace . 0))
108 tab-width:2
109 c-basic-offset:2
110 indent-tabs-mode:nil
111 fill-column:80
112 End:
113*/
virtual Error open()=0
virtual int close()=0
::or_error Error
Definition stream.hpp:54
Stream(const char *filename)
Definition stream.cpp:30
virtual int read(void *buf, size_t count)=0
const std::string & get_path() const
Definition stream.hpp:75
virtual int seek(off_t offset, int whence)=0
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard....
Definition arwfile.cpp:30