libopenraw
rawcontainer.hpp
1 /* -*- Mode: C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
2 /*
3  * libopenraw - rawcontainer.h
4  *
5  * Copyright (C) 2006-2017 Hubert Figuière
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef OR_INTERNALS_RAWCONTAINER_H_
23 #define OR_INTERNALS_RAWCONTAINER_H_
24 
25 #include <stddef.h>
26 #include <stdint.h>
27 #include <sys/types.h>
28 
29 #include <vector>
30 
31 #include "io/stream.hpp"
32 #include "option.hpp"
33 
34 namespace OpenRaw {
35 
36 namespace Internals {
37 
41 class RawContainer {
42 public:
44  typedef enum {
45  ENDIAN_NULL = 0,
48  } EndianType;
49 
55  RawContainer(const IO::Stream::Ptr &_file, off_t offset);
57  virtual ~RawContainer();
58 
59  const IO::Stream::Ptr &file() { return m_file; }
60  EndianType endian() const { return m_endian; }
61  off_t offset() const { return m_offset; }
62 
63  bool skip(off_t offset);
64  Option<int8_t> readInt8(const IO::Stream::Ptr &f);
65  Option<uint8_t> readUInt8(const IO::Stream::Ptr &f);
67  Option<int16_t> readInt16(const IO::Stream::Ptr &f);
69  Option<int32_t> readInt32(const IO::Stream::Ptr &f);
71  Option<uint16_t> readUInt16(const IO::Stream::Ptr &f);
77  size_t readUInt16Array(const IO::Stream::Ptr &f, std::vector<uint16_t> &v, size_t count);
79  Option<uint32_t> readUInt32(const IO::Stream::Ptr &f);
87  size_t fetchData(void *buf, off_t offset, size_t buf_size);
88 
92  off_t size() const;
93 protected:
94  RawContainer(const RawContainer &) = delete;
95  RawContainer &operator=(const RawContainer &) = delete;
96 
97  void setEndian(EndianType _endian) { m_endian = _endian; }
98 
100  IO::Stream::Ptr m_file;
102  off_t m_offset;
103  EndianType m_endian;
104 };
105 }
106 }
107 
108 #endif
size_t fetchData(void *buf, off_t offset, size_t buf_size)
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:30
RawContainer(const IO::Stream::Ptr &_file, off_t offset)
Option< int16_t > readInt16(const IO::Stream::Ptr &f)
Option< uint32_t > readUInt32(const IO::Stream::Ptr &f)
size_t readUInt16Array(const IO::Stream::Ptr &f, std::vector< uint16_t > &v, size_t count)
Option< uint16_t > readUInt16(const IO::Stream::Ptr &f)
Option< int32_t > readInt32(const IO::Stream::Ptr &f)