/src/exiv2/xmpsdk/src/XMPMeta.hpp
Line | Count | Source |
1 | | #ifndef __XMPMeta_hpp__ |
2 | | #define __XMPMeta_hpp__ |
3 | | |
4 | | // ================================================================================================= |
5 | | // Copyright 2002-2008 Adobe Systems Incorporated |
6 | | // All Rights Reserved. |
7 | | // |
8 | | // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms |
9 | | // of the Adobe license agreement accompanying it. |
10 | | // ================================================================================================= |
11 | | |
12 | | #include "XMP_Environment.h" |
13 | | #include "XMP_Const.h" |
14 | | #include "XMPCore_Impl.hpp" |
15 | | #include "XMLParserAdapter.hpp" |
16 | | |
17 | | // ------------------------------------------------------------------------------------------------- |
18 | | |
19 | | #ifndef DumpXMLParseTree |
20 | | #define DumpXMLParseTree 0 |
21 | | #endif |
22 | | |
23 | | extern XMP_VarString * xdefaultName; |
24 | | |
25 | | class XMPIterator; |
26 | | class XMPUtils; |
27 | | |
28 | | // ------------------------------------------------------------------------------------------------- |
29 | | |
30 | | class XMPMeta { |
31 | | public: |
32 | | |
33 | | static void |
34 | | GetVersionInfo ( XMP_VersionInfo * info ); |
35 | | |
36 | | static bool |
37 | | Initialize(); |
38 | | static void |
39 | | Terminate() RELEASE_NO_THROW; |
40 | | |
41 | | static void |
42 | | Unlock ( XMP_OptionBits options ); |
43 | | |
44 | | // --------------------------------------------------------------------------------------------- |
45 | | |
46 | | XMPMeta(); |
47 | | |
48 | | virtual ~XMPMeta() RELEASE_NO_THROW; |
49 | | |
50 | | // --------------------------------------------------------------------------------------------- |
51 | | |
52 | | static XMP_OptionBits |
53 | | GetGlobalOptions(); |
54 | | |
55 | | static void |
56 | | SetGlobalOptions ( XMP_OptionBits options ); |
57 | | |
58 | | // --------------------------------------------------------------------------------------------- |
59 | | |
60 | | static XMP_Status |
61 | | DumpNamespaces ( XMP_TextOutputProc outProc, |
62 | | void * refCon ); |
63 | | |
64 | | static XMP_Status |
65 | | DumpAliases ( XMP_TextOutputProc outProc, |
66 | | void * refCon ); |
67 | | |
68 | | // --------------------------------------------------------------------------------------------- |
69 | | |
70 | | static void |
71 | | RegisterNamespace ( XMP_StringPtr namespaceURI, |
72 | | XMP_StringPtr prefix ); |
73 | | |
74 | | static bool |
75 | | GetNamespacePrefix ( XMP_StringPtr namespaceURI, |
76 | | XMP_StringPtr * namespacePrefix, |
77 | | XMP_StringLen * prefixSize ); |
78 | | |
79 | | static bool |
80 | | GetNamespaceURI ( XMP_StringPtr namespacePrefix, |
81 | | XMP_StringPtr * namespaceURI, |
82 | | XMP_StringLen * uriSize ); |
83 | | |
84 | | static void |
85 | | DeleteNamespace ( XMP_StringPtr namespaceURI ); |
86 | | |
87 | | // --------------------------------------------------------------------------------------------- |
88 | | |
89 | | static void |
90 | | RegisterAlias ( XMP_StringPtr aliasNS, |
91 | | XMP_StringPtr aliasProp, |
92 | | XMP_StringPtr actualNS, |
93 | | XMP_StringPtr actualProp, |
94 | | XMP_OptionBits arrayForm ); |
95 | | |
96 | | static bool |
97 | | ResolveAlias ( XMP_StringPtr aliasNS, |
98 | | XMP_StringPtr aliasProp, |
99 | | XMP_StringPtr * actualNS, |
100 | | XMP_StringLen * nsSize, |
101 | | XMP_StringPtr * actualProp, |
102 | | XMP_StringLen * propSize, |
103 | | XMP_OptionBits * arrayForm ); |
104 | | |
105 | | static void |
106 | | DeleteAlias ( XMP_StringPtr aliasNS, |
107 | | XMP_StringPtr aliasProp ); |
108 | | |
109 | | static void |
110 | | RegisterStandardAliases ( XMP_StringPtr schemaNS ); |
111 | | |
112 | | // --------------------------------------------------------------------------------------------- |
113 | | |
114 | | void |
115 | | UnlockObject ( XMP_OptionBits options ) const; |
116 | | |
117 | | // --------------------------------------------------------------------------------------------- |
118 | | |
119 | | bool |
120 | | GetProperty ( XMP_StringPtr schemaNS, |
121 | | XMP_StringPtr propName, |
122 | | XMP_StringPtr * propValue, |
123 | | XMP_StringLen * valueSize, |
124 | | XMP_OptionBits * options ) const; |
125 | | |
126 | | bool |
127 | | GetArrayItem ( XMP_StringPtr schemaNS, |
128 | | XMP_StringPtr arrayName, |
129 | | XMP_Index itemIndex, |
130 | | XMP_StringPtr * itemValue, |
131 | | XMP_StringLen * valueSize, |
132 | | XMP_OptionBits * options ) const; |
133 | | |
134 | | bool |
135 | | GetStructField ( XMP_StringPtr schemaNS, |
136 | | XMP_StringPtr structName, |
137 | | XMP_StringPtr fieldNS, |
138 | | XMP_StringPtr fieldName, |
139 | | XMP_StringPtr * fieldValue, |
140 | | XMP_StringLen * valueSize, |
141 | | XMP_OptionBits * options ) const; |
142 | | |
143 | | bool |
144 | | GetQualifier ( XMP_StringPtr schemaNS, |
145 | | XMP_StringPtr propName, |
146 | | XMP_StringPtr qualNS, |
147 | | XMP_StringPtr qualName, |
148 | | XMP_StringPtr * qualValue, |
149 | | XMP_StringLen * valueSize, |
150 | | XMP_OptionBits * options ) const; |
151 | | |
152 | | // --------------------------------------------------------------------------------------------- |
153 | | |
154 | | void |
155 | | SetProperty ( XMP_StringPtr schemaNS, |
156 | | XMP_StringPtr propName, |
157 | | XMP_StringPtr propValue, |
158 | | XMP_OptionBits options ); |
159 | | |
160 | | void |
161 | | SetArrayItem ( XMP_StringPtr schemaNS, |
162 | | XMP_StringPtr arrayName, |
163 | | XMP_Index itemIndex, |
164 | | XMP_StringPtr itemValue, |
165 | | XMP_OptionBits options ); |
166 | | |
167 | | void |
168 | | AppendArrayItem ( XMP_StringPtr schemaNS, |
169 | | XMP_StringPtr arrayName, |
170 | | XMP_OptionBits arrayOptions, |
171 | | XMP_StringPtr itemValue, |
172 | | XMP_OptionBits options ); |
173 | | |
174 | | void |
175 | | SetStructField ( XMP_StringPtr schemaNS, |
176 | | XMP_StringPtr structName, |
177 | | XMP_StringPtr fieldNS, |
178 | | XMP_StringPtr fieldName, |
179 | | XMP_StringPtr fieldValue, |
180 | | XMP_OptionBits options ); |
181 | | |
182 | | void |
183 | | SetQualifier ( XMP_StringPtr schemaNS, |
184 | | XMP_StringPtr propName, |
185 | | XMP_StringPtr qualNS, |
186 | | XMP_StringPtr qualName, |
187 | | XMP_StringPtr qualValue, |
188 | | XMP_OptionBits options ); |
189 | | |
190 | | // --------------------------------------------------------------------------------------------- |
191 | | |
192 | | void |
193 | | DeleteProperty ( XMP_StringPtr schemaNS, |
194 | | XMP_StringPtr propName ); |
195 | | |
196 | | void |
197 | | DeleteArrayItem ( XMP_StringPtr schemaNS, |
198 | | XMP_StringPtr arrayName, |
199 | | XMP_Index itemIndex ); |
200 | | |
201 | | void |
202 | | DeleteStructField ( XMP_StringPtr schemaNS, |
203 | | XMP_StringPtr structName, |
204 | | XMP_StringPtr fieldNS, |
205 | | XMP_StringPtr fieldName ); |
206 | | |
207 | | void |
208 | | DeleteQualifier ( XMP_StringPtr schemaNS, |
209 | | XMP_StringPtr propName, |
210 | | XMP_StringPtr qualNS, |
211 | | XMP_StringPtr qualName ); |
212 | | |
213 | | // --------------------------------------------------------------------------------------------- |
214 | | |
215 | | bool |
216 | | DoesPropertyExist ( XMP_StringPtr schemaNS, |
217 | | XMP_StringPtr propName ) const; |
218 | | |
219 | | bool |
220 | | DoesArrayItemExist ( XMP_StringPtr schemaNS, |
221 | | XMP_StringPtr arrayName, |
222 | | XMP_Index itemIndex ) const; |
223 | | |
224 | | bool |
225 | | DoesStructFieldExist ( XMP_StringPtr schemaNS, |
226 | | XMP_StringPtr structName, |
227 | | XMP_StringPtr fieldNS, |
228 | | XMP_StringPtr fieldName ) const; |
229 | | |
230 | | bool |
231 | | DoesQualifierExist ( XMP_StringPtr schemaNS, |
232 | | XMP_StringPtr propName, |
233 | | XMP_StringPtr qualNS, |
234 | | XMP_StringPtr qualName ) const; |
235 | | |
236 | | // --------------------------------------------------------------------------------------------- |
237 | | |
238 | | bool |
239 | | GetLocalizedText ( XMP_StringPtr schemaNS, |
240 | | XMP_StringPtr altTextName, |
241 | | XMP_StringPtr genericLang, |
242 | | XMP_StringPtr specificLang, |
243 | | XMP_StringPtr * actualLang, |
244 | | XMP_StringLen * langSize, |
245 | | XMP_StringPtr * itemValue, |
246 | | XMP_StringLen * valueSize, |
247 | | XMP_OptionBits * options ) const; |
248 | | |
249 | | void |
250 | | SetLocalizedText ( XMP_StringPtr schemaNS, |
251 | | XMP_StringPtr altTextName, |
252 | | XMP_StringPtr genericLang, |
253 | | XMP_StringPtr specificLang, |
254 | | XMP_StringPtr itemValue, |
255 | | XMP_OptionBits options ); |
256 | | |
257 | | // --------------------------------------------------------------------------------------------- |
258 | | |
259 | | bool |
260 | | GetProperty_Bool ( XMP_StringPtr schemaNS, |
261 | | XMP_StringPtr propName, |
262 | | bool * propValue, |
263 | | XMP_OptionBits * options ) const; |
264 | | |
265 | | bool |
266 | | GetProperty_Int ( XMP_StringPtr schemaNS, |
267 | | XMP_StringPtr propName, |
268 | | XMP_Int32 * propValue, |
269 | | XMP_OptionBits * options ) const; |
270 | | |
271 | | bool |
272 | | GetProperty_Int64 ( XMP_StringPtr schemaNS, |
273 | | XMP_StringPtr propName, |
274 | | XMP_Int64 * propValue, |
275 | | XMP_OptionBits * options ) const; |
276 | | |
277 | | bool |
278 | | GetProperty_Float ( XMP_StringPtr schemaNS, |
279 | | XMP_StringPtr propName, |
280 | | double * propValue, |
281 | | XMP_OptionBits * options ) const; |
282 | | |
283 | | bool |
284 | | GetProperty_Date ( XMP_StringPtr schemaNS, |
285 | | XMP_StringPtr propName, |
286 | | XMP_DateTime * propValue, |
287 | | XMP_OptionBits * options ) const; |
288 | | |
289 | | // --------------------------------------------------------------------------------------------- |
290 | | |
291 | | void |
292 | | SetProperty_Bool ( XMP_StringPtr schemaNS, |
293 | | XMP_StringPtr propName, |
294 | | bool propValue, |
295 | | XMP_OptionBits options ); |
296 | | |
297 | | void |
298 | | SetProperty_Int ( XMP_StringPtr schemaNS, |
299 | | XMP_StringPtr propName, |
300 | | XMP_Int32 propValue, |
301 | | XMP_OptionBits options ); |
302 | | |
303 | | void |
304 | | SetProperty_Int64 ( XMP_StringPtr schemaNS, |
305 | | XMP_StringPtr propName, |
306 | | XMP_Int64 propValue, |
307 | | XMP_OptionBits options ); |
308 | | |
309 | | void |
310 | | SetProperty_Float ( XMP_StringPtr schemaNS, |
311 | | XMP_StringPtr propName, |
312 | | double propValue, |
313 | | XMP_OptionBits options ); |
314 | | |
315 | | void |
316 | | SetProperty_Date ( XMP_StringPtr schemaNS, |
317 | | XMP_StringPtr propName, |
318 | | const XMP_DateTime & propValue, |
319 | | XMP_OptionBits options ); |
320 | | |
321 | | // --------------------------------------------------------------------------------------------- |
322 | | |
323 | | void |
324 | | GetObjectName ( XMP_StringPtr * namePtr, |
325 | | XMP_StringLen * nameLen ) const; |
326 | | |
327 | | void |
328 | | SetObjectName ( XMP_StringPtr name ); |
329 | | |
330 | | XMP_OptionBits |
331 | | GetObjectOptions() const; |
332 | | |
333 | | void |
334 | | SetObjectOptions ( XMP_OptionBits options ); |
335 | | |
336 | | void |
337 | | Sort(); |
338 | | |
339 | | void |
340 | | Erase(); |
341 | | |
342 | | void |
343 | | Clone ( XMPMeta * clone, XMP_OptionBits options ) const; |
344 | | |
345 | | XMP_Index |
346 | | CountArrayItems ( XMP_StringPtr schemaNS, |
347 | | XMP_StringPtr arrayName ) const; |
348 | | |
349 | | XMP_Status |
350 | | DumpObject ( XMP_TextOutputProc outProc, |
351 | | void * refCon ) const; |
352 | | |
353 | | // --------------------------------------------------------------------------------------------- |
354 | | |
355 | | void |
356 | | ParseFromBuffer ( XMP_StringPtr buffer, |
357 | | XMP_StringLen bufferSize, |
358 | | XMP_OptionBits options ); |
359 | | |
360 | | void |
361 | | SerializeToBuffer ( XMP_StringPtr * rdfString, |
362 | | XMP_StringLen * rdfSize, |
363 | | XMP_OptionBits options, |
364 | | XMP_StringLen padding, |
365 | | XMP_StringPtr newline, |
366 | | XMP_StringPtr indent, |
367 | | XMP_Index baseIndent ) const; |
368 | | |
369 | | // ============================================================================================= |
370 | | |
371 | | // --------------------------------------------------------------------------------------------- |
372 | | // - Everything is built out of standard nodes. Each node has a name, value, option flags, a |
373 | | // vector of child nodes, and a vector of qualifier nodes. |
374 | | // |
375 | | // - The option flags are those passed to SetProperty and returned from GetProperty. They tell |
376 | | // if the node is simple, a struct or an array; whether it has qualifiers, etc. |
377 | | // |
378 | | // - The name of the node is an XML qualified name, of the form "prefix:simple-name". Since we |
379 | | // force all namespaces to be known and to have unique prefixes, this is semantically equivalent |
380 | | // to using a URI and simple name pair. |
381 | | // |
382 | | // - Although the value part is only for leaf properties and the children part is only for |
383 | | // structs and arrays, it is easier to simply have them in every node. This keeps things visible |
384 | | // so that debugging is easier |
385 | | // |
386 | | // - The top level node children are the namespaces that contain properties, the next level are |
387 | | // the top level properties, lower levels are the fields of structs or items of arrays. The name |
388 | | // of the top level nodes is just the namespace prefix, with the colon terminator. The name of |
389 | | // top level properties includes the namespace prefix. |
390 | | // |
391 | | // - Any property node, at any level, can have qualifiers. These are themselves general property |
392 | | // nodes. And could in fact themselves have qualifiers! |
393 | | |
394 | | // ! Expose the implementation so that file static functions can see the data. |
395 | | |
396 | | XMP_Int32 clientRefs; // ! Must be signed to allow decrement from 0. |
397 | | XMP_Int32 prevTkVer; // Previous toolkit version as MMmmuubbb (major, minor, micro, build). |
398 | | XMP_Node tree; |
399 | | |
400 | | XMLParserAdapter * xmlParser; |
401 | | |
402 | | friend class XMPIterator; |
403 | | friend class XMPUtils; |
404 | | |
405 | | private: |
406 | | |
407 | | // ! These are hidden on purpose: |
408 | | XMPMeta ( const XMPMeta & /* original */ ) : clientRefs(0), prevTkVer(0), tree(XMP_Node(0,"",0)), xmlParser(0) |
409 | 0 | { XMP_Throw ( "Call to hidden constructor", kXMPErr_InternalFailure ); }; |
410 | | void operator= ( const XMPMeta & /* rhs */ ) |
411 | 0 | { XMP_Throw ( "Call to hidden operator=", kXMPErr_InternalFailure ); }; |
412 | | |
413 | | }; // class XMPMeta |
414 | | |
415 | | |
416 | | // ================================================================================================= |
417 | | |
418 | | #endif // __XMPMeta_hpp__ |