1
// ***************************************************************** -*- C++ -*-
3
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
5
* This program is part of the Exiv2 distribution.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
@brief Iptc dataSet and type information
25
@author Brad Schick (brad) <brad@robotbattle.com>
26
@date 24-Jul-04, brad: created
31
// *****************************************************************************
32
// included header files
34
#include "metadatum.hpp"
36
// + standard includes
38
#include <utility> // for std::pair
42
// *****************************************************************************
43
// namespace extensions
46
// *****************************************************************************
49
//! Contains information about one record
52
RecordInfo(uint16_t recordId, const char* name, const char* desc);
53
uint16_t recordId_; //!< Record id
54
const char* name_; //!< Record name (one word)
55
const char* desc_; //!< Record description
58
//! Dataset information
73
uint16_t number_; //!< Dataset number
74
const char* name_; //!< Dataset name
75
const char* desc_; //!< Dataset description
76
bool mandatory_; //!< True if dataset is mandatory
77
bool repeatable_; //!< True if dataset is repeatable
78
uint32_t minbytes_; //!< Minimum number of bytes
79
uint32_t maxbytes_; //!< Maximum number of bytes
80
TypeId type_; //!< Exiv2 default type
81
uint16_t recordId_; //!< Record id
82
const char* photoshop_; //!< Photoshop string
85
//! Container for Iptc dataset information. Implemented as a static class.
89
@name Record identifiers
90
@brief Record identifiers to logically group dataSets. There are other
91
possible record types, but they are not standardized by the Iptc
92
IIM4 standard (and not commonly used in images).
95
static const uint16_t invalidRecord = 0;
96
static const uint16_t envelope = 1;
97
static const uint16_t application2 = 2;
100
//! @name Dataset identifiers
102
static const uint16_t ModelVersion = 0;
103
static const uint16_t Destination = 5;
104
static const uint16_t FileFormat = 20;
105
static const uint16_t FileVersion = 22;
106
static const uint16_t ServiceId = 30;
107
static const uint16_t EnvelopeNumber = 40;
108
static const uint16_t ProductId = 50;
109
static const uint16_t EnvelopePriority = 60;
110
static const uint16_t DateSent = 70;
111
static const uint16_t TimeSent = 80;
112
static const uint16_t CharacterSet = 90;
113
static const uint16_t UNO = 100;
114
static const uint16_t ARMId = 120;
115
static const uint16_t ARMVersion = 122;
116
static const uint16_t RecordVersion = 0;
117
static const uint16_t ObjectType = 3;
118
static const uint16_t ObjectAttribute = 4;
119
static const uint16_t ObjectName = 5;
120
static const uint16_t EditStatus = 7;
121
static const uint16_t EditorialUpdate = 8;
122
static const uint16_t Urgency = 10;
123
static const uint16_t Subject = 12;
124
static const uint16_t Category = 15;
125
static const uint16_t SuppCategory = 20;
126
static const uint16_t FixtureId = 22;
127
static const uint16_t Keywords = 25;
128
static const uint16_t LocationCode = 26;
129
static const uint16_t LocationName = 27;
130
static const uint16_t ReleaseDate = 30;
131
static const uint16_t ReleaseTime = 35;
132
static const uint16_t ExpirationDate = 37;
133
static const uint16_t ExpirationTime = 38;
134
static const uint16_t SpecialInstructions = 40;
135
static const uint16_t ActionAdvised = 42;
136
static const uint16_t ReferenceService = 45;
137
static const uint16_t ReferenceDate = 47;
138
static const uint16_t ReferenceNumber = 50;
139
static const uint16_t DateCreated = 55;
140
static const uint16_t TimeCreated = 60;
141
static const uint16_t DigitizationDate = 62;
142
static const uint16_t DigitizationTime = 63;
143
static const uint16_t Program = 65;
144
static const uint16_t ProgramVersion = 70;
145
static const uint16_t ObjectCycle = 75;
146
static const uint16_t Byline = 80;
147
static const uint16_t BylineTitle = 85;
148
static const uint16_t City = 90;
149
static const uint16_t SubLocation = 92;
150
static const uint16_t ProvinceState = 95;
151
static const uint16_t CountryCode = 100;
152
static const uint16_t CountryName = 101;
153
static const uint16_t TransmissionReference = 103;
154
static const uint16_t Headline = 105;
155
static const uint16_t Credit = 110;
156
static const uint16_t Source = 115;
157
static const uint16_t Copyright = 116;
158
static const uint16_t Contact = 118;
159
static const uint16_t Caption = 120;
160
static const uint16_t Writer = 122;
161
static const uint16_t RasterizedCaption = 125;
162
static const uint16_t ImageType = 130;
163
static const uint16_t ImageOrientation = 131;
164
static const uint16_t Language = 135;
165
static const uint16_t AudioType = 150;
166
static const uint16_t AudioRate = 151;
167
static const uint16_t AudioResolution = 152;
168
static const uint16_t AudioDuration = 153;
169
static const uint16_t AudioOutcue = 154;
170
static const uint16_t PreviewFormat = 200;
171
static const uint16_t PreviewVersion = 201;
172
static const uint16_t Preview = 202;
176
//! Prevent construction: not implemented.
178
//! Prevent copy-construction: not implemented.
179
IptcDataSets(const IptcDataSets& rhs);
180
//! Prevent assignment: not implemented.
181
IptcDataSets& operator=(const IptcDataSets& rhs);
185
@brief Return the name of the dataset.
186
@param number The dataset number
187
@param recordId The Iptc record Id
188
@return The name of the dataset or a string containing the hexadecimal
189
value of the dataset in the form "0x01ff", if this is an unknown
192
static std::string dataSetName(uint16_t number, uint16_t recordId);
194
@brief Return the description of the dataset.
195
@param number The dataset number
196
@param recordId The Iptc record Id
197
@return The description of the dataset
199
static const char* dataSetDesc(uint16_t number, uint16_t recordId);
201
@brief Return the photohsop name of a given dataset.
202
@param number The dataset number
203
@param recordId The Iptc record Id
204
@return The name used by photoshop for a dataset or an empty
205
string if photoshop does not use the dataset.
207
static const char* dataSetPsName(uint16_t number, uint16_t recordId);
209
@brief Check if a given dataset is repeatable
210
@param number The dataset number
211
@param recordId The Iptc record Id
212
@return true if the given dataset is repeatable otherwise false
214
static bool dataSetRepeatable(uint16_t number, uint16_t recordId);
216
@brief Return the dataSet number for dataset name and record id
218
@param dataSetName dataSet name
219
@param recordId recordId
221
@return dataSet number
223
@throw Error if the \em dataSetName or \em recordId are invalid
225
static uint16_t dataSet(const std::string& dataSetName, uint16_t recordId);
226
//! Return the type for dataSet number and Record id
227
static TypeId dataSetType(uint16_t number, uint16_t recordId);
229
@brief Return the name of the Record
230
@param recordId The record id
231
@return The name of the record or a string containing the hexadecimal
232
value of the record in the form "0x01ff", if this is an
235
static std::string recordName(uint16_t recordId);
237
@brief Return the description of a record
238
@param recordId Record Id number
239
@return the description of the Record
241
static const char* recordDesc(uint16_t recordId);
243
@brief Return the Id number of a record
244
@param recordName Name of a record type
245
@return the Id number of a Record
246
@throw Error if the record is not known;
248
static uint16_t recordId(const std::string& recordName);
249
//! Print a list of all dataSets to output stream
250
static void dataSetList(std::ostream& os);
253
static int dataSetIdx(uint16_t number, uint16_t recordId);
254
static int dataSetIdx(const std::string& dataSetName, uint16_t recordId);
256
static const DataSet* records_[];
257
static const RecordInfo recordInfo_[];
259
}; // class IptcDataSets
262
@brief Concrete keys for Iptc metadata.
264
class IptcKey : public Key {
266
//! Shortcut for an %IptcKey auto pointer.
267
typedef std::auto_ptr<IptcKey> AutoPtr;
272
@brief Constructor to create an Iptc key from a key string.
274
@param key The key string.
275
@throw Error if the first part of the key is not '<b>Iptc</b>' or
276
the remaining parts of the key cannot be parsed and
277
converted to a record name and a dataset name.
279
explicit IptcKey(const std::string& key);
281
@brief Constructor to create an Iptc key from dataset and record ids.
282
@param tag Dataset id
283
@param record Record id
285
IptcKey(uint16_t tag, uint16_t record);
287
IptcKey(const IptcKey& rhs);
290
//! @name Manipulators
293
@brief Assignment operator.
295
IptcKey& operator=(const IptcKey& rhs);
300
virtual std::string key() const { return key_; }
301
virtual const char* familyName() const { return familyName_; }
303
@brief Return the name of the group (the second part of the key).
304
For Iptc keys, the group name is the record name.
306
virtual std::string groupName() const { return recordName(); }
307
virtual std::string tagName() const
308
{ return IptcDataSets::dataSetName(tag_, record_); }
309
virtual uint16_t tag() const { return tag_; }
311
AutoPtr clone() const;
312
//! Return the name of the record
313
std::string recordName() const
314
{ return IptcDataSets::recordName(record_); }
315
//! Return the record id
316
uint16_t record() const { return record_; }
320
//! @name Manipulators
323
@brief Set the key corresponding to the dataset and record id.
324
The key is of the form '<b>Iptc</b>.recordName.dataSetName'.
328
@brief Parse and convert the key string into dataset and record id.
329
Updates data members if the string can be decomposed, or throws
332
@throw Error if the key cannot be decomposed.
338
//! Internal virtual copy constructor.
339
virtual IptcKey* clone_() const;
342
static const char* familyName_;
344
uint16_t tag_; //!< Tag value
345
uint16_t record_; //!< Record value
346
std::string key_; //!< Key
350
// *****************************************************************************
353
//! Output operator for dataSet
354
std::ostream& operator<<(std::ostream& os, const DataSet& dataSet);
358
#endif // #ifndef DATASETS_HPP_