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 #include "option.hpp"
38 
39 namespace OpenRaw {
40 namespace Internals {
41 
42 class IfdFileContainer;
43 
44 class IfdDir {
45 public:
46  typedef std::shared_ptr<IfdDir> Ref;
47  typedef std::vector<Ref> RefVec;
48 
49  IfdDir(off_t _offset, IfdFileContainer &_container);
50  virtual ~IfdDir();
51 
52  bool isPrimary() const;
53  bool isThumbnail() const;
54 
56  off_t offset() const { return m_offset; }
57  const IfdFileContainer &container() const { return m_container; }
58 
60  bool load();
62  int numTags() { return m_entries.size(); }
63  IfdEntry::Ref getEntry(uint16_t id) const;
64 
69  template <typename T>
70  Option<T> getValue(uint16_t id) const
71  {
72  IfdEntry::Ref e = getEntry(id);
73  if (e != NULL) {
74  try {
75  return Option<T>(IfdTypeTrait<T>::get(*e));
76  }
77  catch (const std::exception &ex) {
78  LOGERR("Exception raised %s fetch value for %u\n", ex.what(), id);
79  }
80  }
81  return Option<T>();
82  }
83 
91  Option<uint32_t> getIntegerValue(uint16_t id);
92 
96  off_t nextIFD();
97 
101  Ref getSubIFD(uint32_t idx = 0) const;
102 
107 
111  Ref getExifIFD();
112 
116  Ref getMakerNoteIfd();
117 
118 private:
119  off_t m_offset;
120  IfdFileContainer &m_container;
121  std::map<uint16_t, IfdEntry::Ref> m_entries;
122 };
123 }
124 }
125 
126 #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:262
Option< std::vector< IfdDir::Ref > > getSubIFDs()
Definition: ifddir.cpp:151
Option< uint32_t > getIntegerValue(uint16_t id)
Definition: ifddir.cpp:101
std::shared_ptr< IfdEntry > Ref
Definition: ifdentry.hpp:165
off_t offset() const
Definition: ifddir.hpp:56
Ref getSubIFD(uint32_t idx=0) const
Definition: ifddir.cpp:131
Option< T > getValue(uint16_t id) const
Definition: ifddir.hpp:70