Exiv2
Loading...
Searching...
No Matches
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,
66 const Value* pValue =0);
68 Iptcdatum(const Iptcdatum& rhs);
70 virtual ~Iptcdatum();
72
74
75
76 Iptcdatum& operator=(const Iptcdatum& rhs);
81 Iptcdatum& operator=(const uint16_t& value);
86 Iptcdatum& operator=(const std::string& value);
92 void setValue(const Value* pValue);
101 int setValue(const std::string& value);
103
105
106 long copy(byte* buf, ByteOrder byteOrder) const;
107 std::ostream& write(std::ostream& os, const ExifData* pMetadata =0) const;
114 std::string key() const;
119 std::string recordName() const;
124 uint16_t record() const;
125 const char* familyName() const;
126 std::string groupName() const;
131 std::string tagName() const;
132 std::string tagLabel() const;
134 uint16_t tag() const;
135 TypeId typeId() const;
136 const char* typeName() const;
137 long typeSize() const;
138 long count() const;
139 long size() const;
140 std::string toString() const;
141 std::string toString(long n) const;
142 long toLong(long n =0) const;
143 float toFloat(long n =0) const;
144 Rational toRational(long n =0) const;
145 Value::AutoPtr getValue() const;
146 const Value& value() const;
148
149 private:
150 // DATA
151 IptcKey::AutoPtr key_;
152 Value::AutoPtr value_;
153
154 }; // class Iptcdatum
155
157 typedef std::vector<Iptcdatum> IptcMetadata;
158
170 class EXIV2API IptcData {
171 public:
173 typedef IptcMetadata::iterator iterator;
175 typedef IptcMetadata::const_iterator const_iterator;
176
177 // Use the compiler generated constructors and assignment operator
178
180
181
189 Iptcdatum& operator[](const std::string& key);
197 int add(const IptcKey& key, Value* value);
204 int add(const Iptcdatum& iptcdatum);
215 void clear() { iptcMetadata_.clear(); }
217 void sortByKey();
219 void sortByTag();
221 iterator begin() { return iptcMetadata_.begin(); }
223 iterator end() { return iptcMetadata_.end(); }
228 iterator findKey(const IptcKey& key);
233 iterator findId(uint16_t dataset,
234 uint16_t record = IptcDataSets::application2);
236
238
239
240 const_iterator begin() const { return iptcMetadata_.begin(); }
242 const_iterator end() const { return iptcMetadata_.end(); }
247 const_iterator findKey(const IptcKey& key) const;
252 const_iterator findId(uint16_t dataset,
253 uint16_t record = IptcDataSets::application2) const;
255 bool empty() const { return count() == 0; }
257 long count() const { return static_cast<long>(iptcMetadata_.size()); }
261 long size() const;
265 const char *detectCharset() const;
269 static void printStructure(std::ostream& out, const Slice<byte*>& bytes,uint32_t depth);
271
272 private:
273 // DATA
274 IptcMetadata iptcMetadata_;
275 }; // class IptcData
276
281 class EXIV2API IptcParser {
282 public:
294 static int decode(
295 IptcData& iptcData,
296 const byte* pData,
297 uint32_t size
298 );
308 static DataBuf encode(
309 const IptcData& iptcData
310 );
311
312 private:
313 // Constant data
314 static const byte marker_; // Dataset marker
315
316 }; // class IptcParser
317
318} // namespace Exiv2
319
320#endif // #ifndef IPTC_HPP_
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:193
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:170
iterator begin()
Begin of the metadata.
Definition iptc.hpp:221
IptcMetadata::iterator iterator
IptcMetadata iterator type.
Definition iptc.hpp:173
const_iterator begin() const
Begin of the metadata.
Definition iptc.hpp:240
bool empty() const
Return true if there is no IPTC metadata.
Definition iptc.hpp:255
iterator erase(iterator pos)
Delete the Iptcdatum at iterator position pos, return the position of the next Iptcdatum....
Definition iptc.cpp:342
const_iterator end() const
End of the metadata.
Definition iptc.hpp:242
iterator end()
End of the metadata.
Definition iptc.hpp:223
IptcMetadata::const_iterator const_iterator
IptcMetadata const iterator type.
Definition iptc.hpp:175
int add(const IptcKey &key, Value *value)
Add an Iptcdatum from the supplied key and value pair. This method copies (clones) the value....
Definition iptc.cpp:291
long count() const
Get the number of metadata entries.
Definition iptc.hpp:257
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:262
void clear()
Delete all Iptcdatum instances resulting in an empty container.
Definition iptc.hpp:215
Concrete keys for IPTC metadata.
Definition datasets.hpp:275
std::auto_ptr< IptcKey > AutoPtr
Shortcut for an IptcKey auto pointer.
Definition datasets.hpp:278
Stateless parser class for IPTC data. Images use this class to decode and encode binary IPTC data.
Definition iptc.hpp:281
static int decode(IptcData &iptcData, const byte *pData, uint32_t size)
Decode binary IPTC data in IPTC IIM4 format from a buffer pData of length size to the provided metada...
Definition iptc.cpp:433
static DataBuf encode(const IptcData &iptcData)
Encode the IPTC datasets from iptcData to a binary representation in IPTC IIM4 format.
Definition iptc.cpp:510
An IPTC metadatum ("dataset"), consisting of an IptcKey and a Value and methods to manipulate these.
Definition iptc.hpp:49
std::ostream & write(std::ostream &os, const ExifData *pMetadata=0) const
Write the interpreted value to an output stream, return the stream.
Definition iptc.cpp:107
uint16_t tag() const
Return the tag (aka dataset) number.
Definition iptc.cpp:147
std::string recordName() const
Return the name of the record (deprecated).
Definition iptc.cpp:117
TypeId typeId() const
Return the type id of the value.
Definition iptc.cpp:152
std::string tagLabel() const
Return a label for the tag.
Definition iptc.cpp:142
long toLong(long n=0) const
Return the n-th component of the value converted to long. The return value is -1 if the value is not ...
Definition iptc.cpp:187
uint16_t record() const
Return the record id.
Definition iptc.cpp:122
Value::AutoPtr getValue() const
Return an auto-pointer to a copy (clone) of the value. The caller owns this copy and the auto-poiner ...
Definition iptc.cpp:202
long count() const
Return the number of components in the value.
Definition iptc.cpp:167
const char * familyName() const
Return the name of the metadata family (which is also the first part of the key).
Definition iptc.cpp:127
std::string tagName() const
Return the name of the tag (aka dataset).
Definition iptc.cpp:137
std::string toString() const
Return the value as a string.
Definition iptc.cpp:177
Iptcdatum & operator=(const Iptcdatum &rhs)
Assignment operator.
Definition iptc.cpp:213
const Value & value() const
Return a constant reference to the value.
Definition iptc.cpp:207
std::string groupName() const
Return the name of the metadata group (which is also the second part of the key).
Definition iptc.cpp:132
Rational toRational(long n=0) const
Return the n-th component of the value converted to Rational. The return value is -1/1 if the value i...
Definition iptc.cpp:197
long copy(byte *buf, ByteOrder byteOrder) const
Write value to a data buffer and return the number of bytes written.
Definition iptc.cpp:102
std::string key() const
Return the key of the Iptcdatum. The key is of the form 'Iptc.recordName.datasetName'....
Definition iptc.cpp:112
void setValue(const Value *pValue)
Set the value. This method copies (clones) the value pointed to by pValue.
Definition iptc.cpp:247
long typeSize() const
Return the size in bytes of one component of this type.
Definition iptc.cpp:162
float toFloat(long n=0) const
Return the n-th component of the value converted to float. The return value is -1 if the value is not...
Definition iptc.cpp:192
Iptcdatum(const IptcKey &key, const Value *pValue=0)
Constructor for new tags created by an application. The Iptcdatum is created from a key / value pair....
Definition iptc.cpp:84
long size() const
Return the size of the value in bytes.
Definition iptc.cpp:172
const char * typeName() const
Return the name of the type.
Definition iptc.cpp:157
Metadatum()
Default Constructor.
Definition metadatum.cpp:47
Common interface for all types of values used with metadata.
Definition value.hpp:51
std::auto_ptr< Value > AutoPtr
Shortcut for a Value auto pointer.
Definition value.hpp:54
IPTC dataset and type information.
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition asfvideo.hpp:36
TypeId
Exiv2 value type identifiers.
Definition types.hpp:119
std::vector< Iptcdatum > IptcMetadata
Container type to hold all metadata.
Definition iptc.hpp:157
ByteOrder
Type to express the byte order (little or big endian).
Definition types.hpp:102
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition types.hpp:99
Slice (= view) for STL containers.
Definition slice.hpp:522