22#ifndef OR_INTERNALS_IFDENTRY_H
23#define OR_INTERNALS_IFDENTRY_H
35#include "exception.hpp"
37#include "endianutils.hpp"
38#include "rawcontainer.hpp"
55 static const uint16_t
type;
57 static T EL(
const uint8_t* d,
size_t len)
noexcept;
58 static T BE(
const uint8_t* d,
size_t len)
noexcept;
59 static T
get(
IfdEntry & e, uint32_t idx = 0,
bool ignore_type =
false)
65inline uint8_t
IfdTypeTrait<uint8_t>::EL(const uint8_t* b,
size_t) noexcept
71inline uint8_t IfdTypeTrait<uint8_t>::BE(
const uint8_t* b,
size_t)
noexcept
78inline uint16_t IfdTypeTrait<uint16_t>::EL(
const uint8_t* b,
size_t)
noexcept
84inline uint16_t IfdTypeTrait<uint16_t>::BE(
const uint8_t* b,
size_t)
noexcept
90inline uint32_t IfdTypeTrait<uint32_t>::EL(
const uint8_t* b,
size_t)
noexcept
96inline uint32_t IfdTypeTrait<uint32_t>::BE(
const uint8_t* b,
size_t)
noexcept
102inline std::string IfdTypeTrait<std::string>::EL(
const uint8_t* b,
size_t len)
noexcept
106 s.assign((
const char*)b, strnlen((
const char*)b, len));
114inline std::string IfdTypeTrait<std::string>::BE(
const uint8_t* b,
size_t len)
noexcept
118 s.assign((
const char*)b, strnlen((
const char*)b, len));
126inline IFD::Rational IfdTypeTrait<IFD::Rational>::EL(
const uint8_t* b,
size_t)
noexcept
130 r.denom = EL32(b + 4);
135inline IFD::Rational IfdTypeTrait<IFD::Rational>::BE(
const uint8_t* b,
size_t)
noexcept
139 r.denom = BE32(b + 4);
144inline IFD::SRational IfdTypeTrait<IFD::SRational>::EL(
const uint8_t* b,
size_t)
noexcept
148 r.denom = EL32(b + 4);
153inline IFD::SRational IfdTypeTrait<IFD::SRational>::BE(
const uint8_t* b,
size_t)
noexcept
157 r.denom = BE32(b + 4);
165 typedef std::shared_ptr<IfdEntry>
Ref;
167 IfdEntry(uint16_t _id, int16_t _type, int32_t _count,
172 int16_t type() const noexcept
189 return IfdTypeTrait<uint32_t>::EL((uint8_t*)&m_data,
sizeof(uint32_t));
191 return IfdTypeTrait<uint32_t>::BE((uint8_t*)&m_data,
sizeof(uint32_t));
201 static size_t type_unit_size(IFD::ExifTagType _type);
207 bool loadData(
size_t unit_size);
215 template <
typename T>
219 std::vector<T> array;
220 array.reserve(m_count);
221 for (uint32_t i = 0; i < m_count; i++) {
226 catch(
const std::exception & e)
228 LOGERR(
"Exception: %s\n", e.what());
232 uint32_t getIntegerArrayItem(
int idx);
266 if(!ignore_type && (e.m_type != IFD::EXIF_FORMAT_UNDEFINED)) {
271 if (idx + 1 > e.m_count) {
281 if (e.m_dataptr == NULL) {
282 data = (uint8_t*)&e.m_data;
290 val = IfdTypeTrait<T>::EL(data, e.m_count - idx);
293 val = IfdTypeTrait<T>::BE(data, e.m_count - idx);
uint32_t count() const noexcept
std::shared_ptr< IfdEntry > Ref
Option< std::vector< T > > getArray()
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard....
static const uint16_t type
static T get(IfdEntry &e, uint32_t idx=0, bool ignore_type=false) noexcept(false)