~ubuntu-branches/ubuntu/natty/libextractor/natty

« back to all changes in this revision

Viewing changes to src/plugins/exiv2/datasets.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-11-17 20:27:32 UTC
  • mfrom: (1.10.4 upstream) (5.2.5 sid)
  • Revision ID: james.westby@ubuntu.com-20091117202732-ipm2h3gks5bdw2vx
Tags: 0.5.23+dfsg-3
* Building against libltdl7.
* Updating to standards version 3.8.3.
* Adding maintainer homepage field to control.
* Marking maintainer homepage field to be also included in binary
  packages and changelog.
* Adding README.source.
* Simplifying autotools handling in rules.
* Updating README.source.
* Moving maintainer homepage field from control to copyright.
* Dropping la files.
* Simplyfing debhelper install files.
* Bumping versioned build-depends on debhelper.
* Adding depends to dpkg install info.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ***************************************************************** -*- C++ -*-
2
 
/*
3
 
 * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
4
 
 *
5
 
 * This program is part of the Exiv2 distribution.
6
 
 *
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.
11
 
 *
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.
16
 
 *
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.
20
 
 */
21
 
/*!
22
 
  @file    datasets.hpp
23
 
  @brief   Iptc dataSet and type information
24
 
  @version $Rev: 560 $
25
 
  @author  Brad Schick (brad) <brad@robotbattle.com>
26
 
  @date    24-Jul-04, brad: created
27
 
 */
28
 
#ifndef DATASETS_HPP_
29
 
#define DATASETS_HPP_
30
 
 
31
 
// *****************************************************************************
32
 
// included header files
33
 
#include "types.hpp"
34
 
#include "metadatum.hpp"
35
 
 
36
 
// + standard includes
37
 
#include <string>
38
 
#include <utility>                              // for std::pair
39
 
#include <iosfwd>
40
 
#include <memory>
41
 
 
42
 
// *****************************************************************************
43
 
// namespace extensions
44
 
namespace Exiv2 {
45
 
 
46
 
// *****************************************************************************
47
 
// class definitions
48
 
 
49
 
    //! Contains information about one record
50
 
    struct RecordInfo {
51
 
        //! Constructor
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
56
 
    };
57
 
 
58
 
    //! Dataset information
59
 
    struct DataSet {
60
 
        //! Constructor
61
 
        DataSet(
62
 
            uint16_t number,
63
 
            const char* name,
64
 
            const char* desc,
65
 
            bool mandatory,
66
 
            bool repeatable,
67
 
            uint32_t minbytes,
68
 
            uint32_t maxbytes,
69
 
            TypeId type,
70
 
            uint16_t recordId,
71
 
            const char* photoshop
72
 
        );
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
83
 
    }; // struct DataSet
84
 
 
85
 
    //! Container for Iptc dataset information. Implemented as a static class.
86
 
    class IptcDataSets {
87
 
    public:
88
 
        /*!
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).
93
 
         */
94
 
        //@{
95
 
        static const uint16_t invalidRecord = 0;
96
 
        static const uint16_t envelope = 1;
97
 
        static const uint16_t application2 = 2;
98
 
        //@}
99
 
 
100
 
        //! @name Dataset identifiers
101
 
        //@{
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;
173
 
        //@}
174
 
 
175
 
    private:
176
 
        //! Prevent construction: not implemented.
177
 
        IptcDataSets() {}
178
 
        //! Prevent copy-construction: not implemented.
179
 
        IptcDataSets(const IptcDataSets& rhs);
180
 
        //! Prevent assignment: not implemented.
181
 
        IptcDataSets& operator=(const IptcDataSets& rhs);
182
 
 
183
 
    public:
184
 
        /*!
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
190
 
                  dataset.
191
 
         */
192
 
        static std::string dataSetName(uint16_t number, uint16_t recordId);
193
 
        /*!
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
198
 
         */
199
 
        static const char* dataSetDesc(uint16_t number, uint16_t recordId);
200
 
        /*!
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.
206
 
         */
207
 
        static const char* dataSetPsName(uint16_t number, uint16_t recordId);
208
 
