| Exiv2

Loading...
Searching...
No Matches
iptc.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2
7#ifndef IPTC_HPP_
8#define IPTC_HPP_
9
10// *****************************************************************************
11#include "exiv2lib_export.h"
12
13// included header files
14#include "datasets.hpp"
15#include "metadatum.hpp"
16
17// *****************************************************************************
18// namespace extensions
19 namespace Exiv2 {
20// *****************************************************************************
21// class declarations
22 class ExifData;
23
24// *****************************************************************************
25// class definitions
26
33 class EXIV2API Iptcdatum : public Metadatum {
34 public:
36
37
49 explicit Iptcdatum(const IptcKey& key, const Value* pValue = nullptr);
51 Iptcdatum(const Iptcdatum& rhs);
53 ~Iptcdatum() override = default;
55
57
58
59 Iptcdatum& operator=(const Iptcdatum& rhs);
64 Iptcdatum& operator=(const uint16_t& value);
69 Iptcdatum& operator=(const std::string& value);
74 Iptcdatum& operator=(const Value& value);
75 void setValue(const Value* pValue) override;
84 int setValue(const std::string& value) override;
86
88
89 size_t copy(byte* buf, ByteOrder byteOrder) const override;
90 std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
97 [[nodiscard]] std::string key() const override;
102 [[nodiscard]] std::string recordName() const;
107 [[nodiscard]] uint16_t record() const;
108 [[nodiscard]] const char* familyName() const override;
109 [[nodiscard]] std::string groupName() const override;
114 [[nodiscard]] std::string tagName() const override;
115 [[nodiscard]] std::string tagLabel() const override;
116 [[nodiscard]] std::string tagDesc() const override;
118 [[nodiscard]] uint16_t tag() const override;
119 [[nodiscard]] TypeId typeId() const override;
120 [[nodiscard]] const char* typeName() const override;
121 [[nodiscard]] size_t typeSize() const override;
122 [[nodiscard]] size_t count() const override;
123 [[nodiscard]] size_t size() const override;
124 [[nodiscard]] std::string toString() const override;
125 [[nodiscard]] std::string toString(size_t n) const override;
126 [[nodiscard]] int64_t toInt64(size_t n = 0) const override;
127 [[nodiscard]] float toFloat(size_t n = 0) const override;
128 [[nodiscard]] Rational toRational(size_t n = 0) const override;
129 [[nodiscard]] Value::UniquePtr getValue() const override;
130 [[nodiscard]] const Value& value() const override;
132
133 private:
134 // DATA
135 IptcKey::UniquePtr key_;
136 Value::UniquePtr value_;
137
138}; // class Iptcdatum
139
141 using IptcMetadata = std::vector<Iptcdatum>;
142
153 class EXIV2API IptcData {
154 public:
156 using iterator = IptcMetadata::iterator;
158 using const_iterator = IptcMetadata::const_iterator;
159
160 // Use the compiler generated constructors and assignment operator
161
163
164
172 Iptcdatum& operator[](const std::string& key);
180 int add(const IptcKey& key, const Value* value);
187 int add(const Iptcdatum& iptcdatum);
194 iterator erase(iterator pos);
198 void clear() {
199 iptcMetadata_.clear();
200 }
201
202 void sortByKey();
204 void sortByTag();
206 iterator begin() {
207 return iptcMetadata_.begin();
208 }
209
210 iterator end() {
211 return iptcMetadata_.end();
212 }
213
217 iterator findKey(const IptcKey& key);
222 iterator findId(uint16_t dataset, uint16_t record = IptcDataSets::application2);
224
226
227
228 [[nodiscard]] const_iterator begin() const {
229 return iptcMetadata_.begin();
230 }
231
232 [[nodiscard]] const_iterator end() const {
233 return iptcMetadata_.end();
234 }
235
239 [[nodiscard]] const_iterator findKey(const IptcKey& key) const;
244 [[nodiscard]] const_iterator findId(uint16_t dataset, uint16_t record = IptcDataSets::application2) const;
246 [[nodiscard]] bool empty() const {
247 return iptcMetadata_.empty();
248 }
249
251 [[nodiscard]] size_t count() const {
252 return iptcMetadata_.size();
253 }
254
256 [[nodiscard]] size_t size() const;
257
259 [[nodiscard]] const char* detectCharset() const;
260
262 static void printStructure(std::ostream& out, const Slice<byte*>& bytes, size_t depth);
264
265 private:
266 // DATA
267 IptcMetadata iptcMetadata_;
268}; // class IptcData
269
274 class EXIV2API IptcParser {
275 public:
287 static int decode(IptcData& iptcData, const byte* pData, size_t size);
288
297 static DataBuf encode(const IptcData& iptcData);
298
299 private:
300 // Constant data
301 static constexpr byte marker_ = 0x1C; // Dataset marker
302
303}; // class IptcParser
304
305} // namespace Exiv2
306
307#endif // #ifndef IPTC_HPP_
Exiv2::ExifData
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition exif.hpp:379
Exiv2::IptcData
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition iptc.hpp:153
Exiv2::IptcData::begin
iterator begin()
Begin of the metadata.
Definition iptc.hpp:206
Exiv2::IptcData::begin
const_iterator begin() const
Begin of the metadata.
Definition iptc.hpp:228
Exiv2::IptcData::empty
bool empty() const
Return true if there is no IPTC metadata.
Definition iptc.hpp:246
Exiv2::IptcData::erase
iterator erase(iterator pos)
Delete the Iptcdatum at iterator position pos, return the position of the next Iptcdatum....
Definition iptc.cpp:274
Exiv2::IptcData::end
const_iterator end() const
End of the metadata.
Definition iptc.hpp:232
Exiv2::IptcData::end
iterator end()
End of the metadata.
Definition iptc.hpp:210
Exiv2::IptcData::add
int add(const IptcKey &key, const Value *value)
Add an Iptcdatum from the supplied key and value pair. This method copies (clones) the value....
Definition iptc.cpp:234
Exiv2::IptcData::const_iterator
IptcMetadata::const_iterator const_iterator
IptcMetadata const iterator type.
Definition iptc.hpp:158
Exiv2::IptcData::iterator
IptcMetadata::iterator iterator
IptcMetadata iterator type.
Definition iptc.hpp:156
Exiv2::IptcData::count
size_t count() const
Get the number of metadata entries.
Definition iptc.hpp:251
Exiv2::IptcData::operator[]
Iptcdatum & operator[](const std::string &key)
Returns a reference to the Iptcdatum that is associated with a particular key. If IptcData does not a...
Definition iptc.cpp:209
Exiv2::IptcData::clear
void clear()
Delete all Iptcdatum instances resulting in an empty container.
Definition iptc.hpp:198
Exiv2::IptcKey
Concrete keys for IPTC metadata.
Definition datasets.hpp:237
Exiv2::IptcKey::UniquePtr
std::unique_ptr< IptcKey > UniquePtr
Shortcut for an IptcKey auto pointer.
Definition datasets.hpp:240
Exiv2::IptcParser
Stateless parser class for IPTC data. Images use this class to decode and encode binary IPTC data.
Definition iptc.hpp:274
Exiv2::IptcParser::decode
static int decode(IptcData &iptcData, const byte *pData, size_t size)
Decode binary IPTC data in IPTC IIM4 format from a buffer pData of length size to the provided metada...
Definition iptc.cpp:363
Exiv2::IptcParser::encode
static DataBuf encode(const IptcData &iptcData)
Encode the IPTC datasets from iptcData to a binary representation in IPTC IIM4 format.
Definition iptc.cpp:422
Exiv2::Iptcdatum
An IPTC metadatum ("dataset"), consisting of an IptcKey and a Value and methods to manipulate these.
Definition iptc.hpp:33
Exiv2::Iptcdatum::familyName
const char * familyName() const override
Return the name of the metadata family (which is also the first part of the key).
Definition iptc.cpp:88
Exiv2::Iptcdatum::recordName
std::string recordName() const
Return the name of the record (deprecated).
Definition iptc.cpp:80
Exiv2::Iptcdatum::toString
std::string toString() const override
Return the value as a string.
Definition iptc.cpp:132
Exiv2::Iptcdatum::~Iptcdatum
~Iptcdatum() override=default
Destructor.
Exiv2::Iptcdatum::setValue
void setValue(const Value *pValue) override
Set the value. This method copies (clones) the value pointed to by pValue.
Definition iptc.cpp:195
Exiv2::Iptcdatum::getValue
Value::UniquePtr getValue() const override
Return an auto-pointer to a copy (clone) of the value. The caller owns this copy and the auto-poiner ...
Definition iptc.cpp:152
Exiv2::Iptcdatum::key
std::string key() const override
Return the key of the Iptcdatum. The key is of the form 'Iptc.recordName.datasetName'....
Definition iptc.cpp:76
Exiv2::Iptcdatum::record
uint16_t record() const
Return the record id.
Definition iptc.cpp:84
Exiv2::Iptcdatum::tagName
std::string tagName() const override
Return the name of the tag (aka dataset).
Definition iptc.cpp:96
Exiv2::Iptcdatum::copy
size_t copy(byte *buf, ByteOrder byteOrder) const override
Write value to a data buffer and return the number of bytes written.
Definition iptc.cpp:68
Exiv2::Iptcdatum::typeSize
size_t typeSize() const override
Return the size in bytes of one component of this type.
Definition iptc.cpp:120
Exiv2::Iptcdatum::operator=
Iptcdatum & operator=(const Iptcdatum &rhs)
Assignment operator.
Definition iptc.cpp:162
Exiv2::Iptcdatum::tagDesc
std::string tagDesc() const override
Return a description for the tag.
Definition iptc.cpp:104
Exiv2::Iptcdatum::tag
uint16_t tag() const override
Return the tag (aka dataset) number.
Definition iptc.cpp:108
Exiv2::Iptcdatum::toInt64
int64_t toInt64(size_t n=0) const override
Return the n-th component of the value converted to int64_t. The return value is -1 if the value is n...
Definition iptc.cpp:140
Exiv2::Iptcdatum::toFloat
float toFloat(size_t n=0) const override
Return the n-th component of the value converted to float. The return value is -1 if the value is not...
Definition iptc.cpp:144
Exiv2::Iptcdatum::tagLabel
std::string tagLabel() const override
Return a label for the tag.
Definition iptc.cpp:100
Exiv2::Iptcdatum::value
const Value & value() const override
Return a constant reference to the value.
Definition iptc.cpp:156
Exiv2::Iptcdatum::toRational
Rational toRational(size_t n=0) const override
Return the n-th component of the value converted to Rational. The return value is -1/1 if the value i...
Definition iptc.cpp:148
Exiv2::Iptcdatum::groupName
std::string groupName() const override
Return the name of the metadata group (which is also the second part of the key).
Definition iptc.cpp:92
Exiv2::Iptcdatum::typeName
const char * typeName() const override
Return the name of the type.
Definition iptc.cpp:116
Exiv2::Iptcdatum::typeId
TypeId typeId() const override
Return the type id of the value.
Definition iptc.cpp:112
Exiv2::Iptcdatum::write
std::ostream & write(std::ostream &os, const ExifData *pMetadata=nullptr) const override
Write the interpreted value to an output stream, return the stream.
Definition iptc.cpp:72
Exiv2::Iptcdatum::size
size_t size() const override
Return the size of the value in bytes.
Definition iptc.cpp:128
Exiv2::Iptcdatum::count
size_t count() const override
Return the number of components in the value.
Definition iptc.cpp:124
Exiv2::Iptcdatum::Iptcdatum
Iptcdatum(const IptcKey &key, const Value *pValue=nullptr)
Constructor for new tags created by an application. The Iptcdatum is created from a key / value pair....
Definition iptc.cpp:56
Exiv2::Value
Common interface for all types of values used with metadata.
Definition value.hpp:33
Exiv2::Value::UniquePtr
std::unique_ptr< Value > UniquePtr
Shortcut for a Value auto pointer.
Definition value.hpp:36
Exiv2
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
Exiv2::IptcMetadata
std::vector< Iptcdatum > IptcMetadata
Container type to hold all metadata.
Definition iptc.hpp:141
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition types.hpp:70
Exiv2::Rational
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition types.hpp:31
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian).
Definition types.hpp:34
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124
Exiv2::Slice
Slice (= view) for STL containers.
Definition slice.hpp:421