Exiv2
tiffcomposite_int.hpp
1// ***************************************************************** -*- C++ -*-
2/*
3 * Copyright (C) 2004-2021 Exiv2 authors
4 * This program is part of the Exiv2 distribution.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19 */
20#ifndef TIFFCOMPOSITE_INT_HPP_
21#define TIFFCOMPOSITE_INT_HPP_
22
23// *****************************************************************************
24// included header files
25#include "value.hpp"
26#include "tifffwd_int.hpp"
27#include "types.hpp"
28
29// + standard includes
30#include <iosfwd>
31#include <memory>
32#include <vector>
33#include <string>
34#include <cassert>
35
36// *****************************************************************************
37// namespace extensions
38namespace Exiv2 {
39
40 class BasicIo;
41
42 namespace Internal {
43
44// *****************************************************************************
45// class definitions
46
48 using TiffType = uint16_t;
49
62 const TiffType ttTiffIfd =13;
63
65 TypeId toTypeId(TiffType tiffType, uint16_t tag, IfdId group);
68
72 namespace Tag {
73 const uint32_t none = 0x10000;
74 const uint32_t root = 0x20000;
75 const uint32_t next = 0x30000;
76 const uint32_t all = 0x40000;
77 const uint32_t pana = 0x80000;
78 const uint32_t fuji = 0x100000;
79 const uint32_t cmt2 = 0x110000;
80 const uint32_t cmt3 = 0x120000;
81 const uint32_t cmt4 = 0x130000;
82 }
83
89 public:
91
92
94 : extendedTag_(extendedTag), group_(group) {}
96
98
99
100 uint16_t tag() const { return static_cast<uint16_t>(extendedTag_ & 0xffff); }
102 uint32_t extendedTag() const { return extendedTag_; }
104 IfdId group() const { return group_; }
106
107 private:
108 // DATA
109 uint32_t extendedTag_;
110 IfdId group_;
111 }; // class TiffPathItem
112
122 class IoWrapper {
123 public:
125
126
132 IoWrapper(BasicIo& io, const byte* pHeader, long size, OffsetWriter* pow);
134
136
137
143 long write(const byte* pData, long wcount);
150 int putb(byte data);
152 void setTarget(int id, uint32_t target);
154
155 private:
156 // DATA
157 BasicIo& io_;
158 const byte* pHeader_;
159 long size_;
160 bool wroteHeader_;
161 OffsetWriter* pow_;
162 }; // class IoWrapper
163
173 public:
175 using UniquePtr = std::unique_ptr<TiffComponent>;
177 using Components = std::vector<TiffComponent*>;
178
180
181
182 TiffComponent(uint16_t tag, IfdId group);
184 virtual ~TiffComponent() = default;
186
188
189
201 TiffComponent* addPath(uint16_t tag,
202 TiffPath& tiffPath,
203 TiffComponent* const pRoot,
204 UniquePtr object =UniquePtr(nullptr));
210 TiffComponent* addChild(UniquePtr tiffComponent);
217 TiffComponent* addNext(UniquePtr tiffComponent);
224 void accept(TiffVisitor& visitor);
230 void setStart(const byte* pStart) { pStart_ = const_cast<byte*>(pStart); }
245 uint32_t write(IoWrapper& ioWrapper,
246 ByteOrder byteOrder,
247 int32_t offset,
248 uint32_t valueIdx,
249 uint32_t dataIdx,
250 uint32_t& imageIdx);
252
254
255
256 uint16_t tag() const { return tag_; }
258 IfdId group() const { return group_; }
260 byte* start() const { return pStart_; }
266 UniquePtr clone() const;
272 uint32_t writeData(IoWrapper& ioWrapper,
273 ByteOrder byteOrder,
274 int32_t offset,
275 uint32_t dataIdx,
276 uint32_t& imageIdx) const;
282 uint32_t writeImage(IoWrapper& ioWrapper,
283 ByteOrder byteOrder) const;
288 uint32_t size() const;
292 uint32_t count() const;
299 uint32_t sizeData() const;
306 uint32_t sizeImage() const;
310 // Todo: This is only implemented in TiffEntryBase. It is needed here so that
311 // we can sort components by tag and idx. Something is not quite right.
312 virtual int idx() const;
314
315 protected:
317
318
319 virtual TiffComponent* doAddPath(uint16_t tag,
320 TiffPath& tiffPath,
321 TiffComponent* const pRoot,
324 virtual TiffComponent* doAddChild(UniquePtr tiffComponent);
326 virtual TiffComponent* doAddNext(UniquePtr tiffComponent);
328 virtual void doAccept(TiffVisitor& visitor) =0;
330 virtual uint32_t doWrite(IoWrapper& ioWrapper,
331 ByteOrder byteOrder,
332 int32_t offset,
333 uint32_t valueIdx,
334 uint32_t dataIdx,
335 uint32_t& imageIdx) =0;
337
339
340
341 virtual TiffComponent* doClone() const =0;
343 virtual uint32_t doWriteData(IoWrapper& ioWrapper,
344 ByteOrder byteOrder,
345 int32_t offset,
346 uint32_t dataIdx,
347 uint32_t& imageIdx) const =0;
349 virtual uint32_t doWriteImage(IoWrapper& ioWrapper,
350 ByteOrder byteOrder) const =0;
352 virtual uint32_t doSize() const =0;
354 virtual uint32_t doCount() const =0;
356 virtual uint32_t doSizeData() const =0;
358 virtual uint32_t doSizeImage() const =0;
360
361 private:
362 // DATA
363 uint16_t tag_;
364 IfdId group_;
369 byte* pStart_;
370
371 }; // class TiffComponent
372
375 struct Key;
384 bool operator==(const Key& key) const;
386 uint16_t tag() const { return static_cast<uint16_t>(extendedTag_ & 0xffff); }
387
388 // DATA
389 const char* make_;
390 uint32_t extendedTag_;
394
395 }; // struct TiffMappingInfo
396
400 Key(std::string m, uint32_t e, IfdId g) : m_(std::move(m)), e_(e), g_(g)
401 {
402 }
403 std::string m_;
404 uint32_t e_;
406 };
407
415 friend class TiffReader;
416 friend class TiffEncoder;
417 friend int selectNikonLd(TiffBinaryArray* const, TiffComponent* const);
418 public:
420
421
424 ~TiffEntryBase() override;
426
428
429
436 void encode(TiffEncoder& encoder, const Exifdatum* datum);
438 void setOffset(int32_t offset) { offset_ = offset; }
440 void setData(byte* pData, int32_t size);
442 void setData(DataBuf buf);
448 void updateValue(Value::UniquePtr value, ByteOrder byteOrder);
454 void setValue(Value::UniquePtr value);
456
458
459
460 TiffType tiffType() const { return tiffType_; }
465 int32_t offset() const { return offset_; }
469 int idx() const override;
474 const byte* pData() const { return pData_; }
476 const Value* pValue() const { return pValue_; }
478
479 protected:
481
482
483 TiffEntryBase(const TiffEntryBase& rhs);
485
487
488
489 virtual void doEncode(TiffEncoder& encoder, const Exifdatum* datum) =0;
491 void setCount(uint32_t count) { count_ = count; }
493 void setIdx(int idx) { idx_ = idx; }
499 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
500 uint32_t& imageIdx) override;
502
504
505
506 uint32_t doCount() const override;
511 uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx,
512 uint32_t& imageIdx) const override;
517 uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
519 uint32_t doSize() const override;
521 uint32_t doSizeData() const override;
523 uint32_t doSizeImage() const override;
525
527 static uint32_t writeOffset(byte* buf,
528 int32_t offset,
530 ByteOrder byteOrder);
531
532 private:
534
535
536 TiffEntryBase& operator=(const TiffEntryBase& rhs);
538
539 // DATA
540 TiffType tiffType_;
541 uint32_t count_;
542 int32_t offset_;
547 uint32_t size_;
548 byte* pData_;
549 bool isMalloced_;
550 int idx_;
551 Value* pValue_;
552
553 }; // class TiffEntryBase
554
558 class TiffEntry : public TiffEntryBase {
559 public:
561
562
565 ~TiffEntry() override = default;
567
568 protected:
570
571 void doAccept(TiffVisitor& visitor) override;
572 void doEncode(TiffEncoder& encoder, const Exifdatum* datum) override;
574
576
577 TiffEntry* doClone() const override;
579
580 }; // class TiffEntry
581
591 public:
593
594
597 szTag_(szTag), szGroup_(szGroup) {}
599 ~TiffDataEntryBase() override = default;
601
603
604
613 virtual void setStrips(const Value* pSize,
614 const byte* pData,
615 uint32_t sizeData,
616 uint32_t baseOffset) =0;
618
620
621
622 uint16_t szTag() const { return szTag_; }
624 IfdId szGroup() const { return szGroup_; }
626
627 private:
628 // DATA
629 const uint16_t szTag_;
630 const IfdId szGroup_;
631
632 }; // class TiffDataEntryBase
633
646 friend class TiffEncoder;
647 public:
649
650
653 pDataArea_(0), sizeDataArea_(0) {}
655 ~TiffDataEntry() override = default;
657
659
660 void setStrips(const Value* pSize, const byte* pData, uint32_t sizeData, uint32_t baseOffset) override;
662
663 protected:
665
666 void doAccept(TiffVisitor& visitor) override;
667 void doEncode(TiffEncoder& encoder, const Exifdatum* datum) override;
679 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
680 uint32_t& imageIdx) override;
682
684
685 TiffDataEntry* doClone() const override;
690 uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx,
691 uint32_t& imageIdx) const override;
692 // Using doWriteImage from base class
693 // Using doSize() from base class
695 uint32_t doSizeData() const override;
696 // Using doSizeImage from base class
698
699 private:
700 // DATA
701 byte* pDataArea_;
702 uint32_t sizeDataArea_;
703
704 }; // class TiffDataEntry
705
719 friend class TiffEncoder;
720 public:
722
723
727 ~TiffImageEntry() override = default;
729
731
732 void setStrips(const Value* pSize, const byte* pData, uint32_t sizeData, uint32_t baseOffset) override;
734
735 protected:
737
738 void doAccept(TiffVisitor& visitor) override;
739 void doEncode(TiffEncoder& encoder, const Exifdatum* datum) override;
745 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
746 uint32_t& imageIdx) override;
748
750
751 TiffImageEntry* doClone() const override;
760 uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx,
761 uint32_t& imageIdx) const override;
766 uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
768 uint32_t doSize() const override;
770 uint32_t doSizeData() const override;
772 uint32_t doSizeImage() const override;
774
775 private:
777 using Strips = std::vector<std::pair<const byte*, uint32_t>>;
778
779 // DATA
780 Strips strips_;
781
782 }; // class TiffImageEntry
783
791 public:
793
794
796 : TiffEntryBase(tag, group), dtTag_(dtTag), dtGroup_(dtGroup) {}
798 ~TiffSizeEntry() override = default;
800
802
803
804 uint16_t dtTag() const { return dtTag_; }
806 IfdId dtGroup() const { return dtGroup_; }
808
809 protected:
811
812 void doAccept(TiffVisitor& visitor) override;
813 void doEncode(TiffEncoder& encoder, const Exifdatum* datum) override;
815
817
818 TiffSizeEntry* doClone() const override;
820
821 private:
822 // DATA
823 const uint16_t dtTag_;
824 const IfdId dtGroup_;
825
826 }; // class TiffSizeEntry
827
833 friend class TiffEncoder;
834 friend class TiffDecoder;
835 public:
837
838
839 TiffDirectory(uint16_t tag, IfdId group, bool hasNext =true)
840 : TiffComponent(tag, group), hasNext_(hasNext), pNext_(0) {}
842 ~TiffDirectory() override;
844
846
847
848 bool hasNext() const { return hasNext_; }
850
851 protected:
853
854
855 TiffDirectory(const TiffDirectory& rhs);
857
859
860 TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
861 TiffComponent::UniquePtr object) override;
862 TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
863 TiffComponent* doAddNext(TiffComponent::UniquePtr tiffComponent) override;
864 void doAccept(TiffVisitor& visitor) override;
870 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
871 uint32_t& imageIdx) override;
873
875
876 TiffDirectory* doClone() const override;
881 uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx,
882 uint32_t& imageIdx) const override;
889 uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
894 uint32_t doSize() const override;
899 uint32_t doCount() const override;
904 uint32_t doSizeData() const override;
909 uint32_t doSizeImage() const override;
911
912 private:
914
915
916 TiffDirectory& operator=(const TiffDirectory& rhs);
918
920
921
922 static uint32_t writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset,
923 TiffComponent* pTiffComponent, uint32_t valueIdx, uint32_t dataIdx,
924 uint32_t& imageIdx);
926
927 private:
928 // DATA
929 Components components_;
930 const bool hasNext_;
931 TiffComponent* pNext_;
932
933 }; // class TiffDirectory
934
942 class TiffSubIfd : public TiffEntryBase {
943 friend class TiffReader;
944 public:
946
947
948 TiffSubIfd(uint16_t tag, IfdId group, IfdId newGroup);
950 ~TiffSubIfd() override;
952
953 protected:
955
956
957 TiffSubIfd(const TiffSubIfd& rhs);
959
961
962 TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
963 TiffComponent::UniquePtr object) override;
964 TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
965 void doAccept(TiffVisitor& visitor) override;
966 void doEncode(TiffEncoder& encoder, const Exifdatum* datum) override;
972 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
973 uint32_t& imageIdx) override;
975
977
978 TiffSubIfd* doClone() const override;
983 uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx,
984 uint32_t& imageIdx) const override;
989 uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
991 uint32_t doSize() const override;
993 uint32_t doSizeData() const override;
995 uint32_t doSizeImage() const override;
997
998 private:
1000
1001
1002 TiffSubIfd& operator=(const TiffSubIfd& rhs);
1004
1006 using Ifds = std::vector<TiffDirectory*>;
1007
1008 // DATA
1009 IfdId newGroup_;
1010 Ifds ifds_;
1011
1012 }; // class TiffSubIfd
1013
1022 friend class TiffReader;
1023 friend class TiffDecoder;
1024 friend class TiffEncoder;
1025 public:
1027
1028
1029 TiffMnEntry(uint16_t tag, IfdId group, IfdId mnGroup);
1031 ~TiffMnEntry() override;
1033
1034 protected:
1036
1037 TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
1038 TiffComponent::UniquePtr object) override;
1039 TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
1040 TiffComponent* doAddNext(TiffComponent::UniquePtr tiffComponent) override;
1041 void doAccept(TiffVisitor& visitor) override;
1042 void doEncode(TiffEncoder& encoder, const Exifdatum* datum) override;
1047 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
1048 uint32_t& imageIdx) override;
1050
1052
1053 TiffMnEntry* doClone() const override;
1055 uint32_t doCount() const override;
1056 // Using doWriteData from base class
1057 // Using doWriteImage from base class
1062 uint32_t doSize() const override;
1063 // Using doSizeData from base class
1064 // Using doSizeImage from base class
1066
1067 private:
1069
1070
1071 TiffMnEntry(const TiffMnEntry& rhs);
1073 TiffMnEntry& operator=(const TiffMnEntry& rhs);
1075
1076 // DATA
1077 IfdId mnGroup_;
1078 TiffComponent* mn_;
1079
1080 }; // class TiffMnEntry
1081
1092 friend class TiffReader;
1093 public:
1095
1096
1097 TiffIfdMakernote(uint16_t tag,
1098 IfdId group,
1099 IfdId mnGroup,
1100 MnHeader* pHeader,
1101 bool hasNext =true);
1103 ~TiffIfdMakernote() override;
1105
1107
1108
1113 bool readHeader(const byte* pData, uint32_t size, ByteOrder byteOrder);
1121 void setImageByteOrder(ByteOrder byteOrder) { imageByteOrder_ = byteOrder; }
1123
1125
1126
1127 uint32_t sizeHeader() const;
1129 uint32_t writeHeader(IoWrapper& ioWrapper, ByteOrder byteOrder) const;
1134 uint32_t mnOffset() const;
1140 uint32_t ifdOffset() const;
1147 ByteOrder byteOrder() const;
1151 ByteOrder imageByteOrder() const { return imageByteOrder_; }
1157 uint32_t baseOffset() const;
1159
1160 protected:
1162
1163 TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
1164 TiffComponent::UniquePtr object) override;
1165 TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
1166 TiffComponent* doAddNext(TiffComponent::UniquePtr tiffComponent) override;
1167 void doAccept(TiffVisitor& visitor) override;
1173 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
1174 uint32_t& imageIdx) override;
1176
1178
1179 TiffIfdMakernote* doClone() const override;
1184 uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx,
1185 uint32_t& imageIdx) const override;
1190 uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
1195 uint32_t doSize() const override;
1201 uint32_t doCount() const override;
1206 uint32_t doSizeData() const override;
1211 uint32_t doSizeImage() const override;
1213
1214 private:
1226 TiffIfdMakernote& operator=(const TiffIfdMakernote& rhs);
1228
1229 // DATA
1230 MnHeader* pHeader_;
1231 TiffDirectory ifd_;
1232 uint32_t mnOffset_;
1233 ByteOrder imageByteOrder_;
1234
1235 }; // class TiffIfdMakernote
1236
1241 using CfgSelFct = int (*)(uint16_t, const byte*, uint32_t, TiffComponent* const);
1242
1244 using CryptFct = DataBuf (*)(uint16_t, const byte*, uint32_t, TiffComponent* const);
1245
1247 struct ArrayDef {
1249 bool operator==(uint32_t idx) const { return idx_ == idx; }
1251 uint32_t size(uint16_t tag, IfdId group) const;
1252 // DATA
1253 uint32_t idx_;
1255 uint32_t count_;
1256 };
1257
1259 struct ArrayCfg {
1264 uint32_t tagStep() const { return elDefaultDef_.size(0, group_); }
1265 //DATA
1272 bool concat_;
1274 };
1275
1277 struct ArraySet {
1280 const int defSize_;
1281 };
1282
1289 public:
1291
1292
1293 TiffBinaryArray(uint16_t tag,
1294 IfdId group,
1295 const ArrayCfg* arrayCfg,
1296 const ArrayDef* arrayDef,
1297 int defSize);
1299 TiffBinaryArray(uint16_t tag,
1300 IfdId group,
1301 const ArraySet* arraySet,
1302 int setSize,
1303 CfgSelFct cfgSelFct);
1305 ~TiffBinaryArray() override;
1307
1309
1310
1311 uint32_t addElement(uint32_t idx, const ArrayDef& def);
1323 bool initialize(IfdId group);
1334 bool initialize(TiffComponent* const pRoot);
1336 void iniOrigDataBuf();
1338 bool updOrigDataBuf(const byte* pData, uint32_t size);
1340 void setDecoded(bool decoded) { decoded_ = decoded; }
1342
1344
1345
1346 const ArrayCfg* cfg() const { return arrayCfg_; }
1348 const ArrayDef* def() const { return arrayDef_; }
1350 int defSize() const { return defSize_; }
1352 bool decoded() const { return decoded_; }
1354
1355 protected:
1357
1358
1359 TiffBinaryArray(const TiffBinaryArray& rhs);
1361
1363
1364
1367 TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
1368 TiffComponent::UniquePtr object) override;
1372 TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
1373 void doAccept(TiffVisitor& visitor) override;
1374 void doEncode(TiffEncoder& encoder, const Exifdatum* datum) override;
1378 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
1379 uint32_t& imageIdx) override;
1381
1383
1384 TiffBinaryArray* doClone() const override;
1386 uint32_t doCount() const override;
1387 // Using doWriteData from base class
1388 // Using doWriteImage from base class
1392 uint32_t doSize() const override;
1393 // Using doSizeData from base class
1394 // Using doSizeImage from base class
1396
1397 private:
1399
1400
1401 TiffBinaryArray& operator=(const TiffBinaryArray& rhs);
1403
1404 // DATA
1405 const CfgSelFct cfgSelFct_;
1406 const ArraySet* arraySet_;
1407 const ArrayCfg* arrayCfg_;
1408 const ArrayDef* arrayDef_;
1409 int defSize_;
1410 int setSize_;
1411 Components elements_;
1412 byte* origData_;
1413 uint32_t origSize_;
1414 TiffComponent* pRoot_;
1415 bool decoded_;
1416 }; // class TiffBinaryArray
1417
1422 public:
1424
1425
1426 TiffBinaryElement(uint16_t tag, IfdId group);
1428 ~TiffBinaryElement() override = default;
1430
1432
1433
1436 void setElDef(const ArrayDef& def) { elDef_ = def; }
1440 void setElByteOrder(ByteOrder byteOrder) { elByteOrder_ = byteOrder; }
1442
1444
1445
1448 const ArrayDef* elDef() const { return &elDef_; }
1452 ByteOrder elByteOrder() const { return elByteOrder_; }
1454
1455 protected:
1457
1458 void doAccept(TiffVisitor& visitor) override;
1459 void doEncode(TiffEncoder& encoder, const Exifdatum* datum) override;
1463 uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx,
1464 uint32_t& imageIdx) override;
1466
1468
1469 TiffBinaryElement* doClone() const override;
1473 uint32_t doCount() const override;
1474 // Using doWriteData from base class
1475 // Using doWriteImage from base class
1480 uint32_t doSize() const override;
1481 // Using doSizeData from base class
1482 // Using doSizeImage from base class
1484
1485 private:
1486 // DATA
1487 ArrayDef elDef_;
1488 ByteOrder elByteOrder_;
1489
1490 }; // class TiffBinaryElement
1491
1492// *****************************************************************************
1493// template, inline and free functions
1494
1499 bool cmpTagLt(TiffComponent const* lhs, TiffComponent const* rhs);
1500
1505 bool cmpGroupLt(TiffComponent const* lhs, TiffComponent const* rhs);
1506
1508 TiffComponent::UniquePtr newTiffEntry(uint16_t tag, IfdId group);
1509
1511 TiffComponent::UniquePtr newTiffMnEntry(uint16_t tag, IfdId group);
1512
1515
1517 template<IfdId newGroup>
1519 {
1520 return TiffComponent::UniquePtr(new TiffDirectory(tag, newGroup));
1521 }
1522
1524 template<IfdId newGroup>
1526 {
1527 return TiffComponent::UniquePtr(new TiffSubIfd(tag, group, newGroup));
1528 }
1529
1531 template<const ArrayCfg* arrayCfg, int N, const ArrayDef (&arrayDef)[N]>
1533 {
1534 // *& acrobatics is a workaround for a MSVC 7.1 bug
1536 new TiffBinaryArray(tag, group, arrayCfg, *(&arrayDef), N));
1537 }
1538
1540 template<const ArrayCfg* arrayCfg>
1542 {
1544 new TiffBinaryArray(tag, group, arrayCfg, 0, 0));
1545 }
1546
1548 template<const ArraySet* arraySet, int N, CfgSelFct cfgSelFct>
1550 {
1552 new TiffBinaryArray(tag, group, arraySet, N, cfgSelFct));
1553 }
1554
1556 template<uint16_t szTag, IfdId szGroup>
1558 {
1560 new TiffDataEntry(tag, group, szTag, szGroup));
1561 }
1562
1564 template<uint16_t dtTag, IfdId dtGroup>
1566 {
1568 new TiffSizeEntry(tag, group, dtTag, dtGroup));
1569 }
1570
1572 template<uint16_t szTag, IfdId szGroup>
1574 {
1576 new TiffImageEntry(tag, group, szTag, szGroup));
1577 }
1578
1580 template<uint16_t dtTag, IfdId dtGroup>
1582 {
1583 // Todo: Same as newTiffThumbSize - consolidate (rename)?
1585 new TiffSizeEntry(tag, group, dtTag, dtGroup));
1586 }
1587
1588}} // namespace Internal, Exiv2
1589
1590#endif // #ifndef TIFFCOMPOSITE_INT_HPP_
An interface for simple binary IO.
Definition: basicio.hpp:55
An Exif metadatum, consisting of an ExifKey and a Value and methods to manipulate these.
Definition: exif.hpp:59
Simple IO wrapper to ensure that the header is only written if there is any other data at all.
Definition: tiffcomposite_int.hpp:122
int putb(byte data)
Wraps the corresponding BasicIo::putb() method.
Definition: tiffcomposite_int.cpp:75
IoWrapper(BasicIo &io, const byte *pHeader, long size, OffsetWriter *pow)
Definition: tiffcomposite_int.cpp:59
void setTarget(int id, uint32_t target)
Wrapper for OffsetWriter::setTarget(), using an int instead of the enum to reduce include deps.
Definition: tiffcomposite_int.cpp:84
long write(const byte *pData, long wcount)
Wraps the corresponding BasicIo::write() method.
Definition: tiffcomposite_int.cpp:66
Makernote header interface. This class is used with TIFF makernotes.
Definition: makernote_int.hpp:126
Class to insert pointers or offsets to computed addresses at specific locations in an image....
Definition: tiffimage_int.hpp:417
Composite to model an array of different tags. The tag types as well as other aspects of the array ar...
Definition: tiffcomposite_int.hpp:1288
TiffComponent * doAddPath(uint16_t tag, TiffPath &tiffPath, TiffComponent *const pRoot, TiffComponent::UniquePtr object) override
Implements addPath(). Todo: Document it!
Definition: tiffcomposite_int.cpp:732
const ArrayCfg * cfg() const
Return a pointer to the configuration.
Definition: tiffcomposite_int.hpp:1346
uint32_t doSize() const override
Implements size(). Todo: Document it!
Definition: tiffcomposite_int.cpp:1694
TiffBinaryArray * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:303
bool initialize(IfdId group)
Setup cfg and def for the component, in case of a complex binary array. Else do nothing....
Definition: tiffcomposite_int.cpp:537
void setDecoded(bool decoded)
Set a flag to indicate if the array was decoded.
Definition: tiffcomposite_int.hpp:1340
void doEncode(TiffEncoder &encoder, const Exifdatum *datum) override
Implements encode().
Definition: tiffcomposite_int.cpp:947
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write(). Todo: Document it!
Definition: tiffcomposite_int.cpp:1367
bool decoded() const
Return the flag which indicates if the array was decoded.
Definition: tiffcomposite_int.hpp:1352
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:921
bool updOrigDataBuf(const byte *pData, uint32_t size)
Update the original data buffer and its size, return true if successful.
Definition: tiffcomposite_int.cpp:573
~TiffBinaryArray() override
Virtual destructor.
Definition: tiffcomposite_int.cpp:207
uint32_t doCount() const override
Implements count(). Todo: Document it!
Definition: tiffcomposite_int.cpp:1020
void iniOrigDataBuf()
Initialize the original data buffer and its size from the base entry.
Definition: tiffcomposite_int.cpp:567
const ArrayDef * def() const
Return a pointer to the definition.
Definition: tiffcomposite_int.hpp:1348
int defSize() const
Return the number of elements in the definition.
Definition: tiffcomposite_int.hpp:1350
TiffComponent * doAddChild(TiffComponent::UniquePtr tiffComponent) override
Implements addChild(). Todo: Document it!
Definition: tiffcomposite_int.cpp:812
uint32_t addElement(uint32_t idx, const ArrayDef &def)
Add an element to the binary array, return the size of the element.
Definition: tiffcomposite_int.cpp:583
TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg *arrayCfg, const ArrayDef *arrayDef, int defSize)
Constructor.
Definition: tiffcomposite_int.cpp:129
Element of a TiffBinaryArray.
Definition: tiffcomposite_int.hpp:1421
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write(). Todo: Document it!
Definition: tiffcomposite_int.cpp:1430
TiffBinaryElement(uint16_t tag, IfdId group)
Constructor.
Definition: tiffcomposite_int.cpp:165
uint32_t doCount() const override
Implements count(). Returns the count from the element definition.
Definition: tiffcomposite_int.cpp:1043
void setElDef(const ArrayDef &def)
Set the array definition for this element.
Definition: tiffcomposite_int.hpp:1436
void doEncode(TiffEncoder &encoder, const Exifdatum *datum) override
Implements encode().
Definition: tiffcomposite_int.cpp:942
uint32_t doSize() const override
Implements size(). Returns count * type-size, both taken from the element definition.
Definition: tiffcomposite_int.cpp:1723
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:932
const ArrayDef * elDef() const
Return the array definition of this element.
Definition: tiffcomposite_int.hpp:1448
void setElByteOrder(ByteOrder byteOrder)
Set the byte order of this element.
Definition: tiffcomposite_int.hpp:1440
ByteOrder elByteOrder() const
Return the byte order of this element.
Definition: tiffcomposite_int.hpp:1452
~TiffBinaryElement() override=default
Virtual destructor.
TiffBinaryElement * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:308
Interface class for components of a TIFF directory hierarchy (Composite pattern). Both TIFF directori...
Definition: tiffcomposite_int.hpp:172
virtual TiffComponent * doClone() const =0
Internal virtual copy constructor, implements clone().
virtual uint32_t doWriteData(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t &imageIdx) const =0
Implements writeData().
uint32_t sizeImage() const
Return the size in bytes of the image data of this component when written to a binary image....
Definition: tiffcomposite_int.cpp:1776
virtual TiffComponent * doAddPath(uint16_t tag, TiffPath &tiffPath, TiffComponent *const pRoot, TiffComponent::UniquePtr object)
Implements addPath(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:608
byte * start() const
Return a pointer to the start of the binary representation of the component.
Definition: tiffcomposite_int.hpp:260
UniquePtr clone() const
Return an auto-pointer to a copy of itself (deep copy, but without any children). The caller owns thi...
Definition: tiffcomposite_int.cpp:256
uint32_t write(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx)
Write a TiffComponent to a binary image.
Definition: tiffcomposite_int.cpp:1048
uint32_t writeImage(IoWrapper &ioWrapper, ByteOrder byteOrder) const
Write the image data of this component to a binary image. Return the number of bytes written....
Definition: tiffcomposite_int.cpp:1534
uint32_t size() const
Return the size in bytes of the IFD value of this component when written to a binary image.
Definition: tiffcomposite_int.cpp:1634
virtual uint32_t doWriteImage(IoWrapper &ioWrapper, ByteOrder byteOrder) const =0
Implements writeImage().
uint16_t tag() const
Return the tag of this entry.
Definition: tiffcomposite_int.hpp:256
std::vector< TiffComponent * > Components
Container type to hold all metadata.
Definition: tiffcomposite_int.hpp:177
uint32_t count() const
Return the number of components in this component.
Definition: tiffcomposite_int.cpp:982
virtual uint32_t doSizeData() const =0
Implements sizeData().
void setStart(const byte *pStart)
Set a pointer to the start of the binary representation of the component in a memory buffer....
Definition: tiffcomposite_int.hpp:230
TiffComponent * addChild(UniquePtr tiffComponent)
Add a child to the component. Default is to do nothing.
Definition: tiffcomposite_int.cpp:773
virtual TiffComponent * doAddChild(UniquePtr tiffComponent)
Implements addChild(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:778
virtual uint32_t doSize() const =0
Implements size().
virtual ~TiffComponent()=default
Virtual destructor.
virtual void doAccept(TiffVisitor &visitor)=0
Implements accept().
virtual int idx() const
Return the unique id of the entry in the image.
Definition: tiffcomposite_int.cpp:313
std::unique_ptr< TiffComponent > UniquePtr
TiffComponent auto_ptr type.
Definition: tiffcomposite_int.hpp:175
uint32_t writeData(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t &imageIdx) const
Write the IFD data of this component to a binary image. Return the number of bytes written....
Definition: tiffcomposite_int.cpp:1445
virtual uint32_t doSizeImage() const =0
Implements sizeImage().
IfdId group() const
Return the group id of this component.
Definition: tiffcomposite_int.hpp:258
TiffComponent * addNext(UniquePtr tiffComponent)
Add a "next" component to the component. Default is to do nothing.
Definition: tiffcomposite_int.cpp:820
virtual TiffComponent * doAddNext(UniquePtr tiffComponent)
Implements addNext(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:825
virtual uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx)=0
Implements write().
TiffComponent * addPath(uint16_t tag, TiffPath &tiffPath, TiffComponent *const pRoot, UniquePtr object=UniquePtr(nullptr))
Add a TIFF entry tag to the component. Components on the path to the entry are added if they don't ex...
Definition: tiffcomposite_int.cpp:600
TiffComponent(uint16_t tag, IfdId group)
Constructor.
Definition: tiffcomposite_int.cpp:89
void accept(TiffVisitor &visitor)
Interface to accept visitors (Visitor pattern). Visitors can perform operations on all components of ...
Definition: tiffcomposite_int.cpp:854
virtual uint32_t doCount() const =0
Implements count().
uint32_t sizeData() const
Return the size in bytes of the IFD data of this component when written to a binary image....
Definition: tiffcomposite_int.cpp:1729
Interface for a standard TIFF IFD entry consisting of a value which is a set of offsets to a data are...
Definition: tiffcomposite_int.hpp:590
IfdId szGroup() const
Return the group of the entry which has the size.
Definition: tiffcomposite_int.hpp:624
virtual void setStrips(const Value *pSize, const byte *pData, uint32_t sizeData, uint32_t baseOffset)=0
Set the data areas ("strips").
TiffDataEntryBase(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup)
Constructor.
Definition: tiffcomposite_int.hpp:595
uint16_t szTag() const
Return the group of the entry which has the size.
Definition: tiffcomposite_int.hpp:622
~TiffDataEntryBase() override=default
Virtual destructor.
A standard TIFF IFD entry consisting of a value which is an offset to a data area and the data area....
Definition: tiffcomposite_int.hpp:645
void setStrips(const Value *pSize, const byte *pData, uint32_t sizeData, uint32_t baseOffset) override
Set the data areas ("strips").
Definition: tiffcomposite_int.cpp:367
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:864
TiffDataEntry(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup)
Constructor.
Definition: tiffcomposite_int.hpp:651
~TiffDataEntry() override=default
Virtual destructor.
uint32_t doWriteData(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t &imageIdx) const override
Implements writeData(). Write the data area to the ioWrapper. Return the number of bytes written.
Definition: tiffcomposite_int.cpp:1490
void doEncode(TiffEncoder &encoder, const Exifdatum *datum) override
Implements encode().
Definition: tiffcomposite_int.cpp:952
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write(). Write pointers into the data area to the ioWrapper, relative to the offsets in th...
Definition: tiffcomposite_int.cpp:1262
uint32_t doSizeData() const override
Implements sizeData(). Return the size of the data area.
Definition: tiffcomposite_int.cpp:1755
TiffDataEntry * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:266
TIFF composite visitor to decode metadata from the TIFF tree and add it to an Image,...
Definition: tiffvisitor_int.hpp:277
This class models a TIFF directory (Ifd). It is a composite component of the TIFF tree.
Definition: tiffcomposite_int.hpp:832
TiffDirectory(uint16_t tag, IfdId group, bool hasNext=true)
Default constructor.
Definition: tiffcomposite_int.hpp:839
TiffComponent * doAddChild(TiffComponent::UniquePtr tiffComponent) override
Implements addChild(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:783
uint32_t doWriteImage(IoWrapper &ioWrapper, ByteOrder byteOrder) const override
Implements writeImage(). Write the image data of the TIFF directory to the ioWrapper by forwarding th...
Definition: tiffcomposite_int.cpp:1540
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:879
uint32_t doCount() const override
Implements count(). Return the number of entries in the TIFF directory. Does not count entries which ...
Definition: tiffcomposite_int.cpp:987
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write(). Write the TIFF directory, values and additional data, including the next-IFD,...
Definition: tiffcomposite_int.cpp:1058
uint32_t doSize() const override
Implements size(). Return the size of the TIFF directory, values and additional data,...
Definition: tiffcomposite_int.cpp:1639
uint32_t doSizeData() const override
This class does not really implement sizeData(), it only has size(). This method must not be called; ...
Definition: tiffcomposite_int.cpp:1734
bool hasNext() const
Return true if the directory has a next pointer.
Definition: tiffcomposite_int.hpp:848
TiffComponent * doAddPath(uint16_t tag, TiffPath &tiffPath, TiffComponent *const pRoot, TiffComponent::UniquePtr object) override
Implements addPath(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:616
uint32_t doSizeImage() const override
Implements sizeImage(). Return the sum of the image sizes of all components plus that of the next-IFD...
Definition: tiffcomposite_int.cpp:1781
uint32_t doWriteData(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t &imageIdx) const override
This class does not really implement writeData(), it only has write(). This method must not be called...
Definition: tiffcomposite_int.cpp:1454
~TiffDirectory() override
Virtual destructor.
Definition: tiffcomposite_int.cpp:174
TiffDirectory * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:281
TiffComponent * doAddNext(TiffComponent::UniquePtr tiffComponent) override
Implements addNext(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:830
TIFF composite visitor to encode metadata from an image to the TIFF tree. The metadata containers and...
Definition: tiffvisitor_int.hpp:377
This abstract base class provides the common functionality of an IFD directory entry and defines an e...
Definition: tiffcomposite_int.hpp:414
void updateValue(Value::UniquePtr value, ByteOrder byteOrder)
Update the value. Takes ownership of the pointer passed in.
Definition: tiffcomposite_int.cpp:341
void encode(TiffEncoder &encoder, const Exifdatum *datum)
Encode a TIFF component from the metadatum provided and information from the encoder as needed.
Definition: tiffcomposite_int.cpp:937
uint32_t doSize() const override
Implements size(). Return the size of a standard TIFF entry.
Definition: tiffcomposite_int.cpp:1666
void setIdx(int idx)
Set the unique id of the entry in the image.
Definition: tiffcomposite_int.hpp:493
TiffEntryBase(uint16_t tag, IfdId group, TiffType tiffType=ttUndefined)
Default constructor.
Definition: tiffcomposite_int.cpp:93
void setOffset(int32_t offset)
Set the offset.
Definition: tiffcomposite_int.hpp:438
void setData(byte *pData, int32_t size)
Set pointer and size of the entry's data (not taking ownership of the data).
Definition: tiffcomposite_int.cpp:330
const byte * pData() const
Return a pointer to the binary representation of the value of this component.
Definition: tiffcomposite_int.hpp:474
TiffType tiffType() const
Return the TIFF type.
Definition: tiffcomposite_int.hpp:460
static uint32_t writeOffset(byte *buf, int32_t offset, TiffType tiffType, ByteOrder byteOrder)
Helper function to write an offset to a preallocated binary buffer.
Definition: tiffcomposite_int.cpp:1239
uint32_t doSizeData() const override
Implements sizeData(). Return 0.
Definition: tiffcomposite_int.cpp:1740
~TiffEntryBase() override
Virtual destructor.
Definition: tiffcomposite_int.cpp:189
const Value * pValue() const
Return a const pointer to the converted value of this component.
Definition: tiffcomposite_int.hpp:476
uint32_t doWriteImage(IoWrapper &ioWrapper, ByteOrder byteOrder) const override
Implements writeImage(). Standard TIFF entries have no image data: write nothing and return 0.
Definition: tiffcomposite_int.cpp:1567
uint32_t doWriteData(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t &imageIdx) const override
Implements writeData(). Standard TIFF entries have no data: write nothing and return 0.
Definition: tiffcomposite_int.cpp:1467
virtual void doEncode(TiffEncoder &encoder, const Exifdatum *datum)=0
Implements encode().
int idx() const override
Return the unique id of the entry in the image.
Definition: tiffcomposite_int.cpp:318
int32_t offset() const
Return the offset to the data area relative to the base for the component (usually the start of the T...
Definition: tiffcomposite_int.hpp:465
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write(). Write the value of a standard TIFF entry to the ioWrapper, return the number of b...
Definition: tiffcomposite_int.cpp:1224
uint32_t doCount() const override
Implements count().
Definition: tiffcomposite_int.cpp:992
void setCount(uint32_t count)
Set the number of components in this entry.
Definition: tiffcomposite_int.hpp:491
uint32_t doSizeImage() const override
Implements sizeImage(). Return 0.
Definition: tiffcomposite_int.cpp:1807
void setValue(Value::UniquePtr value)
Set tag value. Takes ownership of the pointer passed in.
Definition: tiffcomposite_int.cpp:357
A standard TIFF IFD entry.
Definition: tiffcomposite_int.hpp:558
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:859
TiffEntry * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:261
~TiffEntry() override=default
Virtual destructor.
TiffEntry(uint16_t tag, IfdId group)
Constructor.
Definition: tiffcomposite_int.hpp:563
void doEncode(TiffEncoder &encoder, const Exifdatum *datum) override
Implements encode().
Definition: tiffcomposite_int.cpp:957
Tiff IFD Makernote. This is a concrete class suitable for all IFD makernotes.
Definition: tiffcomposite_int.hpp:1091
TiffComponent * doAddNext(TiffComponent::UniquePtr tiffComponent) override
Implements addNext(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:849
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write(). Write the Makernote header, TIFF directory, values and additional data to the ioW...
Definition: tiffcomposite_int.cpp:1350
void setByteOrder(ByteOrder byteOrder)
Set the byte order for the makernote.
Definition: tiffcomposite_int.cpp:514
uint32_t doSize() const override
Implements size(). Return the size of the Makernote header, TIFF directory, values and additional dat...
Definition: tiffcomposite_int.cpp:1689
uint32_t doSizeData() const override
This class does not really implement sizeData(), it only has size(). This method must not be called; ...
Definition: tiffcomposite_int.cpp:1770
uint32_t doSizeImage() const override
Implements sizeImage(). Return the total image data size of the makernote IFD.
Definition: tiffcomposite_int.cpp:1802
bool readHeader(const byte *pData, uint32_t size, ByteOrder byteOrder)
Read the header from a data buffer, return true if successful.
Definition: tiffcomposite_int.cpp:506
uint32_t doWriteData(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t &imageIdx) const override
This class does not really implement writeData(), it only has write(). This method must not be called...
Definition: tiffcomposite_int.cpp:1524
uint32_t sizeHeader() const
Return the size of the header in bytes.
Definition: tiffcomposite_int.cpp:519
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:913
ByteOrder imageByteOrder() const
Return the byte order used for the image.
Definition: tiffcomposite_int.hpp:1151
~TiffIfdMakernote() override
Virtual destructor.
Definition: tiffcomposite_int.cpp:202
uint32_t doWriteImage(IoWrapper &ioWrapper, ByteOrder byteOrder) const override
Implements writeImage(). Write the image data of the IFD of the Makernote. Return the number of bytes...
Definition: tiffcomposite_int.cpp:1583
TiffIfdMakernote * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:297
TiffComponent * doAddPath(uint16_t tag, TiffPath &tiffPath, TiffComponent *const pRoot, TiffComponent::UniquePtr object) override
Implements addPath(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:724
void setImageByteOrder(ByteOrder byteOrder)
Set the byte order used for the image.
Definition: tiffcomposite_int.hpp:1121
uint32_t doCount() const override
Implements count(). Return the number of entries in the IFD of the Makernote. Does not count entries ...
Definition: tiffcomposite_int.cpp:1015
uint32_t baseOffset() const
Return the base offset for use with the makernote IFD entries relative to the start of the TIFF heade...
Definition: tiffcomposite_int.cpp:500
uint32_t ifdOffset() const
Return the offset to the start of the Makernote IFD from the start of the Makernote....
Definition: tiffcomposite_int.cpp:480
ByteOrder byteOrder() const
Return the byte order for the makernote. Requires the image byte order to be set (setImageByteOrder()...
Definition: tiffcomposite_int.cpp:486
uint32_t mnOffset() const
Return the offset to the makernote from the start of the TIFF header.
Definition: tiffcomposite_int.cpp:495
TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, MnHeader *pHeader, bool hasNext=true)
Default constructor.
Definition: tiffcomposite_int.cpp:116
uint32_t writeHeader(IoWrapper &ioWrapper, ByteOrder byteOrder) const
Write the header to a data buffer, return the number of bytes written.
Definition: tiffcomposite_int.cpp:525
TiffComponent * doAddChild(TiffComponent::UniquePtr tiffComponent) override
Implements addChild(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:807
A standard TIFF IFD entry consisting of a value which is an array of offsets to image data areas....
Definition: tiffcomposite_int.hpp:718
void doEncode(TiffEncoder &encoder, const Exifdatum *datum) override
Implements encode().
Definition: tiffcomposite_int.cpp:962
uint32_t doSizeImage() const override
Implements sizeImage(). Return the size of the image data area.
Definition: tiffcomposite_int.cpp:1812
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:869
uint32_t doSizeData() const override
Implements sizeData(). Return the size of the image data area.
Definition: tiffcomposite_int.cpp:1745
~TiffImageEntry() override=default
Virtual destructor.
TiffImageEntry * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:271
uint32_t doWriteImage(IoWrapper &ioWrapper, ByteOrder byteOrder) const override
Implements writeImage(). Write the image data area to the ioWrapper. Return the number of bytes writt...
Definition: tiffcomposite_int.cpp:1593
TiffImageEntry(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup)
Constructor.
Definition: tiffcomposite_int.hpp:724
uint32_t doSize() const override
Implements size(). Return the size of the strip pointers.
Definition: tiffcomposite_int.cpp:1671
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write(). Write pointers into the image data area to the ioWrapper. Return the number of by...
Definition: tiffcomposite_int.cpp:1286
uint32_t doWriteData(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t &imageIdx) const override
Implements writeData(). Write the image data area to the ioWrapper. Return the number of bytes writte...
Definition: tiffcomposite_int.cpp:1476
void setStrips(const Value *pSize, const byte *pData, uint32_t sizeData, uint32_t baseOffset) override
Set the data areas ("strips").
Definition: tiffcomposite_int.cpp:434
This class is the basis for Makernote support in TIFF. It contains a pointer to a concrete Makernote....
Definition: tiffcomposite_int.hpp:1021
uint32_t doSize() const override
Implements size() by forwarding the call to the actual concrete Makernote, if there is one.
Definition: tiffcomposite_int.cpp:1681
TiffComponent * doAddNext(TiffComponent::UniquePtr tiffComponent) override
Implements addNext(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:840
TiffMnEntry(uint16_t tag, IfdId group, IfdId mnGroup)
Default constructor.
Definition: tiffcomposite_int.cpp:111
TiffMnEntry * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:291
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:902
void doEncode(TiffEncoder &encoder, const Exifdatum *datum) override
Implements encode().
Definition: tiffcomposite_int.cpp:967
TiffComponent * doAddChild(TiffComponent::UniquePtr tiffComponent) override
Implements addChild(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:798
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write() by forwarding the call to the actual concrete Makernote, if there is one.
Definition: tiffcomposite_int.cpp:1337
TiffComponent * doAddPath(uint16_t tag, TiffPath &tiffPath, TiffComponent *const pRoot, TiffComponent::UniquePtr object) override
Implements addPath(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:702
~TiffMnEntry() override
Virtual destructor.
Definition: tiffcomposite_int.cpp:197
uint32_t doCount() const override
Implements count(). Return number of components in the entry.
Definition: tiffcomposite_int.cpp:997
A tupel consisting of extended Tag and group used as an item in TIFF paths.
Definition: tiffcomposite_int.hpp:88
IfdId group() const
Return the group.
Definition: tiffcomposite_int.hpp:104
uint16_t tag() const
Return the tag corresponding to the extended tag.
Definition: tiffcomposite_int.hpp:100
TiffPathItem(uint32_t extendedTag, IfdId group)
Constructor.
Definition: tiffcomposite_int.hpp:93
uint32_t extendedTag() const
Return the extended tag (32 bit so that it can contain special tags)
Definition: tiffcomposite_int.hpp:102
TIFF composite visitor to read the TIFF structure from a block of memory and build the composite from...
Definition: tiffvisitor_int.hpp:614
A TIFF IFD entry containing the size of a data area of a related TiffDataEntry. This component is use...
Definition: tiffcomposite_int.hpp:790
IfdId dtGroup() const
Return the group of the related entry which has the data area.
Definition: tiffcomposite_int.hpp:806
TiffSizeEntry(uint16_t tag, IfdId group, uint16_t dtTag, IfdId dtGroup)
Constructor.
Definition: tiffcomposite_int.hpp:795
uint16_t dtTag() const
Return the group of the related entry which has the data area.
Definition: tiffcomposite_int.hpp:804
TiffSizeEntry * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:276
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:874
void doEncode(TiffEncoder &encoder, const Exifdatum *datum) override
Implements encode().
Definition: tiffcomposite_int.cpp:972
~TiffSizeEntry() override=default
Virtual destructor.
This class models a TIFF sub-directory (sub-IFD). A sub-IFD is an entry with one or more values that ...
Definition: tiffcomposite_int.hpp:942
uint32_t doSize() const override
Implements size(). Return the size of the sub-Ifd pointers.
Definition: tiffcomposite_int.cpp:1676
TiffSubIfd * doClone() const override
Internal virtual copy constructor, implements clone().
Definition: tiffcomposite_int.cpp:286
~TiffSubIfd() override
Virtual destructor.
Definition: tiffcomposite_int.cpp:182
TiffComponent * doAddPath(uint16_t tag, TiffPath &tiffPath, TiffComponent *const pRoot, TiffComponent::UniquePtr object) override
Implements addPath(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:668
uint32_t doSizeImage() const override
Implements sizeImage(). Return the sum of the image sizes of all sub-IFDs.
Definition: tiffcomposite_int.cpp:1793
uint32_t doWrite(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t &imageIdx) override
Implements write(). Write the sub-IFD pointers to the ioWrapper, return the number of bytes written....
Definition: tiffcomposite_int.cpp:1318
TiffSubIfd(uint16_t tag, IfdId group, IfdId newGroup)
Default constructor.
Definition: tiffcomposite_int.cpp:106
TiffComponent * doAddChild(TiffComponent::UniquePtr tiffComponent) override
Implements addChild(). The default implementation does nothing.
Definition: tiffcomposite_int.cpp:790
void doEncode(TiffEncoder &encoder, const Exifdatum *datum) override
Implements encode().
Definition: tiffcomposite_int.cpp:977
uint32_t doWriteImage(IoWrapper &ioWrapper, ByteOrder byteOrder) const override
Implements writeImage(). Write the image data of each sub-IFD to the ioWrapper. Return the number of ...
Definition: tiffcomposite_int.cpp:1573
uint32_t doWriteData(IoWrapper &ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t &imageIdx) const override
Implements writeData(). Write the sub-IFDs to the ioWrapper. Return the number of bytes written.
Definition: tiffcomposite_int.cpp:1507
uint32_t doSizeData() const override
Implements sizeData(). Return the sum of the sizes of all sub-IFDs.
Definition: tiffcomposite_int.cpp:1761
void doAccept(TiffVisitor &visitor) override
Implements accept().
Definition: tiffcomposite_int.cpp:892
Abstract base class defining the interface for TIFF composite visitors (Visitor pattern)
Definition: tiffvisitor_int.hpp:66
Common interface for all types of values used with metadata.
Definition: value.hpp:51
std::unique_ptr< Value > UniquePtr
Shortcut for a Value auto pointer.
Definition: value.hpp:54
const uint32_t cmt2
Special tag: root IFD of CR3 images.
Definition: tiffcomposite_int.hpp:79
const uint32_t fuji
Special tag: root IFD of Fujifilm RAF images.
Definition: tiffcomposite_int.hpp:78
const uint32_t none
Dummy tag.
Definition: tiffcomposite_int.hpp:73
const uint32_t cmt4
Special tag: root IFD of CR3 images.
Definition: tiffcomposite_int.hpp:81
const uint32_t pana
Special tag: root IFD of Panasonic RAW images.
Definition: tiffcomposite_int.hpp:77
const uint32_t root
Special tag: root IFD.
Definition: tiffcomposite_int.hpp:74
const uint32_t cmt3
Special tag: root IFD of CR3 images.
Definition: tiffcomposite_int.hpp:80
const uint32_t all
Special tag: all tags in a group.
Definition: tiffcomposite_int.hpp:76
const uint32_t next
Special tag: next IFD.
Definition: tiffcomposite_int.hpp:75
const TiffType ttTiffFloat
TIFF FLOAT type.
Definition: tiffcomposite_int.hpp:60
TiffComponent::UniquePtr newTiffThumbSize(uint16_t tag, IfdId group)
Function to create and initialize a new TIFF entry for a thumbnail (size)
Definition: tiffcomposite_int.hpp:1565
const TiffType ttUnsignedLong
Exif LONG type.
Definition: tiffcomposite_int.hpp:53
const TiffType ttSignedByte
Exif SBYTE type.
Definition: tiffcomposite_int.hpp:55
const TiffType ttUnsignedRational
Exif RATIONAL type.
Definition: tiffcomposite_int.hpp:54
const TiffType ttTiffDouble
TIFF DOUBLE type.
Definition: tiffcomposite_int.hpp:61
TiffComponent::UniquePtr newTiffEntry(uint16_t tag, IfdId group)
Function to create and initialize a new TIFF entry.
Definition: tiffcomposite_int.cpp:1889
TiffComponent::UniquePtr newTiffBinaryArray0(uint16_t tag, IfdId group)
Function to create and initialize a new binary array entry.
Definition: tiffcomposite_int.hpp:1532
TiffComponent::UniquePtr newTiffDirectory(uint16_t tag, IfdId)
Function to create and initialize a new TIFF directory.
Definition: tiffcomposite_int.hpp:1518
void(TiffEncoder::*)(TiffEntryBase *, const Exifdatum *) EncoderFct
Function pointer type for a TiffDecoder member function to decode a TIFF component.
Definition: tifffwd_int.hpp:81
TiffComponent::UniquePtr newTiffMnEntry(uint16_t tag, IfdId group)
Function to create and initialize a new TIFF makernote entry.
Definition: tiffcomposite_int.cpp:1894
TiffComponent::UniquePtr newTiffSubIfd(uint16_t tag, IfdId group)
Function to create and initialize a new TIFF sub-directory.
Definition: tiffcomposite_int.hpp:1525
const TiffType ttTiffIfd
TIFF IFD type.
Definition: tiffcomposite_int.hpp:62
const TiffType ttSignedShort
Exif SSHORT type.
Definition: tiffcomposite_int.hpp:57
int(*)(uint16_t, const byte *, uint32_t, TiffComponent *const) CfgSelFct
Function pointer type for a function to determine which cfg + def of a corresponding array set to use...
Definition: tiffcomposite_int.hpp:1241
TiffComponent::UniquePtr newTiffImageData(uint16_t tag, IfdId group)
Function to create and initialize a new TIFF entry for image data.
Definition: tiffcomposite_int.hpp:1573
std::stack< TiffPathItem > TiffPath
Stack to hold a path from the TIFF root element to a TIFF entry.
Definition: tifffwd_int.hpp:98
bool cmpGroupLt(TiffComponent const *lhs, TiffComponent const *rhs)
Compare two TIFF component pointers by group. Return true if the group of component lhs is less than ...
Definition: tiffcomposite_int.cpp:1882
const TiffType ttAsciiString
Exif ASCII type.
Definition: tiffcomposite_int.hpp:51
const TiffType ttUnsignedShort
Exif SHORT type.
Definition: tiffcomposite_int.hpp:52
const TiffType ttSignedLong
Exif SLONG type.
Definition: tiffcomposite_int.hpp:58
void(TiffDecoder::*)(const TiffEntryBase *) DecoderFct
Function pointer type for a TiffDecoder member function to decode a TIFF component.
Definition: tifffwd_int.hpp:76
DataBuf(*)(uint16_t, const byte *, uint32_t, TiffComponent *const) CryptFct
Function pointer type for a crypt function used for binary arrays.
Definition: tiffcomposite_int.hpp:1244
TiffComponent::UniquePtr newTiffBinaryArray1(uint16_t tag, IfdId group)
Function to create and initialize a new simple binary array entry.
Definition: tiffcomposite_int.hpp:1541
TiffComponent::UniquePtr newTiffBinaryArray2(uint16_t tag, IfdId group)
Function to create and initialize a new complex binary array entry.
Definition: tiffcomposite_int.hpp:1549
IfdId
Type to specify the IFD to which a metadata belongs.
Definition: tags_int.hpp:46
const TiffType ttUnsignedByte
Exif BYTE type.
Definition: tiffcomposite_int.hpp:50
TiffComponent::UniquePtr newTiffThumbData(uint16_t tag, IfdId group)
Function to create and initialize a new TIFF entry for a thumbnail (data)
Definition: tiffcomposite_int.hpp:1557
TypeId toTypeId(TiffType tiffType, uint16_t tag, IfdId group)
Convert the tiffType of a tag and group to an Exiv2 typeId.
Definition: tiffcomposite_int.cpp:1842
TiffType toTiffType(TypeId typeId)
Convert the Exiv2 typeId to a TIFF value type.
Definition: tiffcomposite_int.cpp:1861
const TiffType ttUndefined
Exif UNDEFINED type.
Definition: tiffcomposite_int.hpp:56
uint16_t TiffType
TIFF value type.
Definition: tiffcomposite_int.hpp:48
bool cmpTagLt(TiffComponent const *lhs, TiffComponent const *rhs)
Compare two TIFF component pointers by tag. Return true if the tag of component lhs is less than that...
Definition: tiffcomposite_int.cpp:1874
TiffComponent::UniquePtr newTiffBinaryElement(uint16_t tag, IfdId group)
Function to create and initialize a new binary array element.
Definition: tiffcomposite_int.cpp:1899
TiffComponent::UniquePtr newTiffImageSize(uint16_t tag, IfdId group)
Function to create and initialize a new TIFF entry for image data (size)
Definition: tiffcomposite_int.hpp:1581
const TiffType ttSignedRational
Exif SRATIONAL type.
Definition: tiffcomposite_int.hpp:59
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: basicio.hpp:43
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:100
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:83
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:162
Additional configuration for a binary array.
Definition: tiffcomposite_int.hpp:1259
bool hasSize_
If true, first tag is the size element.
Definition: tiffcomposite_int.hpp:1270
uint32_t tagStep() const
Return the size of the default tag, which is used to calculate tag numbers as idx/tagStep.
Definition: tiffcomposite_int.hpp:1264
ArrayDef elDefaultDef_
Default element.
Definition: tiffcomposite_int.hpp:1273
bool concat_
If true, concatenate gaps between defined tags to single tags.
Definition: tiffcomposite_int.hpp:1272
CryptFct cryptFct_
Crypt function, 0 if not used.
Definition: tiffcomposite_int.hpp:1269
TiffType elTiffType_
Type for the array entry and the size element, if any.
Definition: tiffcomposite_int.hpp:1268
ByteOrder byteOrder_
Byte order, invalidByteOrder to inherit.
Definition: tiffcomposite_int.hpp:1267
IfdId group_
Group for the elements.
Definition: tiffcomposite_int.hpp:1266
bool hasFillers_
If true, write all defined tags.
Definition: tiffcomposite_int.hpp:1271
Defines one tag in a binary array.
Definition: tiffcomposite_int.hpp:1247
TiffType tiffType_
TIFF type of the element.
Definition: tiffcomposite_int.hpp:1254
bool operator==(uint32_t idx) const
Comparison with idx.
Definition: tiffcomposite_int.hpp:1249
uint32_t count_
Number of components.
Definition: tiffcomposite_int.hpp:1255
uint32_t size(uint16_t tag, IfdId group) const
Get the size in bytes of a tag.
Definition: tiffcomposite_int.cpp:531
uint32_t idx_
Index in bytes from the start.
Definition: tiffcomposite_int.hpp:1253
Combination of array configuration and definition for arrays.
Definition: tiffcomposite_int.hpp:1277
const ArrayDef * def_
Binary array definition array.
Definition: tiffcomposite_int.hpp:1279
const ArrayCfg cfg_
Binary array configuration.
Definition: tiffcomposite_int.hpp:1278
const int defSize_
Size of the array definition array.
Definition: tiffcomposite_int.hpp:1280
Search key for TIFF mapping structures.
Definition: tiffcomposite_int.hpp:398
Key(std::string m, uint32_t e, IfdId g)
Constructor.
Definition: tiffcomposite_int.hpp:400
std::string m_
Camera make.
Definition: tiffcomposite_int.hpp:403
uint32_t e_
Extended tag.
Definition: tiffcomposite_int.hpp:404
IfdId g_
Group
Definition: tiffcomposite_int.hpp:405
TIFF mapping table for functions to decode special cases.
Definition: tiffcomposite_int.hpp:374
IfdId group_
Group that contains the tag.
Definition: tiffcomposite_int.hpp:391
const char * make_
Camera make for which these mapping functions apply.
Definition: tiffcomposite_int.hpp:389
uint16_t tag() const
Return the tag corresponding to the extended tag.
Definition: tiffcomposite_int.hpp:386
bool operator==(const Key &key) const
Compare a TiffMappingInfo with a TiffMappingInfo::Key. The two are equal if TiffMappingInfo::make_ eq...
Definition: tiffcomposite_int.cpp:51
uint32_t extendedTag_
Tag (32 bit so that it can contain special tags)
Definition: tiffcomposite_int.hpp:390
DecoderFct decoderFct_
Decoder function for matching tags.
Definition: tiffcomposite_int.hpp:392
EncoderFct encoderFct_
Encoder function for matching tags.
Definition: tiffcomposite_int.hpp:393