Exiv2
Loading...
Searching...
No Matches
tags.hpp
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef TAGS_HPP_
4#define TAGS_HPP_
5
6// *****************************************************************************
7#include "exiv2lib_export.h"
8
9// included header files
10#include "metadatum.hpp"
11
12// *****************************************************************************
13// namespace extensions
14namespace Exiv2 {
15// *****************************************************************************
16// class declarations
17class ExifData;
18class ExifKey;
19class Value;
20struct TagInfo;
21
22// *****************************************************************************
23// type definitions
24
26using PrintFct = std::ostream& (*)(std::ostream&, const Value&, const ExifData* pExifData);
28using TagListFct = const TagInfo* (*)();
29
30// *****************************************************************************
31// class definitions
32
34enum class IfdId : uint32_t {
35 ifdIdNotSet,
36 ifd0Id,
37 ifd1Id,
38 ifd2Id,
39 ifd3Id,
40 exifId,
41 gpsId,
42 iopId,
43 mpfId,
44 subImage1Id,
45 subImage2Id,
46 subImage3Id,
47 subImage4Id,
48 subImage5Id,
49 subImage6Id,
50 subImage7Id,
51 subImage8Id,
52 subImage9Id,
53 subThumb1Id,
54 panaRawId,
55 mnId,
56 canonId,
57 canonAfCId,
58 canonAfMiAdjId,
59 canonAmId,
60 canonAsId,
61 canonCbId,
62 canonCiId,
63 canonCsId,
64 canonFilId,
65 canonFlId,
66 canonHdrId,
67 canonLeId,
68 canonMeId,
69 canonMoID,
70 canonMvId,
71 canonRawBId,
72 canonSiId,
73 canonCfId,
74 canonContrastId,
75 canonFcd1Id,
76 canonFcd2Id,
77 canonFcd3Id,
78 canonLiOpId,
79 canonMyColorID,
80 canonPiId,
81 canonPaId,
82 canonTiId,
83 canonFiId,
84 canonPrId,
85 canonPreID,
86 canonVigCorId,
87 canonVigCor2Id,
88 canonWbId,
89 casioId,
90 casio2Id,
91 fujiId,
92 minoltaId,
93 minoltaCs5DId,
94 minoltaCs7DId,
95 minoltaCsOldId,
96 minoltaCsNewId,
97 nikon1Id,
98 nikon2Id,
99 nikon3Id,
100 nikonPvId,
101 nikonVrId,
102 nikonPcId,
103 nikonWtId,
104 nikonIiId,
105 nikonAfId,
106 nikonAf21Id,
107 nikonAf22Id,
108 nikonAFTId,
109 nikonFiId,
110 nikonMeId,
111 nikonFl1Id,
112 nikonFl2Id,
113 nikonFl3Id,
114 nikonFl6Id,
115 nikonFl7Id,
116 nikonSi1Id,
117 nikonSi2Id,
118 nikonSi3Id,
119 nikonSi4Id,
120 nikonSi5Id,
121 nikonSi6Id,
122 nikonLd1Id,
123 nikonLd2Id,
124 nikonLd3Id,
125 nikonLd4Id,
126 nikonCb1Id,
127 nikonCb2Id,
128 nikonCb2aId,
129 nikonCb2bId,
130 nikonCb3Id,
131 nikonCb4Id,
132 olympusId,
133 olympus2Id,
134 olympusCsId,
135 olympusEqId,
136 olympusRdId,
137 olympusRd2Id,
138 olympusIpId,
139 olympusFiId,
140 olympusFe1Id,
141 olympusFe2Id,
142 olympusFe3Id,
143 olympusFe4Id,
144 olympusFe5Id,
145 olympusFe6Id,
146 olympusFe7Id,
147 olympusFe8Id,
148 olympusFe9Id,
149 olympusRiId,
150 panasonicId,
151 pentaxId,
152 pentaxDngId,
153 samsung2Id,
154 samsungPvId,
155 samsungPwId,
156 sigmaId,
157 sony1Id,
158 sony2Id,
159 sonyMltId,
160 sony1CsId,
161 sony1Cs2Id,
162 sony2CsId,
163 sony2Cs2Id,
164 sony2FpId,
165 sonyMisc1Id,
166 sonyMisc2bId,
167 sonyMisc3cId,
168 sonySInfo1Id,
169 sony2010eId,
170 sony1MltCs7DId,
171 sony1MltCsOldId,
172 sony1MltCsNewId,
173 sony1MltCsA100Id,
174 tagInfoMvId,
175 lastId,
176 ignoreId = lastId
177};
178
179inline std::ostream& operator<<(std::ostream& os, IfdId id) {
180 return os << static_cast<int>(id);
181}
182
184struct EXIV2API GroupInfo {
185 using GroupName = std::string;
186 bool operator==(IfdId ifdId) const;
187 bool operator==(const GroupName& groupName) const;
189 const char* ifdName_;
190 const char* groupName_;
192};
193
198enum class SectionId {
199 sectionIdNotSet,
200 imgStruct, // 4.6.4 A
201 recOffset, // 4.6.4 B
202 imgCharacter, // 4.6.4 C
203 otherTags, // 4.6.4 D
204 exifFormat, // 4.6.3
205 exifVersion, // 4.6.5 A
206 imgConfig, // 4.6.5 C
207 userInfo, // 4.6.5 D
208 relatedFile, // 4.6.5 E
209 dateTime, // 4.6.5 F
210 captureCond, // 4.6.5 G
211 gpsTags, // 4.6.6
212 iopTags, // 4.6.7
213 mpfTags,
214 makerTags, // MakerNote
215 dngTags, // DNG Spec
216 panaRaw,
217 tiffEp, // TIFF-EP Spec
218 tiffPm6,
219 adobeOpi,
220 lastSectionId
221};
222
224struct EXIV2API TagInfo {
225 uint16_t tag_;
226 const char* name_;
227 const char* title_;
228 const char* desc_;
232 int16_t count_;
234};
235
237class EXIV2API ExifTags {
238 public:
240 static const GroupInfo* groupList();
242 static const TagInfo* tagList(const std::string& groupName);
244 static void taglist(std::ostream& os);
246 static void taglist(std::ostream& os, const std::string& groupName);
247
249 static const char* sectionName(const ExifKey& key);
251 static uint16_t defaultCount(const ExifKey& key);
253 static const char* ifdName(const std::string& groupName);
254
258 static bool isMakerGroup(const std::string& groupName);
264 static bool isExifGroup(const std::string& groupName);
265
266}; // class ExifTags
267
271class EXIV2API ExifKey : public Key {
272 public:
274 using UniquePtr = std::unique_ptr<ExifKey>;
275
277
278
286 explicit ExifKey(const std::string& key);
296 ExifKey(uint16_t tag, const std::string& groupName);
303 explicit ExifKey(const TagInfo& ti);
304
306 ExifKey(const ExifKey& rhs);
308 ~ExifKey() override;
310
312
313
316 ExifKey& operator=(const ExifKey& rhs);
318 void setIdx(int idx) const;
320
322
323 [[nodiscard]] std::string key() const override;
324 [[nodiscard]] const char* familyName() const override;
325 [[nodiscard]] std::string groupName() const override;
327 [[nodiscard]] IfdId ifdId() const;
328 [[nodiscard]] std::string tagName() const override;
329 [[nodiscard]] uint16_t tag() const override;
330 [[nodiscard]] std::string tagLabel() const override;
331 [[nodiscard]] std::string tagDesc() const override;
333 [[nodiscard]] TypeId defaultTypeId() const; // Todo: should be in the base class
334
335 [[nodiscard]] UniquePtr clone() const;
337 [[nodiscard]] int idx() const;
339
340 private:
342 [[nodiscard]] ExifKey* clone_() const override;
343
344 // Pimpl idiom
345 struct Impl;
346 std::unique_ptr<Impl> p_;
347
348}; // class ExifKey
349
350// *****************************************************************************
351// free functions
352
354EXIV2API std::ostream& operator<<(std::ostream& os, const TagInfo& ti);
355
356} // namespace Exiv2
357
358#endif // #ifndef TAGS_HPP_
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition exif.hpp:379
Concrete keys for Exif metadata and access to Exif tag reference data.
Definition tags.hpp:271
ExifKey(const std::string &key)
Constructor to create an Exif key from a key string.
Definition tags.cpp:258
ExifKey & operator=(const ExifKey &rhs)
Assignment operator.
Definition tags.cpp:267
std::string tagDesc() const override
Return a description for the tag.
Definition tags.cpp:301
int idx() const
Return the index (unique id of this key within the original Exif data, 0 if not set)
Definition tags.cpp:329
std::string tagName() const override
Return the name of the tag (which is also the third part of the key)
Definition tags.cpp:291
void setIdx(int idx) const
Set the index.
Definition tags.cpp:275
std::string key() const override
Return the key of the metadatum as a string. The key is of the form 'familyName.groupName....
Definition tags.cpp:279
std::string groupName() const override
Return the name of the group (the second part of the key)
Definition tags.cpp:287
TypeId defaultTypeId() const
Return the default type id for this tag.
Definition tags.cpp:307
~ExifKey() override
Destructor.
uint16_t tag() const override
Return the tag number.
Definition tags.cpp:313
std::string tagLabel() const override
Return a label for the tag.
Definition tags.cpp:295
std::unique_ptr< ExifKey > UniquePtr
Shortcut for an ExifKey auto pointer.
Definition tags.hpp:274
IfdId ifdId() const
Return the IFD id. (Do not use, this is meant for library internal use.)
Definition tags.cpp:325
const char * familyName() const override
Return an identifier for the type of metadata (the first part of the key)
Definition tags.cpp:283
Access to Exif group and tag lists and misc. tag reference methods, implemented as a static class.
Definition tags.hpp:237
static bool isExifGroup(const std::string &groupName)
Return true if groupName is a TIFF or Exif IFD, else false. This is used to differentiate between sta...
Definition tags.cpp:101
static uint16_t defaultCount(const ExifKey &key)
Return the default number of components (not bytes!) key has. (0=any, -1=count not known)
Definition tags.cpp:84
static const GroupInfo * groupList()
Return read-only list of built-in groups.
Definition tags.cpp:106
static const char * ifdName(const std::string &groupName)
Return the name of the IFD for the group.
Definition tags.cpp:91
static const char * sectionName(const ExifKey &key)
Return the name of the section for an Exif key.
Definition tags.cpp:76
static const TagInfo * tagList(const std::string &groupName)
Return read-only list of built-in groupName tags.
Definition tags.cpp:110
static void taglist(std::ostream &os)
Print a list of all standard Exif tags to output stream.
Definition tags.cpp:114
static bool isMakerGroup(const std::string &groupName)
Return true if groupName is a makernote group.
Definition tags.cpp:96
Common interface for all types of values used with metadata.
Definition value.hpp:33
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition tags_int.cpp:2477
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition datasets.cpp:590
const TagInfo *(*)() TagListFct
A function returning a tag list.
Definition tags.hpp:28
IfdId
Type to specify the IFD to which a metadata belongs.
Definition tags.hpp:34
TypeId
Exiv2 value type identifiers.
Definition types.hpp:70
SectionId
Section identifiers to logically group tags. A section consists of nothing more than a name,...
Definition tags.hpp:198
std::ostream &(*)(std::ostream &, const Value &, const ExifData *pExifData) PrintFct
Type for a function pointer for functions interpreting the tag value.
Definition tags.hpp:26
Internal Pimpl structure with private members and data of class ExifKey.
Definition tags.cpp:144
The details of an Exif group. Groups include IFDs and binary arrays.
Definition tags.hpp:184
TagListFct tagList_
Tag list.
Definition tags.hpp:191
const char * ifdName_
IFD name.
Definition tags.hpp:189
const char * groupName_
Group name, unique for each group.
Definition tags.hpp:190
bool operator==(IfdId ifdId) const
Comparison operator for IFD id.
Definition tags.cpp:68
IfdId ifdId_
IFD id.
Definition tags.hpp:188
Tag information.
Definition tags.hpp:224
uint16_t tag_
Tag.
Definition tags.hpp:225
IfdId ifdId_
Link to the (preferred) IFD.
Definition tags.hpp:229
int16_t count_
The number of values (not bytes!), 0=any, -1=count not known.
Definition tags.hpp:232
TypeId typeId_
Type id.
Definition tags.hpp:231
SectionId sectionId_
Section id.
Definition tags.hpp:230
const char * desc_
Short tag description.
Definition tags.hpp:228
const char * title_
Tag title.
Definition tags.hpp:227
PrintFct printFct_
Pointer to tag print function.
Definition tags.hpp:233
const char * name_
One word tag label.
Definition tags.hpp:226