00001 #ifndef __TXMPUtils_hpp__ 00002 #define __TXMPUtils_hpp__ 1 00003 00004 #if ( ! __XMP_hpp__ ) 00005 #error "Do not directly include, use XMP.hpp" 00006 #endif 00007 00008 // ================================================================================================= 00009 // ADOBE SYSTEMS INCORPORATED 00010 // Copyright 2002-2005 Adobe Systems Incorporated 00011 // All Rights Reserved 00012 // 00013 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms 00014 // of the Adobe license agreement accompanying it. 00015 // ================================================================================================= 00016 00017 // ================================================================================================ 00024 // ================================================================================================ 00025 00026 // ================================================================================================ 00047 // ================================================================================================ 00048 00049 template <class tStringObj> 00050 class TXMPUtils { 00051 00052 public: 00053 00054 // ============================================================================================= 00055 // No constructors or destructor declared or needed 00056 // ================================================ 00057 00058 // ============================================================================================= 00059 // ============================================================================================= 00060 00061 // ============================================================================================ 00093 00094 // -------------------------------------------------------------------------------------------- 00109 00110 static void 00111 ComposeArrayItemPath ( XMP_StringPtr schemaNS, 00112 XMP_StringPtr arrayName, 00113 XMP_Index itemIndex, 00114 tStringObj * fullPath ); 00115 00116 // -------------------------------------------------------------------------------------------- 00132 00133 static void 00134 ComposeStructFieldPath ( XMP_StringPtr schemaNS, 00135 XMP_StringPtr structName, 00136 XMP_StringPtr fieldNS, 00137 XMP_StringPtr fieldName, 00138 tStringObj * fullPath ); 00139 00140 // -------------------------------------------------------------------------------------------- 00158 00159 static void 00160 ComposeQualifierPath ( XMP_StringPtr schemaNS, 00161 XMP_StringPtr propName, 00162 XMP_StringPtr qualNS, 00163 XMP_StringPtr qualName, 00164 tStringObj * fullPath ); 00165 00166 // -------------------------------------------------------------------------------------------- 00190 00191 static void 00192 ComposeLangSelector ( XMP_StringPtr schemaNS, 00193 XMP_StringPtr arrayName, 00194 XMP_StringPtr langName, 00195 tStringObj * fullPath ); 00196 00197 // -------------------------------------------------------------------------------------------- 00200 00201 static void 00202 ComposeLangSelector ( XMP_StringPtr schemaNS, 00203 XMP_StringPtr arrayName, 00204 const tStringObj & langName, 00205 tStringObj * fullPath ); 00206 00207 // -------------------------------------------------------------------------------------------- 00241 00242 static void 00243 ComposeFieldSelector ( XMP_StringPtr schemaNS, 00244 XMP_StringPtr arrayName, 00245 XMP_StringPtr fieldNS, 00246 XMP_StringPtr fieldName, 00247 XMP_StringPtr fieldValue, 00248 tStringObj * fullPath ); 00249 00250 // -------------------------------------------------------------------------------------------- 00253 00254 static void 00255 ComposeFieldSelector ( XMP_StringPtr schemaNS, 00256 XMP_StringPtr arrayName, 00257 XMP_StringPtr fieldNS, 00258 XMP_StringPtr fieldName, 00259 const tStringObj & fieldValue, 00260 tStringObj * fullPath ); 00261 00263 00264 // ============================================================================================= 00265 // ============================================================================================= 00266 00267 // ============================================================================================ 00270 00271 // -------------------------------------------------------------------------------------------- 00278 00279 static void 00280 ConvertFromBool ( bool binValue, 00281 tStringObj * strValue ); 00282 00283 // -------------------------------------------------------------------------------------------- 00291 00292 static void 00293 ConvertFromInt ( long binValue, 00294 XMP_StringPtr format, 00295 tStringObj * strValue ); 00296 00297 static void 00298 ConvertFromInt64 ( long long binValue, 00299 XMP_StringPtr format, 00300 tStringObj * strValue ); 00301 00302 // -------------------------------------------------------------------------------------------- 00310 00311 static void 00312 ConvertFromFloat ( double binValue, 00313 XMP_StringPtr format, 00314 tStringObj * strValue ); 00315 00316 // -------------------------------------------------------------------------------------------- 00322 00323 static void 00324 ConvertFromDate ( const XMP_DateTime & binValue, 00325 tStringObj * strValue ); 00326 00327 // -------------------------------------------------------------------------------------------- 00335 00336 static bool 00337 ConvertToBool ( XMP_StringPtr strValue ); 00338 00339 // -------------------------------------------------------------------------------------------- 00342 00343 static bool 00344 ConvertToBool ( const tStringObj & strValue ); 00345 00346 // -------------------------------------------------------------------------------------------- 00352 00353 static long 00354 ConvertToInt ( XMP_StringPtr strValue ); 00355 00356 // -------------------------------------------------------------------------------------------- 00359 00360 static long 00361 ConvertToInt ( const tStringObj & strValue ); 00362 00363 // -------------------------------------------------------------------------------------------- 00369 00370 static long long 00371 ConvertToInt64 ( XMP_StringPtr strValue ); 00372 00373 // -------------------------------------------------------------------------------------------- 00376 00377 static long long 00378 ConvertToInt64 ( const tStringObj & strValue ); 00379 00380 // -------------------------------------------------------------------------------------------- 00386 00387 static double 00388 ConvertToFloat ( XMP_StringPtr strValue ); 00389 00390 // -------------------------------------------------------------------------------------------- 00393 00394 static double 00395 ConvertToFloat ( const tStringObj & strValue ); 00396 00397 // -------------------------------------------------------------------------------------------- 00403 00404 static void 00405 ConvertToDate ( XMP_StringPtr strValue, 00406 XMP_DateTime * binValue ); 00407 00408 // -------------------------------------------------------------------------------------------- 00411 00412 static void 00413 ConvertToDate ( const tStringObj & strValue, 00414 XMP_DateTime * binValue ); 00415 00417 00418 // ============================================================================================= 00419 // ============================================================================================= 00420 00421 // ============================================================================================ 00424 00425 // -------------------------------------------------------------------------------------------- 00431 00432 static void 00433 CurrentDateTime ( XMP_DateTime * time ); 00434 00435 // -------------------------------------------------------------------------------------------- 00440 00441 static void 00442 SetTimeZone ( XMP_DateTime * time ); 00443 00444 // -------------------------------------------------------------------------------------------- 00449 00450 static void 00451 ConvertToUTCTime ( XMP_DateTime * time ); 00452 00453 // -------------------------------------------------------------------------------------------- 00458 00459 static void 00460 ConvertToLocalTime ( XMP_DateTime * time ); 00461 00462 // -------------------------------------------------------------------------------------------- 00473 00474 static int 00475 CompareDateTime ( const XMP_DateTime & left, 00476 const XMP_DateTime & right ); 00477 00479 00480 // ============================================================================================= 00481 // ============================================================================================= 00482 00483 // ============================================================================================ 00486 00487 // -------------------------------------------------------------------------------------------- 00495 00496 static void 00497 EncodeToBase64 ( XMP_StringPtr rawStr, 00498 XMP_StringLen rawLen, 00499 tStringObj * encodedStr ); 00500 00501 // -------------------------------------------------------------------------------------------- 00504 00505 static void 00506 EncodeToBase64 ( const tStringObj & rawStr, 00507 tStringObj * encodedStr ); 00508 00509 // -------------------------------------------------------------------------------------------- 00517 00518 static void 00519 DecodeFromBase64 ( XMP_StringPtr encodedStr, 00520 XMP_StringLen encodedLen, 00521 tStringObj * rawStr ); 00522 00523 // -------------------------------------------------------------------------------------------- 00526 00527 static void 00528 DecodeFromBase64 ( const tStringObj & encodedStr, 00529 tStringObj * rawStr ); 00530 00532 00533 // ============================================================================================= 00534 00535 }; // class TXMPUtils 00536 00537 // ================================================================================================= 00538 00539 #endif // __TXMPUtils_hpp__