| 1 |
/*****************************************************************************/ |
| 2 |
// Copyright 2006-2019 Adobe Systems Incorporated |
| 3 |
// All Rights Reserved. |
| 4 |
// |
| 5 |
// NOTICE: Adobe permits you to use, modify, and distribute this file in |
| 6 |
// accordance with the terms of the Adobe license agreement accompanying it. |
| 7 |
/*****************************************************************************/ |
| 8 |
|
| 9 |
/** \file |
| 10 |
* Support for IPTC metadata within DNG files. |
| 11 |
*/ |
| 12 |
|
| 13 |
/*****************************************************************************/ |
| 14 |
|
| 15 |
#ifndef __dng_iptc__ |
| 16 |
#define __dng_iptc__ |
| 17 |
|
| 18 |
/*****************************************************************************/ |
| 19 |
|
| 20 |
#include "dng_date_time.h" |
| 21 |
#include "dng_string.h" |
| 22 |
#include "dng_string_list.h" |
| 23 |
|
| 24 |
/*****************************************************************************/ |
| 25 |
|
| 26 |
/// @brief Class for reading and holding IPTC metadata associated with a DNG file. |
| 27 |
/// |
| 28 |
/// See the \ref spec_iptc "IPTC specification" |
| 29 |
/// for information on member fields of this class. |
| 30 |
|
| 31 |
class dng_iptc |
| 32 |
{ |
| 33 |
|
| 34 |
public: |
| 35 |
|
| 36 |
dng_string fTitle; |
| 37 |
|
| 38 |
int32 fUrgency; |
| 39 |
|
| 40 |
dng_string fCategory; |
| 41 |
|
| 42 |
dng_string_list fSupplementalCategories; |
| 43 |
|
| 44 |
dng_string_list fKeywords; |
| 45 |
|
| 46 |
dng_string fInstructions; |
| 47 |
|
| 48 |
dng_date_time_info fDateTimeCreated; |
| 49 |
|
| 50 |
dng_date_time_info fDigitalCreationDateTime; |
| 51 |
|
| 52 |
dng_string_list fAuthors; |
| 53 |
|
| 54 |
dng_string fAuthorsPosition; |
| 55 |
|
| 56 |
dng_string fCity; |
| 57 |
dng_string fState; |
| 58 |
dng_string fCountry; |
| 59 |
dng_string fCountryCode; |
| 60 |
|
| 61 |
dng_string fLocation; |
| 62 |
|
| 63 |
dng_string fTransmissionReference; |
| 64 |
|
| 65 |
dng_string fHeadline; |
| 66 |
|
| 67 |
dng_string fCredit; |
| 68 |
|
| 69 |
dng_string fSource; |
| 70 |
|
| 71 |
dng_string fCopyrightNotice; |
| 72 |
|
| 73 |
dng_string fDescription; |
| 74 |
dng_string fDescriptionWriter; |
| 75 |
|
| 76 |
protected: |
| 77 |
|
| 78 |
enum DataSet |
| 79 |
{ |
| 80 |
kRecordVersionSet = 0, |
| 81 |
kObjectNameSet = 5, |
| 82 |
kUrgencySet = 10, |
| 83 |
kCategorySet = 15, |
| 84 |
kSupplementalCategoriesSet = 20, |
| 85 |
kKeywordsSet = 25, |
| 86 |
kSpecialInstructionsSet = 40, |
| 87 |
kDateCreatedSet = 55, |
| 88 |
kTimeCreatedSet = 60, |
| 89 |
kDigitalCreationDateSet = 62, |
| 90 |
kDigitalCreationTimeSet = 63, |
| 91 |
kBylineSet = 80, |
| 92 |
kBylineTitleSet = 85, |
| 93 |
kCitySet = 90, |
| 94 |
kSublocationSet = 92, |
| 95 |
kProvinceStateSet = 95, |
| 96 |
kCountryCodeSet = 100, |
| 97 |
kCountryNameSet = 101, |
| 98 |
kOriginalTransmissionReferenceSet = 103, |
| 99 |
kHeadlineSet = 105, |
| 100 |
kCreditSet = 110, |
| 101 |
kSourceSet = 115, |
| 102 |
kCopyrightNoticeSet = 116, |
| 103 |
kCaptionSet = 120, |
| 104 |
kCaptionWriterSet = 122 |
| 105 |
}; |
| 106 |
|
| 107 |
enum CharSet |
| 108 |
{ |
| 109 |
kCharSetUnknown = 0, |
| 110 |
kCharSetUTF8 = 1 |
| 111 |
}; |
| 112 |
|
| 113 |
public: |
| 114 |
|
| 115 |
dng_iptc (); |
| 116 |
|
| 117 |
virtual ~dng_iptc (); |
| 118 |
|
| 119 |
/// Test if IPTC metadata exists. |
| 120 |
/// \retval true if no IPTC metadata exists for this DNG. |
| 121 |
|
| 122 |
bool IsEmpty () const; |
| 123 |
|
| 124 |
/// Test if IPTC metadata exists. |
| 125 |
/// \retval true if IPTC metadata exists for this DNG. |
| 126 |
|
| 127 |
bool NotEmpty () const |
| 128 |
{ |
| 129 |
return !IsEmpty (); |
| 130 |
} |
| 131 |
|
| 132 |
/// Parse a complete block of IPTC data. |
| 133 |
/// \param blockData The block of IPTC data. |
| 134 |
/// \param blockSize Size in bytes of data block. |
| 135 |
/// \param offsetInOriginalFile Used to enable certain file patching operations such as updating date/time in place. |
| 136 |
|
| 137 |
void Parse (const void *blockData, |
| 138 |
uint32 blockSize, |
| 139 |
uint64 offsetInOriginalFile); |
| 140 |
|
| 141 |
/// Serialize IPTC data to a memory block. |
| 142 |
/// \param allocator Memory allocator used to acquire memory block. |
| 143 |
/// \param padForTIFF Forces length of block to be a multiple of four bytes in accordance with TIFF standard. |
| 144 |
/// \retval Memory block |
| 145 |
|
| 146 |
dng_memory_block * Spool (dng_memory_allocator &allocator, |
| 147 |
bool padForTIFF); |
| 148 |
|
| 149 |
protected: |
| 150 |
|
| 151 |
void ParseString (dng_stream &stream, |
| 152 |
dng_string &s, |
| 153 |
CharSet charSet); |
| 154 |
|
| 155 |
void SpoolString (dng_stream &stream, |
| 156 |
const dng_string &s, |
| 157 |
uint8 dataSet, |
| 158 |
uint32 maxChars, |
| 159 |
CharSet charSet); |
| 160 |
|
| 161 |
}; |
| 162 |
|
| 163 |
/*****************************************************************************/ |
| 164 |
|
| 165 |
#endif |
| 166 |
|
| 167 |
/*****************************************************************************/ |