        /*!
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
213
 
         */
214
 
        static bool dataSetRepeatable(uint16_t number, uint16_t recordId);
215
 
        /*!
216
 
          @brief Return the dataSet number for dataset name and record id
217
 
 
218
 
          @param dataSetName dataSet name
219
 
          @param recordId recordId
220
 
 
221
 
          @return dataSet number
222
 
 
223
 
          @throw Error if the \em dataSetName or \em recordId are invalid
224
 
         */
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);
228
 
        /*!
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
233
 
                  unknown record.
234
 
         */
235
 
        static std::string recordName(uint16_t recordId);
236
 
        /*!
237
 
           @brief Return the description of a record
238
 
           @param recordId Record Id number
239
 
           @return the description of the Record
240
 
         */
241
 
        static const char* recordDesc(uint16_t recordId);
242
 
        /*!
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;
247
 
         */
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);
251
 
 
252
 
    private:
253
 
        static int dataSetIdx(uint16_t number, uint16_t recordId);
254
 
        static int dataSetIdx(const std::string& dataSetName, uint16_t recordId);
255
 
 
256
 
        static const DataSet* records_[];
257
 
        static const RecordInfo recordInfo_[];
258
 
 
259
 
    }; // class IptcDataSets
260
 
 
261
 
    /*!
262
 
      @brief Concrete keys for Iptc metadata.
263
 
     */
264
 
    class IptcKey : public Key {
265
 
    public:
266
 
        //! Shortcut for an %IptcKey auto pointer.
267
 
        typedef std::auto_ptr<IptcKey> AutoPtr;
268
 
 
269
 
        //! @name Creators
270
 
        //@{
271
 
        /*!
272
 
          @brief Constructor to create an Iptc key from a key string.
273
 
 
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.
278
 
        */
279
 
        explicit IptcKey(const std::string& key);
280
 
        /*!
281
 
          @brief Constructor to create an Iptc key from dataset and record ids.
282
 
          @param tag Dataset id
283
 
          @param record Record id
284
 
         */
285
 
        IptcKey(uint16_t tag, uint16_t record);
286
 
        //! Copy constructor
287
 
        IptcKey(const IptcKey& rhs);
288
 
        //@}
289
 
 
290
 
        //! @name Manipulators
291
 
        //@{
292
 
        /*!
293
 
          @brief Assignment operator.
294
 
         */
295
 
        IptcKey& operator=(const IptcKey& rhs);
296
 
        //@}
297
 
 
298
 
        //! @name Accessors
299
 
        //@{
300
 
        virtual std::string key() const { return key_; }
301
 
        virtual const char* familyName() const { return familyName_; }
302
 
        /*!
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.
305
 
        */
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_; }
310
 
 
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_; }
317
 
        //@}
318
 
 
319
 
    protected:
320
 
        //! @name Manipulators
321
 
        //@{
322
 
        /*!
323
 
          @brief Set the key corresponding to the dataset and record id.
324
 
                 The key is of the form '<b>Iptc</b>.recordName.dataSetName'.
325
 
         */
326
 
        void makeKey();
327
 
        /*!
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
330
 
                 \em Error.
331
 
 
332
 
          @throw Error if the key cannot be decomposed.
333
 
         */
334
 
        void decomposeKey();
335
 
        //@}
336
 
 
337
 
    private:
338
 
        //! Internal virtual copy constructor.
339
 
        virtual IptcKey* clone_() const;
340
 
 
341
 
        // DATA
342
 
        static const char* familyName_;
343
 
 
344
 
        uint16_t tag_;                 //!< Tag value
345
 
        uint16_t record_;              //!< Record value
346
 
        std::string key_;              //!< Key
347
 
 
348
 
    }; // class IptcKey
349
 
 
350
 
// *****************************************************************************
351
 
// free functions
352
 
 
353
 
    //! Output operator for dataSet
354
 
    std::ostream& operator<<(std::ostream& os, const DataSet& dataSet);
355
 
 
356
 
}                                       // namespace Exiv2
357
 
 
358
 
#endif                                  // #ifndef DATASETS_HPP_