23#include "rawspeedconfig.h"
56 add(std::make_unique<CiffIFD>(
this, t.
data));
64 add(std::make_unique<CiffEntry>(t));
79 ThrowCPE(
"CIFF directory is too short.");
101 for (
uint32_t i = 0; i < entryCount; i++)
104 assert(valueDatas.size() <= entryCount);
118 for (; p !=
nullptr; p = p->parent)
119 p->subIFDCountRecursive++;
127 ThrowCPE(
"TIFF IFD has %d SubIFDs", count);
133 ThrowCPE(
"TIFF IFD file has %d SubIFDs (recursively)", count);
138 for (
const CiffIFD* p =
this; p !=
nullptr;) {
142 ThrowCPE(
"CiffIFD cascading overflow, found %d level IFD", depth);
144 p->checkSubIFDs(headroom);
153 assert(subIFD->parent ==
this);
156 subIFD->recursivelyCheckSubIFDs(0);
158 mSubIFD.push_back(std::move(subIFD));
163 mEntry[entry->tag] = std::move(entry);
167template <
typename Lambda>
169 const Lambda& f)
const {
172 std::vector<const CiffIFD*> matchingIFDs;
174 if (
const auto found =
mEntry.find(tag); found !=
mEntry.end()) {
175 const auto*
const entry = found->second.get();
177 matchingIFDs.push_back(
this);
180 for (
const auto& i :
mSubIFD) {
181 const auto t = i->getIFDsWithTagIf(tag, f);
182 matchingIFDs.insert(matchingIFDs.end(), t.begin(), t.end());
188template <
typename Lambda>
190 const Lambda& f)
const {
193 if (
const auto found =
mEntry.find(tag); found !=
mEntry.end()) {
194 const auto*
const entry = found->second.get();
199 for (
const auto& i :
mSubIFD) {
200 const CiffEntry* entry = i->getEntryRecursiveIf(tag, f);
218 return entry->
isInt() && entry->
getU32() == isValue;
222vector<const CiffIFD*>
233 return mEntry.contains(tag);
243 [tag](
const std::unique_ptr<const CiffIFD>& i) {
244 return i->hasEntryRecursive(tag);
251 if (
const auto found =
mEntry.find(tag); found !=
mEntry.end())
252 return found->second.get();
254 ThrowCPE(
"Entry 0x%x not found.",
static_cast<unsigned>(tag));
267 return entry->
isInt() && entry->
getU32() == isValue;
assert(dim.area() >=area)
size_type RAWSPEED_READONLY getSize() const
void setPosition(size_type newPos)
ByteStream getStream(size_type size_)
static CiffEntry Create(NORangesSet< Buffer > *valueDatas, ByteStream valueData, ByteStream dirEntry)
uint32_t getU32(uint32_t num=0) const
std::string_view getString() const
bool RAWSPEED_READONLY isInt() const
bool RAWSPEED_READONLY isString() const
bool RAWSPEED_READONLY hasEntry(CiffTag tag) const
const CiffEntry *RAWSPEED_READONLY getEntryRecursiveIf(CiffTag tag, const Lambda &f) const
void recursivelyCheckSubIFDs(int headroom) const
std::vector< const CiffIFD * > RAWSPEED_READONLY getIFDsWithTag(CiffTag tag) const
void recursivelyIncrementSubIFDCount()
void add(std::unique_ptr< CiffIFD > subIFD)
std::vector< const CiffIFD * > RAWSPEED_READONLY getIFDsWithTagIf(CiffTag tag, const Lambda &f) const
const CiffEntry *RAWSPEED_READONLY getEntryRecursiveWhere(CiffTag tag, uint32_t isValue) const
std::vector< const CiffIFD * > RAWSPEED_READONLY getIFDsWithTagWhere(CiffTag tag, uint32_t isValue) const
const CiffEntry *RAWSPEED_READONLY getEntryRecursive(CiffTag tag) const
const CiffEntry *RAWSPEED_READONLY getEntry(CiffTag tag) const
bool RAWSPEED_READONLY hasEntryRecursive(CiffTag tag) const
void parseIFDEntry(NORangesSet< Buffer > *valueDatas, ByteStream valueData, ByteStream &dirEntries)
std::map< CiffTag, std::unique_ptr< const CiffEntry > > mEntry
std::vector< std::unique_ptr< const CiffIFD > > mSubIFD
void checkSubIFDs(int headroom) const
bool RAWSPEED_READONLY isIn(const T value, const std::initializer_list< T2 > &list)
static constexpr std::initializer_list< CiffTag > CiffTagsWeCareAbout
static constexpr int SubIFDCount
static constexpr int RecursiveSubIFDCount
static constexpr int Depth