Exiv2
iptc.hpp
Go to the documentation of this file.
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 */
24#ifndef IPTC_HPP_
25#define IPTC_HPP_
26
27// *****************************************************************************
28#include "exiv2lib_export.h"
29
30// included header files
31#include "metadatum.hpp"
32#include "datasets.hpp"
33
34// *****************************************************************************
35// namespace extensions
36namespace Exiv2 {
37
38// *****************************************************************************
39// class declarations
40 class ExifData;
41
42// *****************************************************************************
43// class definitions
44
49 class EXIV2API Iptcdatum : public Metadatum {
50 public:
52
53
65 explicit Iptcdatum(const IptcKey& key, const Value* pValue = nullptr);
67 Iptcdatum(const Iptcdatum& rhs);
69 ~Iptcdatum() override = default;
71
73
74
75 Iptcdatum& operator=(const Iptcdatum& rhs);
80 Iptcdatum& operator=(const uint16_t& value);
85 Iptcdatum& operator=(const std::string& value);
90 Iptcdatum& operator=(const Value& value);
91 void setValue(const Value* pValue) override;
100 int setValue(const std::string& value) override;
102
104
105 long copy(byte* buf, ByteOrder byteOrder) const override;
106 std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
113 std::string key() const override;
118 std::string recordName() const;
123 uint16_t record() const;
124 const char* familyName() const override;
125 std::string groupName() const override;
130 std::string tagName() const override;
131 std::string tagLabel() const override;
133 uint16_t tag() const override;
134 TypeId typeId() const override;
135 const char* typeName() const override;
136 long typeSize() const override;
137 long count() const override;
138 long size() const override;
139 std::string toString() const override;
140 std::string toString(long n) const override;
141 long toLong(long n = 0) const override;
142 float toFloat(long n = 0) const override;
143 Rational toRational(long n = 0) const override;
144 Value::UniquePtr getValue() const override;
145 const Value& value() const override;
147
148 private:
149 // DATA
150 IptcKey::UniquePtr key_;
151 Value::UniquePtr value_;
152
153 }; // class Iptcdatum
154
156 typedef std::vector<Iptcdatum> IptcMetadata;
157
169 class EXIV2API IptcData {
170 public:
172 typedef IptcMetadata::iterator iterator;
174 typedef IptcMetadata::const_iterator const_iterator;
175
176 // Use the compiler generated constructors and assignment operator
177
179
180
188 Iptcdatum& operator[](const std::string& key);
196 int add(const IptcKey& key, Value* value);
203 int add(const Iptcdatum& iptcdatum);
210 iterator erase(iterator pos);
214 void clear() { iptcMetadata_.clear(); }
216 void sortByKey();
218 void sortByTag();
220 iterator begin() { return iptcMetadata_.begin(); }
222 iterator end() { return iptcMetadata_.end(); }
227 iterator findKey(const IptcKey& key);
232 iterator findId(uint16_t dataset,
233 uint16_t record = IptcDataSets::application2);
235
237
238
239 const_iterator begin() const { return iptcMetadata_.begin(); }
241 const_iterator end() const { return iptcMetadata_.end(); }
246 const_iterator findKey(const IptcKey& key) const;
251 const_iterator findId(uint16_t dataset,
252 uint16_t record = IptcDataSets::application2) const;
254 bool empty() const { return count() == 0; }
256 long count() const { return static_cast<long>(iptcMetadata_.size()); }
260 long size() const;
264 const char *detectCharset() const;
268 static void printStructure(std::ostream& out, const Slice<byte*>& bytes,uint32_t depth);
270
271 private:
272 // DATA
273 IptcMetadata iptcMetadata_;
274 }; // class IptcData
275
280 class EXIV2API IptcParser {
281 public:
293 static int decode(
294 IptcData& iptcData,
295 const byte* pData,
296 uint32_t size
297 );
307 static DataBuf encode(
308 const IptcData& iptcData
309 );
310
311 private:
312 // Constant data
313 static const byte marker_; // Dataset marker
314
315 }; // class IptcParser
316
317} // namespace Exiv2
318
319#endif // #ifndef IPTC_HPP_
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition: exif.hpp:434
A container for IPTC data. This is a top-level class of the Exiv2 library.
Definition: iptc.hpp:169
iterator begin()
Begin of the metadata.
Definition: iptc.hpp:220
IptcMetadata::iterator iterator
IptcMetadata iterator type.
Definition: iptc.hpp:172
const_iterator begin() const
Begin of the metadata.
Definition: iptc.hpp:239
bool empty() const
Return true if there is no IPTC metadata.
Definition: iptc.hpp:254
const_iterator end() const
End of the metadata.
Definition: iptc.hpp:241
iterator end()
End of the metadata.
Definition: iptc.hpp:222
IptcMetadata::const_iterator const_iterator
IptcMetadata const iterator type.
Definition: iptc.hpp:174
long count() const
Get the number of metadata entries.
Definition: iptc.hpp:256
void clear()
Delete all Iptcdatum instances resulting in an empty container.
Definition: iptc.hpp:214
Concrete keys for IPTC metadata.
Definition: datasets.hpp:257
std::unique_ptr< IptcKey > UniquePtr
Shortcut for an IptcKey auto pointer.
Definition: datasets.hpp:260
Stateless parser class for IPTC data. Images use this class to decode and encode binary IPTC data.
Definition: iptc.hpp:280
An IPTC metadatum ("dataset"), consisting of an IptcKey and a Value and methods to manipulate these.
Definition: iptc.hpp:49
~Iptcdatum() override=default
Destructor.
Abstract base class defining the interface to access information related to one metadata tag.
Definition: metadatum.hpp:115
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
IPTC dataset and type information.
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition: tags_int.cpp:2559
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: basicio.hpp:43
T getValue(const byte *buf, ByteOrder byteOrder)
Read a value of type T from the data buffer.
Definition: value.hpp:1346
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:100
std::vector< Iptcdatum > IptcMetadata
Container type to hold all metadata.
Definition: iptc.hpp:156
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:83
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition: types.hpp:80
Exiv2::Exifdatum & setValue(Exiv2::Exifdatum &exifDatum, const T &value)
Set the value of exifDatum to value. If the object already has a value, it is replaced....
Definition: exif.cpp:195
std::string toString(const T &arg)
Utility function to convert the argument of any type to a string.
Definition: types.hpp:510
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:162
Slice (= view) for STL containers.
Definition: slice.hpp:522