1 /*****************************************************************************/ 2 // Copyright 2006-2012 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_xmp_sdk.h#2 $ */ 10 /* $DateTime: 2012/05/31 09:29:29 $ */ 11 /* $Change: 832505 $ */ 12 /* $Author: tknoll $ */ 13 14 /*****************************************************************************/ 15 16 #ifndef __dng_xmp_sdk__ 17 #define __dng_xmp_sdk__ 18 19 /*****************************************************************************/ 20 21 #include "dng_auto_ptr.h" 22 #include "dng_classes.h" 23 #include "dng_flags.h" 24 #include "dng_types.h" 25 26 #if qDNGUseXMP 27 28 /*****************************************************************************/ 29 30 extern const char *XMP_NS_TIFF; 31 extern const char *XMP_NS_EXIF; 32 extern const char *XMP_NS_PHOTOSHOP; 33 extern const char *XMP_NS_XAP; 34 extern const char *XMP_NS_XAP_RIGHTS; 35 extern const char *XMP_NS_DC; 36 extern const char *XMP_NS_XMP_NOTE; 37 extern const char *XMP_NS_MM; 38 39 extern const char *XMP_NS_CRS; 40 extern const char *XMP_NS_CRSS; 41 42 extern const char *XMP_NS_LCP; 43 44 extern const char *XMP_NS_AUX; 45 46 extern const char *XMP_NS_IPTC; 47 extern const char *XMP_NS_IPTC_EXT; 48 49 extern const char *XMP_NS_CRX; 50 51 extern const char *XMP_NS_DNG; 52 53 /*****************************************************************************/ 54 55 class dng_xmp_private; 56 57 /*****************************************************************************/ 58 59 typedef bool (IteratePathsCallback) (const char *ns, 60 const char *path, 61 void *callbackData); 62 63 /*****************************************************************************/ 64 65 struct dng_xmp_namespace 66 { 67 const char * fullName; 68 const char * shortName; 69 }; 70 71 /*****************************************************************************/ 72 73 class dng_xmp_sdk 74 { 75 76 private: 77 78 dng_xmp_private *fPrivate; 79 80 public: 81 82 dng_xmp_sdk (); 83 84 dng_xmp_sdk (const dng_xmp_sdk &sdk); 85 86 virtual ~dng_xmp_sdk (); 87 88 static void InitializeSDK (dng_xmp_namespace * extraNamespaces = NULL, 89 const char *software = NULL); 90 91 static void TerminateSDK (); 92 93 bool HasMeta () const; 94 95 void * GetPrivateMeta (); 96 97 void Parse (dng_host &host, 98 const char *buffer, 99 uint32 count); 100 101 bool Exists (const char *ns, 102 const char *path) const; 103 104 void AppendArrayItem (const char *ns, 105 const char *arrayName, 106 const char *itemValue, 107 bool isBag = true, 108 bool propIsStruct = false); 109 110 int32 CountArrayItems (const char *ns, 111 const char *path) const; 112 113 bool HasNameSpace (const char *ns) const; 114 115 void Remove (const char *ns, 116 const char *path); 117 118 void RemoveProperties (const char *ns); 119 120 bool IsEmptyString (const char *ns, 121 const char *path); 122 123 bool IsEmptyArray (const char *ns, 124 const char *path); 125 126 void ComposeArrayItemPath (const char *ns, 127 const char *arrayName, 128 int32 itemNumber, 129 dng_string &s) const; 130 131 void ComposeStructFieldPath (const char *ns, 132 const char *structName, 133 const char *fieldNS, 134 const char *fieldName, 135 dng_string &s) const; 136 137 bool GetNamespacePrefix (const char *uri, 138 dng_string &s) const; 139 140 bool GetString (const char *ns, 141 const char *path, 142 dng_string &s) const; 143 144 void ValidateStringList (const char *ns, 145 const char *path); 146 147 bool GetStringList (const char *ns, 148 const char *path, 149 dng_string_list &list) const; 150 151 bool GetAltLangDefault (const char *ns, 152 const char *path, 153 dng_string &s) const; 154 155 bool GetStructField (const char *ns, 156 const char *path, 157 const char *fieldNS, 158 const char *fieldName, 159 dng_string &s) const; 160 161 void Set (const char *ns, 162 const char *path, 163 const char *text); 164 165 void SetString (const char *ns, 166 const char *path, 167 const dng_string &s); 168 169 void SetStringList (const char *ns, 170 const char *path, 171 const dng_string_list &list, 172 bool isBag); 173 174 void SetAltLangDefault (const char *ns, 175 const char *path, 176 const dng_string &s); 177 178 void SetStructField (const char *ns, 179 const char *path, 180 const char *fieldNS, 181 const char *fieldName, 182 const char *text); 183 184 void DeleteStructField (const char *ns, 185 const char *structName, 186 const char *fieldNS, 187 const char *fieldName); 188 189 dng_memory_block * Serialize (dng_memory_allocator &allocator, 190 bool asPacket, 191 uint32 targetBytes, 192 uint32 padBytes, 193 bool forJPEG, 194 bool compact) const; 195 196 void PackageForJPEG (dng_memory_allocator &allocator, 197 AutoPtr<dng_memory_block> &stdBlock, 198 AutoPtr<dng_memory_block> &extBlock, 199 dng_string &extDigest) const; 200 201 void MergeFromJPEG (const dng_xmp_sdk *xmp); 202 203 void ReplaceXMP (dng_xmp_sdk *xmp); 204 205 bool IteratePaths (IteratePathsCallback *callback, 206 void *callbackData = NULL, 207 const char *startNS = 0, 208 const char *startingPath = 0); 209 210 #if qDNGXMPDocOps 211 212 void DocOpsOpenXMP (const char *srcMIMI); 213 214 void DocOpsPrepareForSave (const char *srcMIMI, 215 const char *dstMIMI, 216 bool newPath = true); 217 218 void DocOpsUpdateMetadata (const char *srcMIMI); 219 220 #endif 221 222 private: 223 224 void ClearMeta (); 225 226 void MakeMeta (); 227 228 void NeedMeta (); 229 230 // Hidden assignment operator. 231 232 dng_xmp_sdk & operator= (const dng_xmp_sdk &sdk); 233 234 }; 235 236 #endif 237 /*****************************************************************************/ 238 239 #endif 240 241 /*****************************************************************************/ 242