diff options
author | Hubert Figuière <hub@figuiere.net> | 2013-06-29 22:05:20 -0400 |
---|---|---|
committer | Hubert Figuière <hub@figuiere.net> | 2013-06-29 22:08:01 -0400 |
commit | 4652015fe779e12fb06ff8fa56bf70e373cd3894 (patch) | |
tree | de8d78fb704c3eb86802c07eace17eaea0f2ddde /public/include | |
parent | 81a4c6bcb1879cb321246590faca595e9746f8e5 (diff) |
Update to XMP SDK CC 2013.06
Diffstat (limited to 'public/include')
-rw-r--r-- | public/include/TXMPFiles.hpp | 313 | ||||
-rw-r--r-- | public/include/TXMPMeta.hpp | 61 | ||||
-rw-r--r-- | public/include/XMP_Const.h | 199 | ||||
-rw-r--r-- | public/include/XMP_Environment.h | 38 | ||||
-rw-r--r-- | public/include/XMP_Version.h | 12 | ||||
-rw-r--r-- | public/include/client-glue/TXMPFiles.incl_cpp | 107 | ||||
-rw-r--r-- | public/include/client-glue/TXMPMeta.incl_cpp | 31 | ||||
-rw-r--r-- | public/include/client-glue/TXMPUtils.incl_cpp | 7 | ||||
-rw-r--r-- | public/include/client-glue/WXMPFiles.hpp | 95 | ||||
-rw-r--r-- | public/include/client-glue/WXMPMeta.hpp | 47 | ||||
-rw-r--r-- | public/include/client-glue/WXMP_Common.hpp | 1 |
11 files changed, 802 insertions, 109 deletions
diff --git a/public/include/TXMPFiles.hpp b/public/include/TXMPFiles.hpp index dbe4fdc..a05154e 100644 --- a/public/include/TXMPFiles.hpp +++ b/public/include/TXMPFiles.hpp @@ -1,5 +1,5 @@ #ifndef __TXMPFiles_hpp__ -#define __TXMPFiles_hpp__ 1 +#define __TXMPFiles_hpp__ 1 #if ( ! __XMP_hpp__ ) #error "Do not directly include, use XMP.hpp" @@ -22,7 +22,7 @@ /// format-specific file handlers that support file I/O for XMP. The file handlers implement smart, /// efficient support for those file formats for which the means to embed XMP is defined in the XMP /// Specification. Where possible, this support allows: -/// \li Injection of XMP where none currently exists +/// \li Injection of XMP where none currently exists /// \li Expansion of XMP without regard to existing padding /// \li Reconciliation of the XMP and other legacy forms of metadata. /// @@ -58,8 +58,8 @@ // ================================================================================================= -#if XMP_StaticBuild // ! Client XMP_IO objects can only be used in static builds. - #include "XMP_IO.hpp" +#if XMP_StaticBuild // ! Client XMP_IO objects can only be used in static builds. + #include "XMP_IO.hpp" #endif @@ -68,7 +68,7 @@ class TXMPFiles { public: - // ============================================================================================= + // ============================================================================================= /// \name Initialization and termination /// @{ /// @@ -94,7 +94,7 @@ public: /// /// @return True on success. - static bool Initialize(); + static bool Initialize(); // --------------------------------------------------------------------------------------------- /// @brief Initializes the XMPFiles library; must be called before creating an \c SXMPFiles object. @@ -111,7 +111,7 @@ public: /// /// @return True on success. - static bool Initialize ( XMP_OptionBits options ); + static bool Initialize ( XMP_OptionBits options ); // --------------------------------------------------------------------------------------------- /// @brief Initializes the XMPFiles library; must be called before creating an \c SXMPFiles object. @@ -131,7 +131,7 @@ public: /// /// @return True on success. - static bool Initialize ( const char* pluginFolder, const char* plugins = NULL ); + static bool Initialize ( const char* pluginFolder, const char* plugins = NULL ); // --------------------------------------------------------------------------------------------- /// @brief Initializes the XMPFiles library; must be called before creating an \c SXMPFiles object. @@ -152,7 +152,7 @@ public: /// /// @return True on success. - static bool Initialize ( XMP_OptionBits options, const char* pluginFolder, const char* plugins = NULL ); + static bool Initialize ( XMP_OptionBits options, const char* pluginFolder, const char* plugins = NULL ); // --------------------------------------------------------------------------------------------- /// @brief Terminates use of the XMPFiles library. @@ -162,11 +162,11 @@ public: /// /// This function is static; make the call directly from the concrete class (\c SXMPFiles). - static void Terminate(); + static void Terminate(); /// @} - // ============================================================================================= + // ============================================================================================= /// \name Constructors and destructor /// @{ /// @@ -185,14 +185,14 @@ public: /// /// @see \c OpenFile(), \c CloseFile() - virtual ~TXMPFiles() throw(); + virtual ~TXMPFiles() throw(); // --------------------------------------------------------------------------------------------- /// @brief Alternate constructor associates the new \c XMPFiles object with a specific file. /// /// Calls \c OpenFile() to open the specified file after performing a default construct. /// - /// @param filePath The path for the file, specified as a nul-terminated UTF-8 string. + /// @param filePath The path for the file, specified as a nul-terminated UTF-8 string. /// /// @param format A format hint for the file, if known. /// @@ -210,19 +210,19 @@ public: /// @return The new \c TXMPFiles object. TXMPFiles ( XMP_StringPtr filePath, - XMP_FileFormat format = kXMP_UnknownFile, - XMP_OptionBits openFlags = 0 ); + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits openFlags = 0 ); // --------------------------------------------------------------------------------------------- /// @brief Alternate constructor associates the new \c XMPFiles object with a specific file, /// using a string object. /// /// Overloads the basic form of the function, allowing you to pass a string object - /// for the file path. It is otherwise identical; see details in the canonical form. + /// for the file path. It is otherwise identical; see details in the canonical form. TXMPFiles ( const tStringObj & filePath, - XMP_FileFormat format = kXMP_UnknownFile, - XMP_OptionBits openFlags = 0 ); + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits openFlags = 0 ); // --------------------------------------------------------------------------------------------- /// @brief Copy constructor @@ -242,7 +242,7 @@ public: /// /// @param rhs The existing \c TXMPFiles object. - void operator= ( const TXMPFiles<tStringObj> & rhs ); + void operator= ( const TXMPFiles<tStringObj> & rhs ); // --------------------------------------------------------------------------------------------- /// @brief Reconstructs a \c TXMPFiles object from an internal reference. @@ -265,7 +265,7 @@ public: /// Use with the reconstruction constructor to safely pass \c SXMPFiles references across DLL /// boundaries where the clients might have used different string types when instantiating /// \c TXMPFiles. - /// + /// /// @return The internal reference. /// /// @see \c TXMPMeta::GetInternalRef() for usage. @@ -274,7 +274,7 @@ public: /// @} - // ============================================================================================= + // ============================================================================================= /// \name File handler information /// @{ /// @@ -314,11 +314,11 @@ public: static bool GetFormatInfo ( XMP_FileFormat format, - XMP_OptionBits * handlerFlags = 0 ); + XMP_OptionBits * handlerFlags = 0 ); /// @} - // ============================================================================================= + // ============================================================================================= /// \name File operations /// @{ /// @@ -356,29 +356,92 @@ public: static XMP_FileFormat CheckPackageFormat ( XMP_StringPtr folderPath ); // --------------------------------------------------------------------------------------------- - /// @brief \c GetFileModDate() returns the most recent modification date of a file containing metadata. + /// @brief \c GetFileModDate() returns the last modification date of all files that are returned + /// by \c GetAssociatedResources() /// - /// Tries to return the most recent O/S file modification date for associated metadata. In the - /// typical case of a single file containing embedded XMP and non-XMP this is the modification - /// date of that file. For a simple sidecar, such as MPEG-2, this is the modification date of - /// the sidecar and not the media file. For a video package such as P2 this is the XMP file, the - /// XML file, and any media file that might be read for metadata. + /// Returns the most recent O/S file modification date of all associated files. In the typical case + /// of a single file containing embedded XMP, returned date value is the modification date of the + /// same file. For sidecar and folder based video packages, returned date value is the modification + /// date of that associated file which was updated last. /// - /// @param filePath The path for the file, appropriate for the local operating system. Passed as - /// a nul-terminated UTF-8 string. The path is the same as would be passed to \c OpenFile. + /// @param filePath A path exactly as would be passed to \c OpenFile. + /// + /// @param modDate A required pointer to return the last modification date. + /// + /// @param format A format hint as would be passed to \c OpenFile. /// - /// @param modDate A required pointer to return the modification date. + /// @param options An optional set of option flags. The only defined one is \c kXMPFiles_ForceGivenHandler, + /// used to shortcut the handler selection logic if the caller is certain of the format. /// - /// @param format An optional in/out pointer to a file format. Used on input as a hint for the - /// handler to select, on output as the handler chosen. + /// @return Returns true if the file path is valid to select a smart handler, false for an + /// invalid path or if fallback packet scanning would be selected. + + static bool GetFileModDate ( XMP_StringPtr filePath, + XMP_DateTime * modDate, + XMP_FileFormat * format = 0, + XMP_OptionBits options = 0 ); + + + // --------------------------------------------------------------------------------------------- + /// @brief \c GetAssociatedResources() returns a list of files and folders associated to filePath. + /// + /// \c GetAssociatedResources is provided to locate all files that are associated to the given + /// filePath such as sidecar-based XMP or folder-based video packages.If a smart + /// handler can be selected (not fallback packet scanning) then a list of file/folder paths is + /// returned for the related files that can be safely copied/imported to a different location, + /// keeping intact metadata(XMP and non-XMP),content and the necessary folder structure of the + /// format. The necessary folder structure here is the structure that is needed to uniquely + /// identify a folder-based format.The filePath and format parameters are exactly as would be + /// used for OpenFile. In the simple embedded XMP case just one path is returned. In the simple + /// sidecar case one or two paths will be returned, one if there is no sidecar XMP and two if + /// sidecar XMP exists. For folder-based handlers paths to all associated files is returned, + /// including the files and folders necessary to identify the format.In general, all the returned + /// paths are existent.In case of folder based video formats the first associated resource in the + /// resourceList is the root folder. + /// + /// @param filePath A path exactly as would be passed to \c OpenFile. + /// + /// @param resourceList Address of a vector of strings to receive all associated resource paths. + /// + /// @param format A format hint as would be passed to \c OpenFile. /// /// @param options An optional set of option flags. The only defined one is \c kXMPFiles_ForceGivenHandler, /// used to shortcut the handler selection logic if the caller is certain of the format. /// - /// @return True if a modification date could be determined, false if there is no smart file handler. + /// @return Returns true if the file path is valid to select a smart handler, false for an + /// invalid path or if fallback packet scanning would be selected. Can also return false for + /// unexpected errors that prevent knowledge of the file usage. + + static bool GetAssociatedResources ( XMP_StringPtr filePath, + std::vector<tStringObj>* resourceList, + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits options = 0); - static bool GetFileModDate ( XMP_StringPtr filePath, XMP_DateTime * modDate, - XMP_FileFormat * format = 0, XMP_OptionBits options = 0 ); + // --------------------------------------------------------------------------------------------- + /// @brief \c IsMetadataWritable() returns true if metadata can be updated for the given media path. + /// + /// \c IsMetadataWritable is provided to check if metadata can be updated or written to the format.In + /// the case of folder-based video formats only if all the metadata files can be written to, true is + /// returned.In other words, false is returned for a partial-write state of metadata files in + /// folder-based media formats. + /// + /// @param filePath A path exactly as would be passed to \c OpenFile. + /// + /// @param writable A pointer to the result flag. Is true if the metadata can be updated in the format, + /// otherwise false. + /// + /// @param format A format hint as would be passed to \c OpenFile. + /// + /// @param options An optional set of option flags. The only defined one is \c kXMPFiles_ForceGivenHandler, + /// used to shortcut the handler selection logic if the caller is certain of the format. + /// + /// @return Returns true if the file path is valid to select a smart handler, false for an + /// invalid path or if fallback packet scanning would be selected. + + static bool IsMetadataWritable (XMP_StringPtr filePath, + bool * writable, + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits options = 0 ); // --------------------------------------------------------------------------------------------- /// @brief \c OpenFile() opens a file for metadata access. @@ -423,7 +486,7 @@ public: /// \li \c #kXMPFiles_OpenForUpdate - Open for reading and writing. /// \li \c #kXMPFiles_OpenOnlyXMP - Only the XMP is wanted, no reconciliation. /// \li \c #kXMPFiles_OpenStrictly - Be strict about locating XMP and reconciling with other - /// forms. By default, a best effort is made to locate the correct XMP and to reconcile XMP + /// forms. By default, a best effort is made to locate the correct XMP and to reconcile XMP /// with other forms (if reconciliation is done). This option forces stricter rules, resulting /// in exceptions for errors. The definition of strictness is specific to each handler, there /// might be no difference. @@ -434,33 +497,32 @@ public: /// anticipated problems, such as passing \c #kXMPFiles_OpenUseSmartHandler but not having an /// appropriate smart handler. Throws an exception for serious problems. - - bool OpenFile ( XMP_StringPtr filePath, - XMP_FileFormat format = kXMP_UnknownFile, - XMP_OptionBits openFlags = 0 ); + bool OpenFile ( XMP_StringPtr filePath, + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits openFlags = 0 ); // --------------------------------------------------------------------------------------------- /// @brief \c OpenFile() opens a file for metadata access, using a string object /// /// Overloads the basic form of the function, allowing you to pass a string object for the file - /// path. It is otherwise identical; see details in the canonical form. + /// path. It is otherwise identical; see details in the canonical form. - bool OpenFile ( const tStringObj & filePath, - XMP_FileFormat format = kXMP_UnknownFile, - XMP_OptionBits openFlags = 0 ); + bool OpenFile ( const tStringObj & filePath, + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits openFlags = 0 ); - #if XMP_StaticBuild // ! Client XMP_IO objects can only be used in static builds. + #if XMP_StaticBuild // ! Client XMP_IO objects can only be used in static builds. // --------------------------------------------------------------------------------------------- /// @brief \c OpenFile() opens a client-provided XMP_IO object for metadata access. /// /// Alternative to the basic form of the function, allowing you to pass an XMP_IO object for /// client-managed I/O. - /// + /// - bool OpenFile ( XMP_IO * clientIO, - XMP_FileFormat format = kXMP_UnknownFile, - XMP_OptionBits openFlags = 0 ); - #endif + bool OpenFile ( XMP_IO * clientIO, + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits openFlags = 0 ); + #endif // --------------------------------------------------------------------------------------------- /// @brief CloseFile() explicitly closes an opened file. @@ -504,10 +566,10 @@ public: /// but \c CloseFile() has not. False otherwise. Even if the file object is open, the actual /// disk file might be closed in the host file-system sense; see \c OpenFile(). - bool GetFileInfo ( tStringObj * filePath = 0, - XMP_OptionBits * openFlags = 0, - XMP_FileFormat * format = 0, - XMP_OptionBits * handlerFlags = 0 ); + bool GetFileInfo ( tStringObj * filePath = 0, + XMP_OptionBits * openFlags = 0, + XMP_FileFormat * format = 0, + XMP_OptionBits * handlerFlags = 0 ); // --------------------------------------------------------------------------------------------- /// @brief \c SetAbortProc() registers a callback function used to check for a user-signaled abort. @@ -521,11 +583,11 @@ public: /// @param abortArg A pointer to caller-defined data to pass to the callback function. void SetAbortProc ( XMP_AbortProc abortProc, - void * abortArg ); + void * abortArg ); /// @} - // ============================================================================================= + // ============================================================================================= /// \name Accessing metadata /// @{ /// @@ -562,8 +624,8 @@ public: /// @return True if the file has XMP, false otherwise. bool GetXMP ( SXMPMeta * xmpObj = 0, - tStringObj * xmpPacket = 0, - XMP_PacketInfo * packetInfo = 0 ); + tStringObj * xmpPacket = 0, + XMP_PacketInfo * packetInfo = 0 ); // --------------------------------------------------------------------------------------------- /// @brief \c PutXMP() updates the XMP metadata in this object without writing out the file. @@ -578,21 +640,21 @@ public: // --------------------------------------------------------------------------------------------- /// @brief \c PutXMP() updates the XMP metadata in this object without writing out the file, - /// using a string object for input. + /// using a string object for input. /// /// Overloads the basic form of the function, allowing you to pass the metadata as a string object - /// instead of an XMP object. It is otherwise identical; see details in the canonical form. - /// + /// instead of an XMP object. It is otherwise identical; see details in the canonical form. + /// /// @param xmpPacket The new metadata as a string object containing a complete XMP packet. void PutXMP ( const tStringObj & xmpPacket ); // --------------------------------------------------------------------------------------------- /// @brief \c PutXMP() updates the XMP metadata in this object without writing out the file, - /// using a string object and optional length. + /// using a string object and optional length. /// /// Overloads the basic form of the function, allowing you to pass the metadata as a string object - /// instead of an XMP object. It is otherwise identical; see details in the canonical form. + /// instead of an XMP object. It is otherwise identical; see details in the canonical form. /// /// @param xmpPacket The new metadata as a <tt>const char *</tt> string containing an XMP packet. /// @@ -644,7 +706,7 @@ public: /// passed in a string object. /// /// Overloads the basic form of the function, allowing you to pass the metadata as a string object - /// instead of an XMP object. It is otherwise identical; see details in the canonical form. + /// instead of an XMP object. It is otherwise identical; see details in the canonical form. /// /// @param xmpPacket The proposed new metadata as a string object containing an XMP packet. @@ -655,7 +717,7 @@ public: /// passed in a string object. /// /// Overloads the basic form of the function, allowing you to pass the metadata as a string object - /// instead of an XMP object. It is otherwise identical; see details in the canonical form. + /// instead of an XMP object. It is otherwise identical; see details in the canonical form. /// /// @param xmpPacket The proposed new metadata as a <tt>const char *</tt> string containing an XMP packet. /// @@ -667,15 +729,124 @@ public: /// @} - // ============================================================================================= + // ============================================================================================= + /// \name Progress notifications + /// @{ + /// + /// These functions allow track the progress of file operations. Initially only file updates are + /// tracked, these all occur within calls to SXMPFiles::CloseFile. There are no plans to track + /// other operations at this time. Tracking support must be added to specific file handlers, + /// there are no guarantees about which handlers will have support. To simplify the logic only + /// file writes will be estimated and measured. + + // --------------------------------------------------------------------------------------------- + /// @brief \c SetDefaultProgressCallback() sets a global default for progress tracking. This is + /// used as a default for XMPFiles (library) objects created after the default is set. This does + /// not affect the callback for new SXMPFiles (client) objects with an existing XMPFiles object. + /// + /// @param proc The client's callback function. Can be zero to disable notifications. + /// + /// @param context A pointer used to carry client-private context. + /// + /// @param interval The desired number of seconds between notifications. Ideally the first + /// notification is sent after this interval, then at each following multiple of this interval. + /// + /// @param sendStartStop A Boolean value indicating if initial and final notifications are + /// wanted in addition to those at the reporting intervals. + + static void SetDefaultProgressCallback ( XMP_ProgressReportProc proc, void * context = 0, + float interval = 1.0, bool sendStartStop = false ); + + // --------------------------------------------------------------------------------------------- + /// @brief \c SetProgressCallback() sets the progress notification callback for the associated + /// XMPFiles (library) object. + /// + /// @param proc The client's callback function. Can be zero to disable notifications. + /// + /// @param context A pointer used to carry client-private context. + /// + /// @param interval The desired number of seconds between notifications. Ideally the first + /// notification is sent after this interval, then at each following multiple of this interval. + /// + /// @param sendStartStop A Boolean value indicating if initial and final notifications are + /// wanted in addition to those at the reporting intervals. + + void SetProgressCallback ( XMP_ProgressReportProc proc, void * context = 0, + float interval = 1.0, bool sendStartStop = false ); + + /// @} + + // ============================================================================================= + // Error notifications + // =================== + + // --------------------------------------------------------------------------------------------- + /// \name Error notifications + /// @{ + /// + /// From the beginning through version 5.5, XMP Toolkit errors result in throwing an \c XMP_Error + /// exception. For the most part exceptions were thrown early and thus API calls aborted as soon + /// as an error was detected. Starting in version 5.5, support has been added for notifications + /// of errors arising in calls to \c TXMPFiles functions. + /// + /// A client can register an error notification callback function for a \c TXMPFile object. This + /// can be done as a global default or individually to each object. The global default applies + /// to all objects created after it is registered. Within the object there is no difference + /// between the global default or explicitly registered callback. The callback function returns + /// a \c bool value indicating if recovery should be attempted (true) or an exception thrown + /// (false). If no callback is registered, a best effort at recovery and continuation will be + /// made with an exception thrown if recovery is not possible. + /// + /// The number of notifications delivered for a given TXMPFiles object can be limited. This is + /// intended to reduce chatter from multiple or cascading errors. The limit is set when the + /// callback function is registered. This limits the number of notifications of the highest + /// severity delivered or less. If a higher severity error occurs, the counting starts again. + /// The limit and counting can be reset at any time, see \c ResetErrorCallbackLimit. + + // -------------------------------------------------------------------------------------------- + /// @brief SetDefaultErrorCallback() registers a global default error notification callback. + /// + /// @param proc The client's callback function. + /// + /// @param context Client-provided context for the callback. + /// + /// @param limit A limit on the number of notifications to be delivered. + + static void SetDefaultErrorCallback ( XMPFiles_ErrorCallbackProc proc, void* context = 0, XMP_Uns32 limit = 1 ); + + // -------------------------------------------------------------------------------------------- + /// @brief SetErrorCallback() registers an error notification callback. + /// + /// @param proc The client's callback function. + /// + /// @param context Client-provided context for the callback. + /// + /// @param limit A limit on the number of notifications to be delivered. + + void SetErrorCallback ( XMPFiles_ErrorCallbackProc proc, void* context = 0, XMP_Uns32 limit = 1 ); + + // -------------------------------------------------------------------------------------------- + /// @brief ResetErrorCallbackLimit() resets the error notification limit and counting. It has no + /// effect if an error notification callback function is not registered. + /// + /// @param limit A limit on the number of notifications to be delivered. + + void ResetErrorCallbackLimit ( XMP_Uns32 limit = 1 ); + + /// @} + + // ============================================================================================= private: - XMPFilesRef xmpFilesRef; + XMPFilesRef xmpFilesRef; - static void SetClientString ( void * clientPtr, XMP_StringPtr valuePtr, XMP_StringLen valueLen ); + // These are used as callbacks from the library code to the client when returning values that + // involve heap allocations. This ensures the allocations occur within the client. + static void SetClientString ( void * clientPtr, XMP_StringPtr valuePtr, XMP_StringLen valueLen ); + static void SetClientStringVector ( void * clientPtr, XMP_StringPtr* arrayPtr, XMP_Uns32 stringCount ); -}; // class TXMPFiles +}; // class TXMPFiles // ================================================================================================= diff --git a/public/include/TXMPMeta.hpp b/public/include/TXMPMeta.hpp index f87ce82..57aa62a 100644 --- a/public/include/TXMPMeta.hpp +++ b/public/include/TXMPMeta.hpp @@ -100,7 +100,7 @@ public: // ============================================================================================= // Constuctors and destructor - // ========================= + // ========================== // --------------------------------------------------------------------------------------------- /// \name Constructors and destructor @@ -1675,6 +1675,65 @@ public: /// @} // ============================================================================================= + // Error notifications + // =================== + + // --------------------------------------------------------------------------------------------- + /// \name Error notifications + /// @{ + /// + /// From the beginning through version 5.5, XMP Tookit errors result in throwing an \c XMP_Error + /// exception. For the most part exceptions were thrown early and thus API calls aborted as soon + /// as an error was detected. Starting in version 5.5, support has been added for notifications + /// of errors arising in calls to \c TXMPMeta functions. + /// + /// A client can register an error notification callback function for a \c TXMPMeta object. This + /// can be done as a global default or individually to each object. The global default applies + /// to all objects created after it is registered. Within the object there is no difference + /// between the global default or explicitly registered callback. The callback function returns + /// a \c bool value indicating if recovery should be attempted (true) or an exception thrown + /// (false). If no callback is registered, a best effort at recovery and continuation will be + /// made with an exception thrown if recovery is not possible. + /// + /// The number of notifications delivered for a given TXMPMeta object can be limited. This is + /// intended to reduce chatter from multiple or cascading errors. The limit is set when the + /// callback function is registered. This limits the number of notifications of the highest + /// severity delivered or less. If a higher severity error occurs, the counting starts again. + /// The limit and counting can be reset at any time, see \c ResetErrorCallbackLimit. + + // -------------------------------------------------------------------------------------------- + /// @brief SetDefaultErrorCallback() registers a global default error notification callback. + /// + /// @param proc The client's callback function. + /// + /// @param context Client-provided context for the callback. + /// + /// @param limit A limit on the number of notifications to be delivered. + + static void SetDefaultErrorCallback ( XMPMeta_ErrorCallbackProc proc, void* context = 0, XMP_Uns32 limit = 1 ); + + // -------------------------------------------------------------------------------------------- + /// @brief SetErrorCallback() registers an error notification callback. + /// + /// @param proc The client's callback function. + /// + /// @param context Client-provided context for the callback. + /// + /// @param limit A limit on the number of notifications to be delivered. + + void SetErrorCallback ( XMPMeta_ErrorCallbackProc proc, void* context = 0, XMP_Uns32 limit = 1 ); + + // -------------------------------------------------------------------------------------------- + /// @brief ResetErrorCallbackLimit() resets the error notification limit and counting. It has no + /// effect if an error notification callback function is not registered. + /// + /// @param limit A limit on the number of notifications to be delivered. + + void ResetErrorCallbackLimit ( XMP_Uns32 limit = 1 ); + + /// @} + + // ============================================================================================= XMPMetaRef xmpRef; // *** Should be private, see below. diff --git a/public/include/XMP_Const.h b/public/include/XMP_Const.h index 4e4ccde..0bb5958 100644 --- a/public/include/XMP_Const.h +++ b/public/include/XMP_Const.h @@ -13,7 +13,7 @@ #include <stddef.h> -#if XMP_MacBuild // ! No stdint.h on Windows and some UNIXes. +#if XMP_MacBuild | XMP_iOSBuild // ! No stdint.h on Windows and some UNIXes. #include <stdint.h> #endif #if XMP_UNIXBuild // hopefully an inttypes.h on all UNIXes... @@ -38,7 +38,7 @@ extern "C" { // case only the declarations of the XMP_... types needs to change, not all of the uses. These // types are used where fixed sizes are required in order to have a known ABI for a DLL build. -#if XMP_MacBuild +#if XMP_MacBuild | XMP_iOSBuild typedef int8_t XMP_Int8; typedef int16_t XMP_Int16; @@ -92,12 +92,17 @@ extern "C" { #else - #error "XMP environment error - must define one of XMP_MacBuild, XMP_WinBuild, or XMP_UNIXBuild" + #error "XMP environment error - must define one of XMP_MacBuild, XMP_WinBuild, XMP_UNIXBuild or XMP_iOSBuild" #endif typedef XMP_Uns8 XMP_Bool; +const XMP_Uns8 kXMP_Bool_False = 0; + +#define ConvertXMP_BoolToBool(a) (a) != kXMP_Bool_False +#define ConvertBoolToXMP_Bool(a) (a) ? !kXMP_Bool_False : kXMP_Bool_False + /// An "ABI safe" pointer to the internal part of an XMP object. Use to pass an XMP object across /// client DLL boundaries. See \c TXMPMeta::GetInternalRef(). typedef struct __XMPMeta__ * XMPMetaRef; @@ -896,6 +901,8 @@ enum { kXMP_WMAVFile = 0x574D4156UL, /// Public file format constant: 'AIFF' kXMP_AIFFFile = 0x41494646UL, + /// Public file format constant: 'RED ', RED file format + kXMP_REDFile = 0x52454420UL, /// Public file format constant: 'P2 ', a collection not really a single file kXMP_P2File = 0x50322020UL, /// Public file format constant: 'XDCF', a collection not really a single file @@ -1106,7 +1113,13 @@ enum { kXMPFiles_UsesSidecarXMP = 0x00000800, /// The format is folder oriented, for example the P2 video format. - kXMPFiles_FolderBasedFormat = 0x00001000 + kXMPFiles_FolderBasedFormat = 0x00001000, + + /// The file Handler is capable of notifying progress notifications + kXMPFiles_CanNotifyProgress = 0x00002000, + + /// The plugin handler is not capable for delay loading + kXMPFiles_NeedsPreloading = 0x00004000 }; @@ -1149,14 +1162,25 @@ enum { }; // ================================================================================================= -// Exception codes -// =============== +// Error notification and Exceptions +// ================================= -/// \name Errors Exception handling +/// \name Error notification and Exceptions /// @{ /// -/// XMP Tookit errors result in throwing an \c XMP_Error exception. Any exception thrown within the -/// XMP Toolkit is caught in the toolkit and rethrown as an \c XMP_Error. +/// From the beginning through version 5.5, XMP Tookit errors result in throwing an \c XMP_Error +/// exception. For the most part exceptions were thrown early and thus API calls aborted as soon as +/// an error was detected. Starting in version 5.5, support has been added for notifications of +/// errors arising in calls to \c TXMPMeta and \c TXMPFiles functions. +/// +/// A client can register an error notification callback function for a \c TXMPMeta or \c TXMPFiles +/// object. This can be done as a global default or individually to each object. The global default +/// applies to all objects created after it is registered. Within the object there is no difference +/// between the global default or explicitly registered callback. The callback function returns a +/// \c bool value indicating if recovery should be attempted (true) or an exception thrown (false). +/// If no callback is registered, a best effort at recovery and continuation will be made with an +/// exception thrown if recovery is not possible. More details can be found in the \c TXMPMeta and +/// \c TXMPFiles documentation. /// /// The \c XMP_Error class contains a numeric code and an English explanation. New numeric codes may /// be added at any time. There are typically many possible explanations for each numeric code. The @@ -1164,7 +1188,93 @@ enum { /// /// \note The explanation string is for debugging use only. It must not be shown to users in a /// final product. It is written for developers not users, and never localized. + +typedef XMP_Uns8 XMP_ErrorSeverity; + +/// Severity codes for error notifications +enum { + /// Partial recovery and continuation is possible. + kXMPErrSev_Recoverable = 0, + /// Recovery is not possible, an exception will be thrown aborting the API call. + kXMPErrSev_OperationFatal = 1, + /// Recovery is not possible, an exception will be thrown, the file is corrupt and possibly unusable. + kXMPErrSev_FileFatal = 2, + /// Recovery is not possible, an exception will be thrown, the entire process should be aborted. + kXMPErrSev_ProcessFatal = 3 +}; + +// ------------------------------------------------------------------------------------------------- +/// The signature of a client-defined callback for TXMPMeta error notifications. +/// +/// @param context A pointer used to carry client-private context. /// +/// @param severity The severity of the error, see the \c XMP_ErrorSeverity values. +/// +/// @param cause A numeric code for the cause of the error, from the XMP_Error exception codes. +/// Codes used with TXMPMeta error notifications: +/// \li \c kXMPErr_BadXML - An XML syntax error found during parsing. +/// \li \c kXMPErr_BadRDF - A syntax or semantic parsing error in the XMP subset of RDF. +/// \li \c kXMPErr_BadXMP - A semantic XMP data model error. +/// \li \c kXMPErr_BadValue - An XMP value error, wrong type, out of range, etc. +/// \li \c kXMPErr_NoMemory - A heap allocation failure. +/// +/// @param message An explanation of the error, for debugging use only. This should not be displayed +/// to users in a final product. +/// +/// @return True if the operation should continue with a best effort attempt at recovery, false if +/// it should be aborted with an exception thrown from the library back to the original caller. +/// Recovery is possible only if the severity is kXMPErrSev_Recoverable, an exception will be +/// thrown on return from the callback in all other cases. +/// +/// @see \c TXMPMeta::SetDefaultErrorCallback() and \c TXMPMeta::SetErrorCallback() + +typedef bool (* XMPMeta_ErrorCallbackProc) ( void* context, XMP_ErrorSeverity severity, XMP_Int32 cause, XMP_StringPtr message ); + +// ------------------------------------------------------------------------------------------------- +/// The signature of a client-defined callback for TXMPFiles error notifications. +/// +/// @param context A pointer used to carry client-private context. +/// +/// @param filePath The path for the file involved in the error. +/// +/// @param severity The severity of the error, see the \c XMP_ErrorSeverity values. +/// +/// @param cause A numeric code for the cause of the error, from the XMP_Error exception codes. +/// Codes used with TXMPFiles error notifications: +/// \li \c kXMPErr_NoFile - A file does not exist +/// \li \c kXMPErr_FilePermission - A file exists but cannot be opened +/// \li \c kXMPErr_FilePathNotAFile - A path exists which is not a file +/// \li \c dXMPErr_RejectedFileExtension - Any Operation called on rejected file extension +/// \li \c KXMPErr_NoFileHandler - No suitable handler is found for the file +/// \li \c kXMPErr_DiskSpace - A file write fails due to lack of disk space +/// \li \c kXMPErr_ReadError - A file read fails +/// \li \c kXMPErr_WriteError - A file write fails for some other reason than space +/// \li \c kXMPErr_BadFileFormat - A file is corrupt or ill-formed +/// \li \c kXMPErr_BadBlockFormat - A portion of a file is corrupt or ill-formed +/// \li \c kXMPErr_BadValue - An XMP or non-XMP metadata item has an invalid value +/// \li \c kXMPErr_NoMemory - A heap allocation failure +/// +/// @param message An explanation of the error, for debugging use only. This should not be displayed +/// to users in a final product. +/// +/// @return True if the operation should continue with a best effort attempt at recovery, false if +/// it should be aborted with an exception thrown from the library back to the original caller. +/// Recovery is possible only if the severity is kXMPErrSev_Recoverable, an exception will be +/// thrown on return from the callback in all other cases. +/// +/// @see \c TXMPFiles::SetDefaultErrorCallback() and \c TXMPFiles::SetErrorCallback() + +typedef bool (* XMPFiles_ErrorCallbackProc) ( void* context, XMP_StringPtr filePath, XMP_ErrorSeverity severity, XMP_Int32 cause, XMP_StringPtr message ); + +// ------------------------------------------------------------------------------------------------- +/// Internal: The signatures of client-side wrappers for the error notification callbacks. + +typedef XMP_Bool (* XMPMeta_ErrorCallbackWrapper) ( XMPMeta_ErrorCallbackProc clientProc, void* context, + XMP_ErrorSeverity severity, XMP_Int32 cause, XMP_StringPtr message ); + +typedef XMP_Bool (* XMPFiles_ErrorCallbackWrapper) ( XMPFiles_ErrorCallbackProc clientProc, void* context, + XMP_StringPtr filePath, XMP_ErrorSeverity severity, + XMP_Int32 cause, XMP_StringPtr message ); /// XMP Toolkit error, associates an error code with a descriptive error string. class XMP_Error { @@ -1176,7 +1286,7 @@ public: /// /// @param _errMsg The descriptive string, for debugging use only. It must not be shown to users /// in a final product. It is written for developers, not users, and never localized. - XMP_Error ( XMP_Int32 _id, XMP_StringPtr _errMsg ) : id(_id), errMsg(_errMsg) {}; + XMP_Error ( XMP_Int32 _id, XMP_StringPtr _errMsg ) : id(_id), errMsg(_errMsg), notified(false) {}; /// Retrieves the numeric code from an XMP_Error. inline XMP_Int32 GetID() const { return id; }; @@ -1184,22 +1294,30 @@ public: /// Retrieves the descriptive string from an XMP_Error. inline XMP_StringPtr GetErrMsg() const { return errMsg; }; + /// Retrieves the information whether particular error is notified or not + inline XMP_Bool IsNotified() const { return notified; } + + /// Sets the notification status for an error + inline void SetNotified() { notified = true; }; + private: /// Exception code. See constants \c #kXMPErr_Unknown and following. XMP_Int32 id; /// Descriptive string, for debugging use only. It must not be shown to users in a final /// product. It is written for developers, not users, and never localized. XMP_StringPtr errMsg; + /// Variable to store whether this particular error is notified to user or not + XMP_Bool notified; }; -/// Exception code constants +/// XMP_Error exception code constants enum { - // -------------------- - // Generic error codes. + // -------------------- + /// Generic error codes. /// No error - kXMPErr_NoError = -1, + kXMPErr_NoError = -1, /// Generic unknown error kXMPErr_Unknown = 0, @@ -1233,6 +1351,8 @@ enum { kXMPErr_UnknownException = 14, /// Generic out-of-memory error kXMPErr_NoMemory = 15, + /// Progress reporting callback requested abort + kXMPErr_ProgressAbort = 16, // ------------------------------------ // More specific parameter error codes. @@ -1247,7 +1367,7 @@ enum { kXMPErr_BadIndex = 104, /// Bad iteration position kXMPErr_BadIterPosition = 105, - /// XML parsing error + /// XML parsing error (deprecated) kXMPErr_BadParse = 106, /// Serialization error kXMPErr_BadSerialize = 107, @@ -1257,6 +1377,22 @@ enum { kXMPErr_NoFileHandler = 109, /// Data too large for JPEG file format kXMPErr_TooLargeForJPEG = 110, + /// A file does not exist + kXMPErr_NoFile = 111, + /// A file exists but cannot be opened + kXMPErr_FilePermission = 112, + /// A file write failed due to lack of disk space + kXMPErr_DiskSpace = 113, + /// A file read failed + kXMPErr_ReadError = 114, + /// A file write failed for a reason other than lack of disk space + kXMPErr_WriteError = 115, + /// A block of a file is ill-formed, e.g. invalid IPTC-IIM in a photo + kXMPErr_BadBlockFormat = 116, + /// File Path is not a file + kXMPErr_FilePathNotAFile = 117, + /// Rejected File extension + kXMPErr_RejectedFileExtension = 118, // ----------------------------------------------- // File format and internal structure error codes. @@ -1333,7 +1469,36 @@ typedef XMP_Status (* XMP_TextOutputProc) ( void * refCon, /// /// @see \c TXMPFiles::SetAbortProc() -typedef bool (* XMP_AbortProc) ( void * arg ); // Used by . +typedef bool (* XMP_AbortProc) ( void * arg ); + +// ------------------------------------------------------------------------------------------------- +/// The signature of a client-defined callback for progress report notifications. +/// +/// @param context A pointer used to carry client-private context. +/// +/// @param elapsedTime The time in seconds since the progress reporting started. +/// +/// @param fractionDone A float value estimating the amount of work already done, in the range of +/// 0.0 to 1.0. A value of 0.0 is given if the amount is not known, this happens if there is no +/// estimate total for the total work. The units of work are not defined, but should usually be +/// related to the number of bytes of I/O. This will go backwards if total work estimate changes. +/// +/// @param secondsToGo A float value estimating the number of seconds left to complete the file +/// operation. A value of 0.0 is given if the amount is not known, this happens if the amount of +/// total work is unknown. This can go backwards according to throughput or if work estimate changes. +/// +/// @return True if the file operation should continue, false if it should be aborted with an +/// exception being thrown from the XMPFiles library back to the original caller. +/// +/// @see \c TXMPFiles::SetDefaultProgressCallback() and \c TXMPFiles::SetProgressCallback() + +typedef bool (* XMP_ProgressReportProc) ( void * context, float elapsedTime, float fractionDone, float secondsToGo ); + +// ------------------------------------------------------------------------------------------------- +/// Internal: The signature of a client-side wrapper for the progress report callback. + +typedef XMP_Bool (* XMP_ProgressReportWrapper) ( XMP_ProgressReportProc proc, void * context, + float elapsedTime, float fractionDone, float secondsToGo ); /// @} @@ -1365,4 +1530,6 @@ typedef struct XMP_VersionInfo { } // extern "C" #endif +#include <vector> + #endif // __XMP_Const_h__ diff --git a/public/include/XMP_Environment.h b/public/include/XMP_Environment.h index de7d44a..b7765b7 100644 --- a/public/include/XMP_Environment.h +++ b/public/include/XMP_Environment.h @@ -22,7 +22,7 @@ // Determine the Platform // ====================== -// One of MAC_ENV, WIN_ENV, or UNIX_ENV must be defined by the client. Since some other code +// One of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV must be defined by the client. Since some other code // requires these to be defined without values, they are only used here to define XMP-specific // macros with 0 or 1 values. @@ -35,13 +35,14 @@ #error "MAC_ENV must be defined so that \"#if MAC_ENV\" is true" #endif - #if defined ( WIN_ENV ) || defined ( UNIX_ENV ) - #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, or UNIX_ENV" + #if defined ( WIN_ENV ) || defined ( UNIX_ENV ) || defined ( IOS_ENV ) + #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" #endif #define XMP_MacBuild 1 #define XMP_WinBuild 0 #define XMP_UNIXBuild 0 + #define XMP_iOSBuild 0 #elif defined ( WIN_ENV ) @@ -49,13 +50,14 @@ #error "WIN_ENV must be defined so that \"#if WIN_ENV\" is true" #endif - #if defined ( UNIX_ENV ) - #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, or UNIX_ENV" + #if defined ( MAC_ENV ) || defined ( UNIX_ENV ) || defined ( IOS_ENV ) + #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" #endif #define XMP_MacBuild 0 #define XMP_WinBuild 1 #define XMP_UNIXBuild 0 + #define XMP_iOSBuild 0 #elif defined ( UNIX_ENV ) @@ -63,13 +65,33 @@ #error "UNIX_ENV must be defined so that \"#if UNIX_ENV\" is true" #endif + #if defined ( MAC_ENV ) || defined ( WIN_ENV ) || defined ( IOS_ENV ) + #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" + #endif + #define XMP_MacBuild 0 #define XMP_WinBuild 0 #define XMP_UNIXBuild 1 + #define XMP_iOSBuild 0 + +#elif defined ( IOS_ENV ) + + #if 0 // ! maybe someday - ! IOS_ENV + #error "IOS_ENV must be defined so that \"#if IOS_ENV\" is true" + #endif + + #if defined ( MAC_ENV ) || defined ( WIN_ENV ) || defined ( UNIX_ENV ) + #error "XMP environment error - must define only one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" + #endif + + #define XMP_MacBuild 0 + #define XMP_WinBuild 0 + #define XMP_UNIXBuild 0 + #define XMP_iOSBuild 1 #else - #error "XMP environment error - must define one of MAC_ENV, WIN_ENV, or UNIX_ENV" + #error "XMP environment error - must define one of MAC_ENV, WIN_ENV, UNIX_ENV or IOS_ENV" #endif @@ -96,6 +118,10 @@ #include <stdio.h> // The assert macro needs printf. #endif +#ifndef DISABLE_SERIALIZED_IMPORT_EXPORT + #define DISABLE_SERIALIZED_IMPORT_EXPORT 0 +#endif + #ifndef XMP_64 #if _WIN64 || defined(_LP64) #define XMP_64 1 diff --git a/public/include/XMP_Version.h b/public/include/XMP_Version.h index b0e7e0e..53707b1 100644 --- a/public/include/XMP_Version.h +++ b/public/include/XMP_Version.h @@ -34,18 +34,18 @@ versions. /* ============================================================================================= */ #define XMPCORE_API_VERSION_MAJOR 5 -#define XMPCORE_API_VERSION_MINOR 4 +#define XMPCORE_API_VERSION_MINOR 5 #define XMPCORE_API_VERSION_MICRO 0 -#define XMPCORE_API_VERSION 5.4.0 -#define XMPCORE_API_VERSION_STRING "5.4.0" +#define XMPCORE_API_VERSION 5.5.0 +#define XMPCORE_API_VERSION_STRING "5.5.0" #define XMPFILES_API_VERSION_MAJOR 5 -#define XMPFILES_API_VERSION_MINOR 5 +#define XMPFILES_API_VERSION_MINOR 6 #define XMPFILES_API_VERSION_MICRO 0 -#define XMPFILES_API_VERSION 5.5.0 -#define XMPFILES_API_VERSION_STRING "5.5.0" +#define XMPFILES_API_VERSION 5.6.0 +#define XMPFILES_API_VERSION_STRING "5.6.0" /* ============================================================================================= */ diff --git a/public/include/client-glue/TXMPFiles.incl_cpp b/public/include/client-glue/TXMPFiles.incl_cpp index f424f10..eb19887 100644 --- a/public/include/client-glue/TXMPFiles.incl_cpp +++ b/public/include/client-glue/TXMPFiles.incl_cpp @@ -55,6 +55,19 @@ SetClientString ( void * clientPtr, XMP_StringPtr valuePtr, XMP_StringLen valueL // ------------------------------------------------------------------------------------------------- XMP_MethodIntro(TXMPFiles,void):: +SetClientStringVector ( void * clientPtr, XMP_StringPtr * arrayPtr, XMP_Uns32 stringCount ) +{ + std::vector<tStringObj>* clientVec = (std::vector<tStringObj>*) clientPtr; + clientVec->clear(); + for ( XMP_Uns32 i = 0; i < stringCount; ++i ) { + tStringObj nextValue ( arrayPtr[i] ); + clientVec->push_back ( nextValue ); + } +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: GetVersionInfo ( XMP_VersionInfo * versionInfo ) { WrapNoCheckVoid ( zXMPFiles_GetVersionInfo_1 ( versionInfo ) ); @@ -259,9 +272,43 @@ GetFileModDate ( XMP_StringPtr filePath, XMP_DateTime * modDate, XMP_FileFormat // ------------------------------------------------------------------------------------------------- XMP_MethodIntro(TXMPFiles,bool):: +GetAssociatedResources ( XMP_StringPtr filePath, + std::vector<tStringObj>* resourceList, + XMP_FileFormat format /* = kXMP_UnknownFile */, + XMP_OptionBits options /* = 0 */) +{ + WrapCheckBool ( ok, zXMPFiles_GetAssociatedResources_1 ( filePath, resourceList, format, options, SetClientStringVector ) ); + return ok; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +IsMetadataWritable ( XMP_StringPtr filePath, + bool * writable, + XMP_FileFormat format /* = kXMP_UnknownFile */, + XMP_OptionBits options /* = 0 */) +{ + if ( writable) + { + XMP_Bool internalWritable = ConvertBoolToXMP_Bool( *writable ); + WrapCheckBool ( ok, zXMPFiles_IsMetadataWritable_1 ( filePath, &internalWritable, format, options ) ); + *writable = ConvertXMP_BoolToBool( internalWritable ); + return ok; + } + else + { + WrapCheckBool ( ok, zXMPFiles_IsMetadataWritable_1 ( filePath, NULL, format, options ) ); + return ok; + } +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: OpenFile ( XMP_StringPtr filePath, XMP_FileFormat format /* = kXMP_UnknownFile */, - XMP_OptionBits openFlags /* =0 */ ) + XMP_OptionBits openFlags /* = 0 */ ) { WrapCheckBool ( ok, zXMPFiles_OpenFile_1 ( filePath, format, openFlags ) ); return ok; @@ -272,7 +319,7 @@ OpenFile ( XMP_StringPtr filePath, XMP_MethodIntro(TXMPFiles,bool):: OpenFile ( const tStringObj & filePath, XMP_FileFormat format /* = kXMP_UnknownFile */, - XMP_OptionBits openFlags /* =0 */ ) + XMP_OptionBits openFlags /* = 0 */ ) { return this->OpenFile ( filePath.c_str(), format, openFlags ); } @@ -283,7 +330,7 @@ OpenFile ( const tStringObj & filePath, XMP_MethodIntro(TXMPFiles,bool):: OpenFile ( XMP_IO * clientIO, XMP_FileFormat format /* = kXMP_UnknownFile */, - XMP_OptionBits openFlags /* =0 */ ) + XMP_OptionBits openFlags /* = 0 */ ) { WrapCheckBool ( ok, zXMPFiles_OpenFile_2 ( clientIO, format, openFlags ) ); return ok; @@ -293,7 +340,7 @@ OpenFile ( XMP_IO * clientIO, // ------------------------------------------------------------------------------------------------- XMP_MethodIntro(TXMPFiles,void):: -CloseFile ( XMP_OptionBits closeFlags /* =0 */ ) +CloseFile ( XMP_OptionBits closeFlags /* = 0 */ ) { WrapCheckVoid ( zXMPFiles_CloseFile_1 ( closeFlags ) ); } @@ -302,9 +349,9 @@ CloseFile ( XMP_OptionBits closeFlags /* =0 */ ) XMP_MethodIntro(TXMPFiles,bool):: GetFileInfo ( tStringObj * filePath /* = 0 */, - XMP_OptionBits * openFlags /* =0 */, + XMP_OptionBits * openFlags /* = 0 */, XMP_FileFormat * format /* = 0 */, - XMP_OptionBits * handlerFlags /* =0 */ ) + XMP_OptionBits * handlerFlags /* = 0 */ ) { WrapCheckBool ( isOpen, zXMPFiles_GetFileInfo_1 ( filePath, openFlags, format, handlerFlags, SetClientString ) ); return isOpen; @@ -324,7 +371,7 @@ SetAbortProc ( XMP_AbortProc abortProc, XMP_MethodIntro(TXMPFiles,bool):: GetXMP ( SXMPMeta * xmpObj /* = 0 */, tStringObj * xmpPacket /* = 0 */, - XMP_PacketInfo * packetInfo /* =0 */ ) + XMP_PacketInfo * packetInfo /* = 0 */ ) { XMPMetaRef xmpRef = 0; if ( xmpObj != 0 ) { @@ -389,3 +436,49 @@ CanPutXMP ( const tStringObj & xmpPacket ) } // ================================================================================================= + +XMP_MethodIntro(TXMPFiles,void):: +SetDefaultProgressCallback ( XMP_ProgressReportProc proc, void * context /* = 0 */, + float interval /* = 1.0 */, bool sendStartStop /* = false */ ) +{ + XMP_Bool internalsendStartStop = ConvertBoolToXMP_Bool( sendStartStop ); + WrapCheckVoid ( zXMPFiles_SetDefaultProgressCallback_1 ( proc, context, interval, internalsendStartStop ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +SetProgressCallback ( XMP_ProgressReportProc proc, void * context /* = 0 */, + float interval /* = 1.0 */, bool sendStartStop /* = false */ ) +{ + XMP_Bool internalsendStartStop = ConvertBoolToXMP_Bool( sendStartStop ); + WrapCheckVoid ( zXMPFiles_SetProgressCallback_1 ( proc, context, interval, internalsendStartStop ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +SetDefaultErrorCallback ( XMPFiles_ErrorCallbackProc proc, + void * context /* = 0 */, XMP_Uns32 limit /*= 1 */ ) +{ + WrapCheckVoid ( zXMPFiles_SetDefaultErrorCallback_1 ( proc, context, limit ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +SetErrorCallback ( XMPFiles_ErrorCallbackProc proc, + void * context /* = 0 */, XMP_Uns32 limit /*= 1 */ ) +{ + WrapCheckVoid ( zXMPFiles_SetErrorCallback_1 ( proc, context, limit ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +ResetErrorCallbackLimit ( XMP_Uns32 limit /* = 1 */ ) +{ + WrapCheckVoid ( zXMPFiles_ResetErrorCallbackLimit_1 ( limit ) ); +} + +// ================================================================================================= diff --git a/public/include/client-glue/TXMPMeta.incl_cpp b/public/include/client-glue/TXMPMeta.incl_cpp index 5bcbd91..098355a 100644 --- a/public/include/client-glue/TXMPMeta.incl_cpp +++ b/public/include/client-glue/TXMPMeta.incl_cpp @@ -108,7 +108,8 @@ Initialize() XMP_TypeCheck ( (sizeof(XMP_Uns16) == 2), "Size wrong for critical type XMP_Uns16" ); XMP_TypeCheck ( (sizeof(XMP_Uns32) == 4), "Size wrong for critical type XMP_Uns32" ); XMP_TypeCheck ( (sizeof(XMP_Uns64) == 8), "Size wrong for critical type XMP_Uns64" ); - + XMP_TypeCheck ( (sizeof(XMP_Bool) == 1), "Size wrong for critical type XMP_Bool" ); + #if XMP_TraceClientCallsToFile xmpClientLog = fopen ( "XMPClientLog.txt", "w" ); if ( xmpClientLog == 0 ) xmpClientLog = stderr; @@ -868,4 +869,32 @@ SerializeToBuffer ( tStringObj * pktString, // ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetDefaultErrorCallback ( XMPMeta_ErrorCallbackProc proc, + void * context /* = 0 */, + XMP_Uns32 limit /* = 1 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetDefaultErrorCallback_1 ( proc, context, limit ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetErrorCallback ( XMPMeta_ErrorCallbackProc proc, + void * context /* = 0 */, + XMP_Uns32 limit /* = 1 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetErrorCallback_1 ( proc, context, limit ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +ResetErrorCallbackLimit ( XMP_Uns32 limit /* = 1 */ ) +{ + WrapCheckVoid ( zXMPMeta_ResetErrorCallbackLimit_1 ( limit ) ); +} + // ================================================================================================= diff --git a/public/include/client-glue/TXMPUtils.incl_cpp b/public/include/client-glue/TXMPUtils.incl_cpp index fd406e2..2cd5bae 100644 --- a/public/include/client-glue/TXMPUtils.incl_cpp +++ b/public/include/client-glue/TXMPUtils.incl_cpp @@ -130,7 +130,12 @@ ConvertFromInt ( long binValue, XMP_StringPtr format, tStringObj * strValue ) { - WrapCheckVoid ( zXMPUtils_ConvertFromInt_1 ( binValue, format, strValue, SetClientString ) ); + #if XMP_MacBuild & XMP_64 // This is checked because on Mac 64 bit environment, long is of 64 bit and hence gives a warning during implicit + // typecasting to XMP_Int32. Now doing it explicitly in that case. + WrapCheckVoid ( zXMPUtils_ConvertFromInt_1 ( (XMP_Int32)binValue, format, strValue, SetClientString ) ); + #else + WrapCheckVoid ( zXMPUtils_ConvertFromInt_1 ( binValue, format, strValue, SetClientString ) ); + #endif } // ------------------------------------------------------------------------------------------------- diff --git a/public/include/client-glue/WXMPFiles.hpp b/public/include/client-glue/WXMPFiles.hpp index 5cb7d0b..648a842 100644 --- a/public/include/client-glue/WXMPFiles.hpp +++ b/public/include/client-glue/WXMPFiles.hpp @@ -36,6 +36,32 @@ extern "C" { PropagateException ( wResult ); \ XMPFilesRef result = XMPFilesRef(wResult.ptrResult) +static XMP_Bool WrapProgressReport ( XMP_ProgressReportProc proc, void * context, + float elapsedTime, float fractionDone, float secondsToGo ) +{ + bool ok; + try { + ok = (*proc) ( context, elapsedTime, fractionDone, secondsToGo ); + } catch ( ... ) { + ok = false; + } + return ConvertBoolToXMP_Bool( ok ); +} + +// ================================================================================================= + +static XMP_Bool WrapFilesErrorNotify ( XMPFiles_ErrorCallbackProc proc, void * context, + XMP_StringPtr filePath, XMP_ErrorSeverity severity, XMP_Int32 cause, XMP_StringPtr message ) +{ + bool ok; + try { + ok = (*proc) ( context, filePath, severity, cause, message ); + } catch ( ... ) { + ok = false; + } + return ConvertBoolToXMP_Bool( ok ); +} + // ================================================================================================= #define zXMPFiles_GetVersionInfo_1(versionInfo) \ @@ -65,6 +91,12 @@ extern "C" { #define zXMPFiles_GetFileModDate_1(filePath,modDate,format,options) \ WXMPFiles_GetFileModDate_1 ( filePath, modDate, format, options, &wResult ) +#define zXMPFiles_GetAssociatedResources_1( filePath, resourceList, format, options, SetClientStringVector ) \ + WXMPFiles_GetAssociatedResources_1 ( filePath, resourceList, format, options, SetClientStringVector, &wResult ) + +#define zXMPFiles_IsMetadataWritable_1( filePath, writable, format, options ) \ + WXMPFiles_IsMetadataWritable_1 ( filePath, writable, format, options, &wResult ) + #define zXMPFiles_OpenFile_1(filePath,format,openFlags) \ WXMPFiles_OpenFile_1 ( this->xmpFilesRef, filePath, format, openFlags, &wResult ) @@ -91,6 +123,21 @@ extern "C" { #define zXMPFiles_CanPutXMP_1(xmpRef,xmpPacket,xmpPacketLen) \ WXMPFiles_CanPutXMP_1 ( this->xmpFilesRef, xmpRef, xmpPacket, xmpPacketLen, &wResult ) +#define zXMPFiles_SetDefaultProgressCallback_1(proc,context,interval,sendStartStop) \ + WXMPFiles_SetDefaultProgressCallback_1 ( WrapProgressReport, proc, context, interval, sendStartStop, &wResult ) + +#define zXMPFiles_SetProgressCallback_1(proc,context,interval,sendStartStop) \ + WXMPFiles_SetProgressCallback_1 ( this->xmpFilesRef, WrapProgressReport, proc, context, interval, sendStartStop, &wResult ) + +#define zXMPFiles_SetDefaultErrorCallback_1(proc,context,limit) \ + WXMPFiles_SetDefaultErrorCallback_1 ( WrapFilesErrorNotify, proc, context, limit, &wResult ) + +#define zXMPFiles_SetErrorCallback_1(proc,context,limit) \ + WXMPFiles_SetErrorCallback_1 ( this->xmpFilesRef, WrapFilesErrorNotify, proc, context, limit, &wResult ) + +#define zXMPFiles_ResetErrorCallbackLimit_1(limit) \ + WXMPFiles_ResetErrorCallbackLimit_1 ( this->xmpFilesRef, limit, &wResult ) + // ================================================================================================= extern void WXMPFiles_GetVersionInfo_1 ( XMP_VersionInfo * versionInfo ); @@ -127,6 +174,20 @@ extern void WXMPFiles_GetFileModDate_1 ( XMP_StringPtr filePath, XMP_OptionBits options, WXMP_Result * result ); + +extern void WXMPFiles_GetAssociatedResources_1 ( XMP_StringPtr filePath, + void * resourceList, + XMP_FileFormat format, + XMP_OptionBits options, + SetClientStringVectorProc SetClientStringVector, + WXMP_Result * result ); + +extern void WXMPFiles_IsMetadataWritable_1 ( XMP_StringPtr filePath, + XMP_Bool * writable, + XMP_FileFormat format, + XMP_OptionBits options, + WXMP_Result * result ); + extern void WXMPFiles_OpenFile_1 ( XMPFilesRef xmpFilesRef, XMP_StringPtr filePath, XMP_FileFormat format, @@ -177,6 +238,40 @@ extern void WXMPFiles_CanPutXMP_1 ( XMPFilesRef xmpFilesRef, XMP_StringLen xmpPacketLen, WXMP_Result * result ); +extern void WXMPFiles_SetDefaultProgressCallback_1 ( XMP_ProgressReportWrapper wrapperproc, + XMP_ProgressReportProc clientProc, + void * context, + float interval, + XMP_Bool sendStartStop, + WXMP_Result * result ); + +extern void WXMPFiles_SetProgressCallback_1 ( XMPFilesRef xmpFilesRef, + XMP_ProgressReportWrapper wrapperproc, + XMP_ProgressReportProc clientProc, + void * context, + float interval, + XMP_Bool sendStartStop, + WXMP_Result * result ); + +// ------------------------------------------------------------------------------------------------- + +extern void WXMPFiles_SetDefaultErrorCallback_1 ( XMPFiles_ErrorCallbackWrapper wrapperProc, + XMPFiles_ErrorCallbackProc clientProc, + void * context, + XMP_Uns32 limit, + WXMP_Result * wResult ); + +extern void WXMPFiles_SetErrorCallback_1 ( XMPFilesRef xmpRef, + XMPFiles_ErrorCallbackWrapper wrapperProc, + XMPFiles_ErrorCallbackProc clientProc, + void * context, + XMP_Uns32 limit, + WXMP_Result * wResult ); + +extern void WXMPFiles_ResetErrorCallbackLimit_1 ( XMPFilesRef xmpRef, + XMP_Uns32 limit, + WXMP_Result * wResult ); + // ================================================================================================= #if __cplusplus diff --git a/public/include/client-glue/WXMPMeta.hpp b/public/include/client-glue/WXMPMeta.hpp index fa8663e..b51ffa1 100644 --- a/public/include/client-glue/WXMPMeta.hpp +++ b/public/include/client-glue/WXMPMeta.hpp @@ -15,6 +15,22 @@ extern "C" { #endif +// ================================================================================================= + +static XMP_Bool WrapErrorNotify ( XMPMeta_ErrorCallbackProc proc, void * context, + XMP_ErrorSeverity severity, XMP_Int32 cause, XMP_StringPtr message ) +{ + bool ok; + try { + ok = (*proc) ( context, severity, cause, message ); + } catch ( ... ) { + ok = false; + } + return ConvertBoolToXMP_Bool( ok ); +} + +// ================================================================================================= + #define zXMPMeta_GetVersionInfo_1(info) \ WXMPMeta_GetVersionInfo_1 ( info /* no wResult */ ) @@ -169,6 +185,15 @@ extern "C" { #define zXMPMeta_SerializeToBuffer_1(pktString,options,padding,newline,indent,baseIndent,SetClientString) \ WXMPMeta_SerializeToBuffer_1 ( this->xmpRef, pktString, options, padding, newline, indent, baseIndent, SetClientString, &wResult ) +#define zXMPMeta_SetDefaultErrorCallback_1(proc,context,limit) \ + WXMPMeta_SetDefaultErrorCallback_1 ( WrapErrorNotify, proc, context, limit, &wResult ) + +#define zXMPMeta_SetErrorCallback_1(proc,context,limit) \ + WXMPMeta_SetErrorCallback_1 ( this->xmpRef, WrapErrorNotify, proc, context, limit, &wResult ) + +#define zXMPMeta_ResetErrorCallbackLimit_1(limit) \ + WXMPMeta_ResetErrorCallbackLimit_1 ( this->xmpRef, limit, &wResult ) + // ================================================================================================= extern void @@ -565,6 +590,28 @@ WXMPMeta_SerializeToBuffer_1 ( XMPMetaRef xmpRef, SetClientStringProc SetClientString, WXMP_Result * wResult ) /* const */ ; +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_SetDefaultErrorCallback_1 ( XMPMeta_ErrorCallbackWrapper wrapperProc, + XMPMeta_ErrorCallbackProc clientProc, + void * context, + XMP_Uns32 limit, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SetErrorCallback_1 ( XMPMetaRef xmpRef, + XMPMeta_ErrorCallbackWrapper wrapperProc, + XMPMeta_ErrorCallbackProc clientProc, + void * context, + XMP_Uns32 limit, + WXMP_Result * wResult ); + +extern void +WXMPMeta_ResetErrorCallbackLimit_1 ( XMPMetaRef xmpRef, + XMP_Uns32 limit, + WXMP_Result * wResult ); + // ================================================================================================= #if __cplusplus diff --git a/public/include/client-glue/WXMP_Common.hpp b/public/include/client-glue/WXMP_Common.hpp index a43caef..abc3ccb 100644 --- a/public/include/client-glue/WXMP_Common.hpp +++ b/public/include/client-glue/WXMP_Common.hpp @@ -21,6 +21,7 @@ #define XMP_MethodIntro(Class,ResultType) template <class tStringObj> XMP_Inline ResultType Class<tStringObj> typedef void (* SetClientStringProc) ( void * clientPtr, XMP_StringPtr valuePtr, XMP_StringLen valueLen ); +typedef void (* SetClientStringVectorProc) ( void * clientPtr, XMP_StringPtr * arrayPtr, XMP_Uns32 stringCount ); struct WXMP_Result { XMP_StringPtr errMessage; |