File indexing completed on 2025-01-19 03:55:03

0001 /*****************************************************************************/
0002 // Copyright 2006-2019 Adobe Systems Incorporated
0003 // All Rights Reserved.
0004 //
0005 // NOTICE:  Adobe permits you to use, modify, and distribute this file in
0006 // accordance with the terms of the Adobe license agreement accompanying it.
0007 /*****************************************************************************/
0008 
0009 /** \file
0010  * Support for IPTC metadata within DNG files.
0011  */
0012 
0013 /*****************************************************************************/
0014 
0015 #ifndef __dng_iptc__
0016 #define __dng_iptc__
0017 
0018 /*****************************************************************************/
0019 
0020 #include "dng_date_time.h"
0021 #include "dng_string.h"
0022 #include "dng_string_list.h"
0023 
0024 /*****************************************************************************/
0025 
0026 /// \brief Class for reading and holding IPTC metadata associated with a DNG file.
0027 ///
0028 /// See the \ref spec_iptc "IPTC specification"
0029 /// for information on member fields of this class.
0030 
0031 class dng_iptc
0032     {
0033 
0034     public:
0035 
0036         dng_string fTitle;
0037 
0038         int32 fUrgency;
0039 
0040         dng_string fCategory;
0041 
0042         dng_string_list fSupplementalCategories;
0043 
0044         dng_string_list fKeywords;
0045 
0046         dng_string fInstructions;
0047 
0048         dng_date_time_info fDateTimeCreated;
0049 
0050         dng_date_time_info fDigitalCreationDateTime;
0051 
0052         dng_string_list fAuthors;
0053 
0054         dng_string fAuthorsPosition;
0055 
0056         dng_string fCity;
0057         dng_string fState;
0058         dng_string fCountry;
0059         dng_string fCountryCode;
0060 
0061         dng_string fLocation;
0062 
0063         dng_string fTransmissionReference;
0064 
0065         dng_string fHeadline;
0066 
0067         dng_string fCredit;
0068 
0069         dng_string fSource;
0070 
0071         dng_string fCopyrightNotice;
0072 
0073         dng_string fDescription;
0074         dng_string fDescriptionWriter;
0075 
0076     protected:
0077 
0078         enum DataSet
0079             {
0080             kRecordVersionSet                   = 0,
0081             kObjectNameSet                      = 5,
0082             kUrgencySet                         = 10,
0083             kCategorySet                        = 15,
0084             kSupplementalCategoriesSet          = 20,
0085             kKeywordsSet                        = 25,
0086             kSpecialInstructionsSet             = 40,
0087             kDateCreatedSet                     = 55,
0088             kTimeCreatedSet                     = 60,
0089             kDigitalCreationDateSet             = 62,
0090             kDigitalCreationTimeSet             = 63,
0091             kBylineSet                          = 80,
0092             kBylineTitleSet                     = 85,
0093             kCitySet                            = 90,
0094             kSublocationSet                     = 92,
0095             kProvinceStateSet                   = 95,
0096             kCountryCodeSet                     = 100,
0097             kCountryNameSet                     = 101,
0098             kOriginalTransmissionReferenceSet   = 103,
0099             kHeadlineSet                        = 105,
0100             kCreditSet                          = 110,
0101             kSourceSet                          = 115,
0102             kCopyrightNoticeSet                 = 116,
0103             kCaptionSet                         = 120,
0104             kCaptionWriterSet                   = 122
0105             };
0106 
0107         enum CharSet
0108             {
0109             kCharSetUnknown                     = 0,
0110             kCharSetUTF8                        = 1
0111             };
0112 
0113     public:
0114 
0115         dng_iptc ();
0116 
0117         virtual ~dng_iptc ();
0118 
0119         /// Test if IPTC metadata exists.
0120         /// \retval true if no IPTC metadata exists for this DNG.
0121 
0122         bool IsEmpty () const;
0123 
0124         /// Test if IPTC metadata exists.
0125         /// \retval true if IPTC metadata exists for this DNG.
0126 
0127         bool NotEmpty () const
0128             {
0129             return !IsEmpty ();
0130             }
0131 
0132         /// Parse a complete block of IPTC data.
0133         /// \param blockData The block of IPTC data.
0134         /// \param blockSize Size in bytes of data block.
0135         /// \param offsetInOriginalFile Used to enable certain file patching operations such as updating date/time in place.
0136 
0137         void Parse (const void *blockData,
0138                     uint32 blockSize,
0139                     uint64 offsetInOriginalFile);
0140 
0141         /// Serialize IPTC data to a memory block.
0142         /// \param allocator Memory allocator used to acquire memory block.
0143         /// \param padForTIFF Forces length of block to be a multiple of four bytes in accordance with TIFF standard.
0144         /// \retval Memory block
0145 
0146         dng_memory_block * Spool (dng_memory_allocator &allocator,
0147                                   bool padForTIFF);
0148 
0149     protected:
0150 
0151         void ParseString (dng_stream &stream,
0152                           dng_string &s,
0153                           CharSet charSet);
0154 
0155         void SpoolString (dng_stream &stream,
0156                           const dng_string &s,
0157                           uint8 dataSet,
0158                           uint32 maxChars,
0159                           CharSet charSet);
0160 
0161     };
0162 
0163 /*****************************************************************************/
0164 
0165 #endif
0166 
0167 /*****************************************************************************/