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