XMP Toolkit SDK  6.0.0
TXMPUtils.hpp
Go to the documentation of this file.
1 #ifndef __TXMPUtils_hpp__
2 #define __TXMPUtils_hpp__ 1
3 
4 #if ( ! __XMP_hpp__ )
5  #error "Do not directly include, use XMP.hpp"
6 #endif
7 
8 // =================================================================================================
9 // Copyright Adobe
10 // Copyright 2002 Adobe
11 // All Rights Reserved
12 //
13 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
14 // of the Adobe license agreement accompanying it. If you have received this file from a source other
15 // than Adobe, then your use, modification, or distribution of it requires the prior written permission
16 // of Adobe.
17 // =================================================================================================
18 
19 // =================================================================================================
26 // =================================================================================================
27 
28 // =================================================================================================
49 // =================================================================================================
50 
51 template <class tStringObj> class TXMPUtils {
52 
53 public:
54 
55  // =============================================================================================
56  // No constructors or destructor declared or needed
57  // ================================================
58 
59  // ============================================================================================
94 
95  // ---------------------------------------------------------------------------------------------
111 
112  static void ComposeArrayItemPath ( XMP_StringPtr schemaNS,
113  XMP_StringPtr arrayName,
114  XMP_Index itemIndex,
115  tStringObj * fullPath );
116 
117  // ---------------------------------------------------------------------------------------------
135 
136  static void ComposeStructFieldPath ( XMP_StringPtr schemaNS,
137  XMP_StringPtr structName,
138  XMP_StringPtr fieldNS,
139  XMP_StringPtr fieldName,
140  tStringObj * fullPath );
141 
142  // ---------------------------------------------------------------------------------------------
161 
162  static void ComposeQualifierPath ( XMP_StringPtr schemaNS,
163  XMP_StringPtr propName,
164  XMP_StringPtr qualNS,
165  XMP_StringPtr qualName,
166  tStringObj * fullPath );
167 
168  // ---------------------------------------------------------------------------------------------
192 
193  static void ComposeLangSelector ( XMP_StringPtr schemaNS,
194  XMP_StringPtr arrayName,
195  XMP_StringPtr langName,
196  tStringObj * fullPath );
197 
198  // ---------------------------------------------------------------------------------------------
222 
223  static void ComposeLangSelector ( XMP_StringPtr schemaNS,
224  XMP_StringPtr arrayName,
225  const tStringObj & langName,
226  tStringObj * fullPath );
227 
228  // ---------------------------------------------------------------------------------------------
262 
263  static void ComposeFieldSelector ( XMP_StringPtr schemaNS,
264  XMP_StringPtr arrayName,
265  XMP_StringPtr fieldNS,
266  XMP_StringPtr fieldName,
267  XMP_StringPtr fieldValue,
268  tStringObj * fullPath );
269 
270  // ---------------------------------------------------------------------------------------------
304 
305  static void ComposeFieldSelector ( XMP_StringPtr schemaNS,
306  XMP_StringPtr arrayName,
307  XMP_StringPtr fieldNS,
308  XMP_StringPtr fieldName,
309  const tStringObj & fieldValue,
310  tStringObj * fullPath );
311 
313 
314  // =============================================================================================
326 
327  // ---------------------------------------------------------------------------------------------
336 
337  static void ConvertFromBool ( bool binValue,
338  tStringObj * strValue );
339 
340  // ---------------------------------------------------------------------------------------------
348 
349  static void ConvertFromInt ( long binValue,
350  XMP_StringPtr format,
351  tStringObj * strValue );
352  // ---------------------------------------------------------------------------------------------
360 
361  static void ConvertFromInt64 ( long long binValue,
362  XMP_StringPtr format,
363  tStringObj * strValue );
364 
365  // ---------------------------------------------------------------------------------------------
373 
374  static void ConvertFromFloat ( double binValue,
375  XMP_StringPtr format,
376  tStringObj * strValue );
377 
378  // ---------------------------------------------------------------------------------------------
411 
412  static void ConvertFromDate ( const XMP_DateTime & binValue,
413  tStringObj * strValue );
414 
415  // ---------------------------------------------------------------------------------------------
425 
426  static bool ConvertToBool ( XMP_StringPtr strValue );
427 
428  // ---------------------------------------------------------------------------------------------
437 
438  static bool ConvertToBool ( const tStringObj & strValue );
439 
440  // ---------------------------------------------------------------------------------------------
446 
447  static long ConvertToInt ( XMP_StringPtr strValue );
448 
449  // ---------------------------------------------------------------------------------------------
458 
459  static long ConvertToInt ( const tStringObj & strValue );
460 
461  // ---------------------------------------------------------------------------------------------
467 
468  static long long ConvertToInt64 ( XMP_StringPtr strValue );
469 
470  // ---------------------------------------------------------------------------------------------
479 
480  static long long ConvertToInt64 ( const tStringObj & strValue );
481 
482  // ---------------------------------------------------------------------------------------------
488 
489  static double ConvertToFloat ( XMP_StringPtr strValue );
490 
491  // ---------------------------------------------------------------------------------------------
500 
501  static double ConvertToFloat ( const tStringObj & strValue );
502 
503  // ---------------------------------------------------------------------------------------------
538 
539  static void ConvertToDate ( XMP_StringPtr strValue,
540  XMP_DateTime * binValue );
541 
542  // ---------------------------------------------------------------------------------------------
554 
555  static void ConvertToDate ( const tStringObj & strValue,
556  XMP_DateTime * binValue );
557 
559 
560  // =============================================================================================
566 
567  // ---------------------------------------------------------------------------------------------
575 
576  static void CurrentDateTime ( XMP_DateTime * time );
577 
578  // ---------------------------------------------------------------------------------------------
584 
585  static void SetTimeZone ( XMP_DateTime * time );
586 
587  // ---------------------------------------------------------------------------------------------
594 
595  static void ConvertToUTCTime ( XMP_DateTime * time );
596 
597  // ---------------------------------------------------------------------------------------------
605 
606  static void ConvertToLocalTime ( XMP_DateTime * time );
607 
608  // ---------------------------------------------------------------------------------------------
621 
622  static int CompareDateTime ( const XMP_DateTime & left,
623  const XMP_DateTime & right );
624 
626 
627  // =============================================================================================
632 
633  // ---------------------------------------------------------------------------------------------
641 
642  static void EncodeToBase64 ( XMP_StringPtr rawStr,
643  XMP_StringLen rawLen,
644  tStringObj * encodedStr );
645 
646  // ---------------------------------------------------------------------------------------------
655 
656  static void EncodeToBase64 ( const tStringObj & rawStr,
657  tStringObj * encodedStr );
658 
659  // ---------------------------------------------------------------------------------------------
667 
668  static void DecodeFromBase64 ( XMP_StringPtr encodedStr,
669  XMP_StringLen encodedLen,
670  tStringObj * rawStr );
671 
672  // ---------------------------------------------------------------------------------------------
681 
682  static void DecodeFromBase64 ( const tStringObj & encodedStr,
683  tStringObj * rawStr );
684 
686 
687  // =============================================================================================
688  // =============================================================================================
696 
697  // ---------------------------------------------------------------------------------------------
716 
717  static void PackageForJPEG ( const TXMPMeta<tStringObj> & xmpObj,
718  tStringObj * standardXMP,
719  tStringObj * extendedXMP,
720  tStringObj * extendedDigest );
721 
722  // ---------------------------------------------------------------------------------------------
736 
737  static void MergeFromJPEG ( TXMPMeta<tStringObj> * fullXMP,
738  const TXMPMeta<tStringObj> & extendedXMP );
739 
741 
742  // =============================================================================================
749 
750  // ---------------------------------------------------------------------------------------------
774 
775  static void CatenateArrayItems ( const TXMPMeta<tStringObj> & xmpObj,
776  XMP_StringPtr schemaNS,
777  XMP_StringPtr arrayName,
778  XMP_StringPtr separator,
779  XMP_StringPtr quotes,
780  XMP_OptionBits options,
781  tStringObj * catedStr );
782 
783  // ---------------------------------------------------------------------------------------------
801 
802  static void SeparateArrayItems ( TXMPMeta<tStringObj> * xmpObj,
803  XMP_StringPtr schemaNS,
804  XMP_StringPtr arrayName,
805  XMP_OptionBits options,
806  XMP_StringPtr catedStr );
807 
808  // ---------------------------------------------------------------------------------------------
814 
815  static void SeparateArrayItems ( TXMPMeta<tStringObj> * xmpObj,
816  XMP_StringPtr schemaNS,
817  XMP_StringPtr arrayName,
818  XMP_OptionBits options,
819  const tStringObj & catedStr );
820 
870 
885 
886  static void ApplyTemplate ( TXMPMeta<tStringObj> * workingXMP,
887  const TXMPMeta<tStringObj> & templateXMP,
888  XMP_OptionBits actions );
889 
890  // ---------------------------------------------------------------------------------------------
921 
922  static void RemoveProperties ( TXMPMeta<tStringObj> * xmpObj,
923  XMP_StringPtr schemaNS = 0,
924  XMP_StringPtr propName = 0,
925  XMP_OptionBits options = 0 );
926 
927  // ---------------------------------------------------------------------------------------------
948 
949  static void DuplicateSubtree ( const TXMPMeta<tStringObj> & source,
950  TXMPMeta<tStringObj> * dest,
951  XMP_StringPtr sourceNS,
952  XMP_StringPtr sourceRoot,
953  XMP_StringPtr destNS = 0,
954  XMP_StringPtr destRoot = 0,
955  XMP_OptionBits options = 0 );
956 
958 
959  // =============================================================================================
960 
961 private:
962 
963  static void SetClientString ( void * clientPtr, XMP_StringPtr valuePtr, XMP_StringLen valueLen );
964 
965 }; // class TXMPUtils
966 
967 // =================================================================================================
968 
969 #endif // __TXMPUtils_hpp__
TXMPUtils::ComposeLangSelector
static void ComposeLangSelector(XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_StringPtr langName, tStringObj *fullPath)
ComposeLangSelector() composes the path expression to select an alternate item by language.
TXMPUtils::ConvertFromInt64
static void ConvertFromInt64(long long binValue, XMP_StringPtr format, tStringObj *strValue)
ConvertFromInt64() converts a 64-bit integer value to a string.
TXMPUtils::ConvertToInt64
static long long ConvertToInt64(XMP_StringPtr strValue)
ConvertToInt64() converts a string to a 64-bit integer value.
TXMPUtils::SetTimeZone
static void SetTimeZone(XMP_DateTime *time)
SetTimeZone() sets the time zone in a date/time value to the local time zone.
TXMPUtils::ConvertToDate
static void ConvertToDate(XMP_StringPtr strValue, XMP_DateTime *binValue)
ConvertToDate() converts a string to a date/time value.
TXMPUtils::ConvertFromInt
static void ConvertFromInt(long binValue, XMP_StringPtr format, tStringObj *strValue)
ConvertFromInt() converts a 32-bit integer value to a string.
TXMPUtils::CurrentDateTime
static void CurrentDateTime(XMP_DateTime *time)
CurrentDateTime() obtains the current date and time.
TXMPUtils::ConvertFromFloat
static void ConvertFromFloat(double binValue, XMP_StringPtr format, tStringObj *strValue)
ConvertFromFloat() converts a floating-point value to a string.
TXMPUtils::ComposeFieldSelector
static void ComposeFieldSelector(XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_StringPtr fieldNS, XMP_StringPtr fieldName, XMP_StringPtr fieldValue, tStringObj *fullPath)
ComposeFieldSelector() composes a path expression to select an alternate item by a field's value.
TXMPUtils::CompareDateTime
static int CompareDateTime(const XMP_DateTime &left, const XMP_DateTime &right)
CompareDateTime() compares the order of two date/time values.
TXMPUtils::PackageForJPEG
static void PackageForJPEG(const TXMPMeta< tStringObj > &xmpObj, tStringObj *standardXMP, tStringObj *extendedXMP, tStringObj *extendedDigest)
PackageForJPEG() creates XMP serializations appropriate for a JPEG file.
TXMPUtils::EncodeToBase64
static void EncodeToBase64(XMP_StringPtr rawStr, XMP_StringLen rawLen, tStringObj *encodedStr)
These functions convert between raw data values and Base64-encoded strings.
TXMPUtils::RemoveProperties
static void RemoveProperties(TXMPMeta< tStringObj > *xmpObj, XMP_StringPtr schemaNS=0, XMP_StringPtr propName=0, XMP_OptionBits options=0)
RemoveProperties() removes multiple properties from an XMP object.
TXMPUtils::ConvertFromDate
static void ConvertFromDate(const XMP_DateTime &binValue, tStringObj *strValue)
ConvertFromDate() converts a date/time value to a string.
TXMPUtils::ComposeQualifierPath
static void ComposeQualifierPath(XMP_StringPtr schemaNS, XMP_StringPtr propName, XMP_StringPtr qualNS, XMP_StringPtr qualName, tStringObj *fullPath)
ComposeQualifierPath() composes the path expression for a qualifier.
TXMPMeta
API for access to the XMP Toolkit core services.
Definition: TXMPMeta.hpp:57
TXMPUtils::ConvertToInt
static long ConvertToInt(XMP_StringPtr strValue)
ConvertToInt() converts a string to a 32-bit integer value.
TXMPUtils::ComposeStructFieldPath
static void ComposeStructFieldPath(XMP_StringPtr schemaNS, XMP_StringPtr structName, XMP_StringPtr fieldNS, XMP_StringPtr fieldName, tStringObj *fullPath)
ComposeStructFieldPath() composes the path expression for a field in a struct.
XMP_StringPtr
const typedef char * XMP_StringPtr
The type for input string parameters. A const char *, a null-terminated UTF-8 string.
Definition: XMP_Const.h:178
TXMPUtils::ConvertToLocalTime
static void ConvertToLocalTime(XMP_DateTime *time)
ConvertToLocalTime() ensures that a time is local.
TXMPUtils::DuplicateSubtree
static void DuplicateSubtree(const TXMPMeta< tStringObj > &source, TXMPMeta< tStringObj > *dest, XMP_StringPtr sourceNS, XMP_StringPtr sourceRoot, XMP_StringPtr destNS=0, XMP_StringPtr destRoot=0, XMP_OptionBits options=0)
DuplicateSubtree() replicates a subtree from one XMP object into another.
XMP_StringLen
XMP_Uns32 XMP_StringLen
The type for string length parameters. A 32-bit unsigned integer, as big as will be practically neede...
Definition: XMP_Const.h:179
TXMPUtils::ComposeArrayItemPath
static void ComposeArrayItemPath(XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_Index itemIndex, tStringObj *fullPath)
ComposeArrayItemPath() composes the path expression for an item in an array.
XMP_Index
XMP_Int32 XMP_Index
The type for offsets and indices. A 32-bit signed integer. It is signed to allow -1 for loop terminat...
Definition: XMP_Const.h:180
TXMPUtils::DecodeFromBase64
static void DecodeFromBase64(XMP_StringPtr encodedStr, XMP_StringLen encodedLen, tStringObj *rawStr)
DecodeFromBase64() Decodes a Base64-encoded string to raw data.
TXMPUtils::MergeFromJPEG
static void MergeFromJPEG(TXMPMeta< tStringObj > *fullXMP, const TXMPMeta< tStringObj > &extendedXMP)
MergeFromJPEG() merges standard and extended XMP retrieved from a JPEG file.
TXMPUtils
API for access to the XMP Toolkit utility services.
Definition: TXMPMeta.hpp:53
TXMPUtils::ConvertToUTCTime
static void ConvertToUTCTime(XMP_DateTime *time)
ConvertToUTCTime() ensures that a time is UTC.
TXMPUtils::ConvertFromBool
static void ConvertFromBool(bool binValue, tStringObj *strValue)
ConvertFromBool() converts a Boolean value to a string.
TXMPUtils::CatenateArrayItems
static void CatenateArrayItems(const TXMPMeta< tStringObj > &xmpObj, XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_StringPtr separator, XMP_StringPtr quotes, XMP_OptionBits options, tStringObj *catedStr)
CatenateArrayItems() creates a single edit string from a set of array item values.
TXMPUtils::SetClientString
static void SetClientString(void *clientPtr, XMP_StringPtr valuePtr, XMP_StringLen valueLen)
TXMPUtils::ApplyTemplate
static void ApplyTemplate(TXMPMeta< tStringObj > *workingXMP, const TXMPMeta< tStringObj > &templateXMP, XMP_OptionBits actions)
ApplyTemplate() modifies a working XMP object according to a template object.
XMP_OptionBits
XMP_Uns32 XMP_OptionBits
The type for a collection of 32 flag bits.
Definition: XMP_Const.h:181
XMP_DateTime
The expanded type for a date and time.
Definition: XMP_Const.h:232
TXMPUtils::SeparateArrayItems
static void SeparateArrayItems(TXMPMeta< tStringObj > *xmpObj, XMP_StringPtr schemaNS, XMP_StringPtr arrayName, XMP_OptionBits options, XMP_StringPtr catedStr)
SeparateArrayItems() updates an array from a concatenated edit string of values.
TXMPUtils::ConvertToBool
static bool ConvertToBool(XMP_StringPtr strValue)
ConvertToBool() converts a string to a Boolean value.
TXMPUtils::ConvertToFloat
static double ConvertToFloat(XMP_StringPtr strValue)
ConvertToFloat() converts a string to a floating-point value.