Exiv2
tags.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 TAGS_HPP_
21#define TAGS_HPP_
22
23// *****************************************************************************
24#include "exiv2lib_export.h"
25
26// included header files
27#include "metadatum.hpp"
28
29// + standard includes
30#include <string>
31#include <iosfwd>
32#include <memory>
33
34// *****************************************************************************
35// namespace extensions
36namespace Exiv2 {
37
38// *****************************************************************************
39// class declarations
40 class ExifData;
41 class ExifKey;
42 class Value;
43 struct TagInfo;
44
45// *****************************************************************************
46// type definitions
47
49 typedef std::ostream& (*PrintFct)(std::ostream&, const Value&, const ExifData* pExifData);
51 typedef const TagInfo* (*TagListFct)();
52
53// *****************************************************************************
54// class definitions
55
57 struct EXIV2API GroupInfo {
58 struct GroupName;
59 bool operator==(int ifdId) const;
60 bool operator==(const GroupName& groupName) const;
61 int ifdId_;
62 const char* ifdName_;
63 const char* groupName_;
65 };
66
68 struct EXIV2API GroupInfo::GroupName {
69 explicit GroupName(std::string groupName);
70 std::string g_;
71 };
72
74 struct EXIV2API TagInfo {
75 uint16_t tag_;
76 const char* name_;
77 const char* title_;
78 const char* desc_;
79 int ifdId_;
82 int16_t count_;
84 }; // struct TagInfo
85
87 class EXIV2API ExifTags {
88 public:
90 ExifTags() = delete;
92 ExifTags(const ExifTags& rhs) = delete;
94 ExifTags& operator=(const ExifTags& rhs) = delete;
95
97 static const GroupInfo* groupList();
99 static const TagInfo* tagList(const std::string& groupName);
101 static void taglist(std::ostream& os);
103 static void taglist(std::ostream& os, const std::string& groupName);
104
106 static const char* sectionName(const ExifKey& key);
108 static uint16_t defaultCount(const ExifKey& key);
110 static const char* ifdName(const std::string& groupName);
111
115 static bool isMakerGroup(const std::string& groupName);
121 static bool isExifGroup(const std::string& groupName);
122
123 }; // class ExifTags
124
128 class EXIV2API ExifKey : public Key {
129 public:
131 typedef std::unique_ptr<ExifKey> UniquePtr;
132
134
135
143 explicit ExifKey(const std::string& key);
153 ExifKey(uint16_t tag, const std::string& groupName);
160 explicit ExifKey(const TagInfo& ti);
161
163 ExifKey(const ExifKey& rhs);
165 ~ExifKey() override;
167
169
170
173 ExifKey& operator=(const ExifKey& rhs);
175 void setIdx(int idx);
177
179
180 std::string key() const override;
181 const char* familyName() const override;
182 std::string groupName() const override;
184 int ifdId() const;
185 std::string tagName() const override;
186 uint16_t tag() const override;
187 std::string tagLabel() const override;
189 std::string tagDesc() const; // Todo: should be in the base class
191 TypeId defaultTypeId() const; // Todo: should be in the base class
192
193 UniquePtr clone() const;
195 int idx() const;
197
198 private:
200 ExifKey* clone_() const override;
201
202 // Pimpl idiom
203 struct Impl;
204 std::unique_ptr<Impl> p_;
205
206 }; // class ExifKey
207
208// *****************************************************************************
209// free functions
210
212 EXIV2API std::ostream& operator<<(std::ostream& os, const TagInfo& ti);
213
214} // namespace Exiv2
215
216#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:434
Concrete keys for Exif metadata and access to Exif tag reference data.
Definition: tags.hpp:128
std::unique_ptr< ExifKey > UniquePtr
Shortcut for an ExifKey auto pointer.
Definition: tags.hpp:131
~ExifKey() override
Destructor.
Access to Exif group and tag lists and misc. tag reference methods, implemented as a static class.
Definition: tags.hpp:87
ExifTags(const ExifTags &rhs)=delete
Prevent copy-construction: not implemented.
ExifTags()=delete
Prevent construction: not implemented.
ExifTags & operator=(const ExifTags &rhs)=delete
Prevent assignment: not implemented.
Abstract base class defining the Key of a metadatum. Keys are used to identify and group metadata.
Definition: metadatum.hpp:44
std::unique_ptr< Key > UniquePtr
Shortcut for a Key auto pointer.
Definition: metadatum.hpp:47
Common interface for all types of values used with metadata.
Definition: value.hpp:51
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition: tags_int.cpp:2559
void taglist(std::ostream &os, IfdId ifdId)
Print the list of tags for ifdId to the output stream os.
Definition: tags_int.cpp:2502
const TagInfo * tagList(IfdId ifdId)
Return the tag list for ifdId.
Definition: tags_int.cpp:2512
const char * ifdName(IfdId ifdId)
Return the name of the IFD.
Definition: tags_int.cpp:2552
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: basicio.hpp:43
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition: datasets.cpp:677
const TagInfo *(* TagListFct)()
A function returning a tag list.
Definition: tags.hpp:51
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:100
std::ostream &(* PrintFct)(std::ostream &, const Value &, const ExifData *pExifData)
Type for a function pointer for functions interpreting the tag value.
Definition: tags.hpp:49
Internal Pimpl structure with private members and data of class ExifKey.
Definition: tags.cpp:198
The details of an Exif group. Groups include IFDs and binary arrays.
Definition: tags.hpp:57
int ifdId_
IFD id.
Definition: tags.hpp:61
std::string g_
Group name.
Definition: tags.hpp:70
TagListFct tagList_
Tag list.
Definition: tags.hpp:64
const char * ifdName_
IFD name.
Definition: tags.hpp:62
const char * groupName_
Group name, unique for each group.
Definition: tags.hpp:63
Tag information.
Definition: tags.hpp:74
uint16_t tag_
Tag.
Definition: tags.hpp:75
int sectionId_
Section id.
Definition: tags.hpp:80
int16_t count_
The number of values (not bytes!), 0=any, -1=count not known.
Definition: tags.hpp:82
TypeId typeId_
Type id.
Definition: tags.hpp:81
int ifdId_
Link to the (preferred) IFD.
Definition: tags.hpp:79
const char * desc_
Short tag description.
Definition: tags.hpp:78
const char * title_
Tag title.
Definition: tags.hpp:77
PrintFct printFct_
Pointer to tag print function.
Definition: tags.hpp:83
const char * name_
One word tag label.
Definition: tags.hpp:76