libopenraw
ifddir.hpp
1 /* -*- Mode: C++ -*- */
2 /*
3  * libopenraw - ifddir.h
4  *
5  * Copyright (C) 2006-2015 Hubert Figuiere
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_IFDDIR_H
23 #define OR_INTERNALS_IFDDIR_H
24 
25 #include <stddef.h>
26 #include <stdint.h>
27 #include <sys/types.h>
28 #include <exception>
29 #include <map>
30 #include <memory>
31 #include <vector>
32 
33 #include <libopenraw/debug.h>
34 
35 #include "ifdentry.hpp"
36 #include "trace.hpp"
37 
38 namespace OpenRaw {
39 namespace Internals {
40 
41 class IfdFileContainer;
42 
43 class IfdDir {
44 public:
45  typedef std::shared_ptr<IfdDir> Ref;
46  typedef std::vector<Ref> RefVec;
47 
48  IfdDir(off_t _offset, IfdFileContainer &_container);
49  virtual ~IfdDir();
50 
51  bool isPrimary() const;
52  bool isThumbnail() const;
53 
55  off_t offset() const { return m_offset; }
56  const IfdFileContainer &container() const { return m_container; }
57 
59  bool load();
61  int numTags() { return m_entries.size(); }
62  IfdEntry::Ref getEntry(uint16_t id) const;
63 
69  template <typename T>
70  bool getValue(uint16_t id, T &v) const
71  {
72  bool success = false;
73  IfdEntry::Ref e = getEntry(id);
74  if (e != NULL) {
75  try {
76  v = IfdTypeTrait<T>::get(*e);
77  success = true;
78  }
79  catch (const std::exception &ex) {
80  Debug::Trace(ERROR) << "Exception raised " << ex.what()
81  << " fetch value for " << id << "\n";
82  }
83  }
84  return success;
85  }
86 
95  bool getIntegerValue(uint16_t id, uint32_t &v);
96 
100  off_t nextIFD();
101 
105  Ref getSubIFD(uint32_t idx = 0) const;
110  bool getSubIFDs(std::vector<IfdDir::Ref> &ifds);
111 
115  Ref getExifIFD();
116 
120  Ref getMakerNoteIfd();
121 
122 private:
123  off_t m_offset;
124  IfdFileContainer &m_container;
125  std::map<uint16_t, IfdEntry::Ref> m_entries;
126 };
127 }
128 }
129 
130 #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:30
static T get(IfdEntry &e, uint32_t idx=0, bool ignore_type=false) noexcept(false)
Definition: ifdentry.hpp:269
bool getSubIFDs(std::vector< IfdDir::Ref > &ifds)
Definition: ifddir.cpp:148
bool getIntegerValue(uint16_t id, uint32_t &v)
Definition: ifddir.cpp:94
bool getValue(uint16_t id, T &v) const
Definition: ifddir.hpp:70
std::shared_ptr< IfdEntry > Ref
Definition: ifdentry.hpp:178
off_t offset() const
Definition: ifddir.hpp:55
Ref getSubIFD(uint32_t idx=0) const
Definition: ifddir.cpp:128