diff options
author | Hubert Figuiere <hub@figuiere.net> | 2007-05-11 18:38:11 -0400 |
---|---|---|
committer | Hubert Figuiere <hub@figuiere.net> | 2007-05-11 18:38:11 -0400 |
commit | 9d7d7c3caac05db240692ad7e9196fcb7f5a1ce5 (patch) | |
tree | c6228d1abcad689137e764f63539effadaf1a662 /public/include |
Import of XMP SDK 4.1.1 as the start for openxmpadobe-4.1.1
Diffstat (limited to 'public/include')
-rw-r--r-- | public/include/TXMPFiles.hpp | 418 | ||||
-rw-r--r-- | public/include/TXMPIterator.hpp | 205 | ||||
-rw-r--r-- | public/include/TXMPMeta.hpp | 1599 | ||||
-rw-r--r-- | public/include/TXMPUtils.hpp | 845 | ||||
-rw-r--r-- | public/include/XMP.hpp | 98 | ||||
-rw-r--r-- | public/include/XMP.incl_cpp | 69 | ||||
-rw-r--r-- | public/include/XMP_Const.h | 913 | ||||
-rw-r--r-- | public/include/XMP_Environment.h | 121 | ||||
-rw-r--r-- | public/include/XMP_Version.h | 45 | ||||
-rw-r--r-- | public/include/client-glue/TXMPFiles.incl_cpp | 347 | ||||
-rw-r--r-- | public/include/client-glue/TXMPIterator.incl_cpp | 226 | ||||
-rw-r--r-- | public/include/client-glue/TXMPMeta.incl_cpp | 927 | ||||
-rw-r--r-- | public/include/client-glue/TXMPUtils.incl_cpp | 491 | ||||
-rw-r--r-- | public/include/client-glue/WXMPFiles.hpp | 155 | ||||
-rw-r--r-- | public/include/client-glue/WXMPIterator.hpp | 83 | ||||
-rw-r--r-- | public/include/client-glue/WXMPMeta.hpp | 610 | ||||
-rw-r--r-- | public/include/client-glue/WXMPUtils.hpp | 322 | ||||
-rw-r--r-- | public/include/client-glue/WXMP_Common.hpp | 110 |
18 files changed, 7584 insertions, 0 deletions
diff --git a/public/include/TXMPFiles.hpp b/public/include/TXMPFiles.hpp new file mode 100644 index 0000000..499dfb9 --- /dev/null +++ b/public/include/TXMPFiles.hpp @@ -0,0 +1,418 @@ +#ifndef __TXMPFiles_hpp__ +#define __TXMPFiles_hpp__ 1 + +#if ( ! __XMP_hpp__ ) + #error "Do not directly include, use XMP.hpp" +#endif + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file TXMPFiles.hpp +/// \brief API for access to the "main" metadata in a file. +/// +/// \c TXMPFiles provides the API for the Adobe XMP Toolkit's File Handler component. This provides +/// convenient access to the main, or document level, XMP for a file. The File Handler supports file +/// I/O, the XMP Toolkit Core supports manipulation of the XMP properties. The File Handler is +/// intended to eventually have smart, efficient support for all file formats for which the means to +/// embed XMP is defined in the XMP Specification. Where possible this support will allow injection +/// of XMP where none currently exists, expansion of XMP without regard to existing padding, and +/// reconciliation of the XMP and other legacy forms of metadata. +/// +///\c TXMPFiles is designed for use by clients interested in the metadata and not in the primary file +/// content. The Adobe Bridge application is a typical example. \c TXMPFiles is not intended to be +/// particulary appropriate for files authored by an application. I.e. those files for which the +/// application has explicit knowledge of the file format. +// ================================================================================================ + +// ================================================================================================ +/// \class TXMPFiles TXMPFiles.hpp +/// \brief API for access to the "main" metadata in a file. +/// +/// \c TXMPFiles provides the API for the Adobe XMP Toolkit's File Handler component. This provides +/// convenient access to the main, or document level, XMP for a file. The general model is to open +/// a file, read and write the metadata, then close the file. While open, portions of the file +/// might be maintained in RAM data structures. Memory usage can vary considerably depending on +/// file format and access options. The file may be opened for read-only or read-write access, with +/// typical exclusion for both modes. +/// +/// Errors result in the throw of an \c XMPError exception. +/// +/// The template is instantiated with a string object class. This allows a clean implementation +/// that provides two major benefits: output string storage is fully owned by the client and access +/// is fully thread safe. The template parameter, class \c tStringObj, is described in the XMP.hpp +/// umbrella header. +/// +/// To use TXMPFiles define TXMP_STRING_TYPE and XMP_INCLUDE_XMPFILES, then include the XMP.hpp +/// umbrella header: +/// \code +/// #define TXMP_STRING_TYPE std::string +/// #define XMP_INCLUDE_XMPFILES 1 +/// #include "XMP.hpp" +/// \endcode +// ================================================================================================ + +template <class tStringObj> +class TXMPFiles { + +public: + + // ============================================================================================ + /// \name Initialization and termination + /// @{ + /// \c SXMPFiles must be initialized before use and may be terminated when done. + + static void GetVersionInfo ( XMP_VersionInfo * versionInfo ); + + /// \brief \c Initialize must be called before using \c SXMPFiles. It returns a Boolean + /// success/failure value. + + static bool Initialize(); + static bool Initialize ( XMP_OptionBits options ); + + /// \brief \c Terminate may be called when done using \c SXMPFiles. It deallocates global data + /// structures created by \c Initialize. + + static void Terminate(); + + /// @} + + // ============================================================================================ + /// \name Constructors and destructor + /// @{ + /// The default constructor initializes an object that is associated with no file. The alternate + /// constructors call OpenFile. The destructor automatically calls CloseFile if necessary. + + /// \brief The default constructor initializes an object that is associated with no file. + + TXMPFiles(); + virtual ~TXMPFiles() throw(); + + /// \brief These alternate constructors call \c OpenFile. The second form is a trivial overload + /// that calls the first form passing \c filePath.c_str(). + + TXMPFiles ( XMP_StringPtr filePath, + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits openFlags = 0 ); + + TXMPFiles ( const tStringObj & filePath, + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits openFlags = 0 ); + + /// \brief The copy constructor and assignment operator increment an internal reference count, + /// they do not perform a deep copy. + + TXMPFiles ( const TXMPFiles<tStringObj> & original ); + + void operator= ( const TXMPFiles<tStringObj> & rhs ); + + /// \brief The "ref" constructor and \c GetInternalRef serve the same purpose as their analogs + /// in SXMPMeta, safely passing \c SXMPFiles references across DLL boundaries where the clients + /// might have used different string types when instantiating \c TXMPFiles. + + TXMPFiles ( XMPFilesRef xmpFilesObj ); + + XMPFilesRef GetInternalRef(); + + /// @} + + // ============================================================================================ + /// \name Static Functions + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief Determine the supported features for a given file format. + /// + /// The supported features can vary quite a bit among file formats, depending on both the + /// general capabilities of the format and the implementation of the handler for that format. + /// + /// \param format The format whose support flags are desired. + /// + /// \param handlerFlags A set of option bits showing the support for this format: + /// + /// \li kXMPFiles_CanInjectXMP - Can inject first-time XMP into an existing file. + /// \li kXMPFiles_CanExpand - Can expand XMP or other metadata in an existing file. + /// \li kXMPFiles_CanRewrite - Can copy one file to another, writing new metadata. + /// \li kXMPFiles_CanReconcile - Supports reconciliation between XMP and other forms. + /// \li kXMPFiles_AllowsOnlyXMP - Allows access to just the XMP, ignoring other forms. + /// \li kXMPFiles_ReturnsRawPacket - File handler returns raw XMP packet information and string. + /// \li kXMPFiles_ReturnsTNail - File handler returns native thumbnail information. + /// + /// The kXMPFiles_AllowsOnlyXMP flag is only meaningful if kXMPFiles_CanReconcile is set. + /// + /// If kXMPFiles_ReturnsRawPacket is set, the returned packet information might have an offset + /// of -1 to indicate an unknown offset. While all file handlers should be able to return the + /// raw packet, some might not know the offset of the packet within the file. This is typical + /// in cases where external libraries are used. These cases might not even allow return of the + /// raw packet. + /// + /// \result Returns true if the format has explicit "smart" support. Returns false if the format + /// is handled by the default packet scanning plus heuristics. + + static bool GetFormatInfo ( XMP_FileFormat format, + XMP_OptionBits * handlerFlags = 0 ); + + /// @} + + // ============================================================================================ + /// \name OpenFile, CloseFile, and related file-oriented operations + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief Open a file for metadata access. + /// + /// Opens a file for the requested forms of metadata access. Opening the file at a minimum + /// causes the raw XMP packet to be read from the file. If the file handler supports legacy + /// metadata reconciliation then legacy metadata will also be read, unless kXMPFiles_OpenOnlyXMP + /// is passed. If the file handler supports native thumbnails and kXMPFiles_OpenCacheTNail is + /// passed then the native thumbnail will also be cached. + /// + /// If the file is opened for read-only access (passing kXMPFiles_OpenForRead), then the disk + /// file itself will be closed after reading the data from it. The XMPFiles object will not be + /// "closed" though, it is still necessary to call CloseFile when finished using it. Other + /// methods (GetXMP, etc.) can only be used between the OpenFile and CloseFile calls. The XMPFiles + /// destructor will not call CloseFile, any pending updates will be lost. + /// + /// If the file is opened for update (passing kXMPFiles_OpenForUpdate), then the disk file remains + /// open until CloseFile is called. The disk file is only updated once, when Close file is called, + /// no matter how many calls are made to PutXMP. + /// + /// Ideally the XMP is not parsed and legacy reconciliation is not performed until GetXMP is + /// called. This is not guaranteed though, specific file handlers might do earlier parsing of + /// the XMP. This delayed parsing and the early disk file close for read-only access are + /// optimizations to help clients implementing file browsers. They can access the file briefly + /// and possibly display a thumbnail, then postpone more expensive XMP processing until later. + /// + /// \param filePath The UTF-8 path for the file, appropriate for the local OS. Overloads are + /// declared to pass the path as either a "const char *" or a string object. + /// + /// \param format The format of the file. If the format is unknown pass \c kXMP_UnknownFile and + /// the format will be determined from the file content. The first handler to check will be + /// guessed from the file's extension. Passing any other format value is generally just a hint + /// about what file handler to try first (instead of the one based on the extension). If the + /// kXMPFiles_OpenStrictly is set, then any format other than kXMP_UnknownFile requires that the + /// file actually be that format, an exception is thrown if not. + /// + /// \param openFlags A set of option bits describing the desired access. By default (zero) the + /// file is opened for read-only access and the format handler decides on the level of + /// reconciliation that will be performed. By default a best effort will be made to locate the + /// correct XMP and to reconcile XMP with other forms (if reconciliation is done). The option + /// \c kXMPFiles_OpenStrictly may be used to force more strict rules, resulting is exceptions for + /// errors. The definition of strictness is specific to each handler, there may be no difference. + /// + /// The defined openFlag bits are: + /// + /// \li kXMPFiles_OpenForRead - Open for read-only access. + /// \li kXMPFiles_OpenForUpdate - Open for reading and writing. + /// \li kXMPFiles_OpenOnlyXMP - Only the XMP is wanted, no reconciliation. + /// \li kXMPFiles_OpenCacheTNail - Cache thumbnail if possible, GetThumbnail will be called. + /// \li kXMPFiles_OpenStrictly - Be strict about locating XMP and reconciling with other forms. + /// \li kXMPFiles_OpenUseSmartHandler - Require the use of a smart handler. + /// \li kXMPFiles_OpenUsePacketScanning - Force packet scanning, don't use a smart handler. + /// + /// \result Returns true if the file is succesfully opened and attached to a file handler. + /// Returns false for "anticipated" problems, e.g. passing 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 ( const tStringObj & filePath, + XMP_FileFormat format = kXMP_UnknownFile, + XMP_OptionBits openFlags = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief Close an opened file. + /// + /// Performs any necessary output to the file and closes it. Files that are opened for update + /// are written to only when closing. + /// + /// \param closeFlags A set of bit flags for optional closing actions. + /// + /// The defined closeFlags bits are: + /// + /// \li kXMPFiles_UpdateSafely - Write into a temporary file then swap for crash safety. + + void CloseFile ( XMP_OptionBits closeFlags = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief Get basic information about an opened file. + /// + /// \param filePath If not null, returns the path passed to OpenFile. + /// + /// \param openFlags If not null, returns the flags passed to OpenFile. + /// + /// \param format If not null, returns the format of the file. + /// + /// \param handlerFlags If not null, returns the handler's capability flags. + /// + /// \result Returns true if a file is opened, false otherwise. This notion of "open" really means + /// that OpenFile has been called but CloseFile has not. The actual disk file might be closed in + /// the host file system sense, as explained for OpenFile. + + bool GetFileInfo ( tStringObj * filePath = 0, + XMP_OptionBits * openFlags = 0, + XMP_FileFormat * format = 0, + XMP_OptionBits * handlerFlags = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief Set the callback function used to check for a user signaled abort. + /// + /// \param abortProc The callback function used to check for a user signaled abort. It will be + /// called periodically to allow an abort of time consuming operations. The abort results in an + /// exception being thrown. The callback function should return true to signal an abort. + /// + /// \param abortArg An argument passed to the callback function. + + void SetAbortProc ( XMP_AbortProc abortProc, + void * abortArg ); + + /// @} + + // ============================================================================================ + /// \name Metadata Access Functions + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief Obtain the XMP. + /// + /// \c GetXMP is used to obtain the parsed XMP, and/or the raw XMP packet, and/or information + /// about the raw XMP packet. If all parameters are null it simply tells if XMP is present or + /// not. The options provided when the file was opened determine if reconciliation is done with + /// other forms of metadata. + /// + /// \param xmpObj If not null, returns the parsed XMP. + /// + /// \param xmpPacket If not null, returns the raw XMP packet as stored in the file. The encoding + /// of the packet is given in the packetInfo. The string will be empty if the low level file + /// handler does not provide the raw packet. + /// + /// \param packetInfo If not null, returns the location and form of the raw XMP in the file. The + /// charForm and writeable flag reflect the raw XMP in the file. The parsed XMP property values + /// are always UTF-8. The writeable flag is taken from the packet trailer, it is only relevant + /// for "format ignorant" writing. + /// + /// \note The packetInfo struct always reflects the state of the XMP in the file. The offset, + /// length, and character form will not change as a result of calling \c PutXMP unless the file + /// is also written. + /// + /// \note Some file handlers might not return location or contents of the raw packet string. + /// Check the \c kXMPFiles_ReturnsRawPacket bit returned by GetFormatInfo if you depend on this. + /// If the low level file handler does not provide the raw packet location then the offset and + /// length will both be 0, the charForm will be UTF-8, and the writeable flag will be false. + /// + /// \result Returns true if the file has XMP, false otherwise. + + bool GetXMP ( SXMPMeta * xmpObj = 0, + tStringObj * xmpPacket = 0, + XMP_PacketInfo * packetInfo = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief Obtain the native thumbnail. + /// + /// \c GetThumbnail is used to obtain native thumbnail information, if the associated file + /// handler supports that and the thumbnail was cached by OpenFile. This requires that + /// kXMPFiles_OpenCacheTNail be passed to OpenFile. The tnailInfo output pointer can be null, + /// in which case GetThumbnail will simply tell if a recognized native thumbnail is present. + /// + /// \param tnailInfo If not null, returns information about a recognized native thumbnail, and + /// some related information about the primary image if appropriate. + /// + /// \note The returned thumbnail information can be incomplete. What gets returned can depend on + /// the file format, the file handler's capabilities, and the specific file content. + /// + /// \li The fullHeight, fullWIdth, and fullOrientation fields are only meaningful for image files. + /// They are not meaningful for multi-page files such as PDF or InDesign, for dynamic audio or + /// video files, etc. The fields will be zero if not meaningful or not determined. + /// + /// \li The tnailImage and tnailSize fields might be zero even if a "recognized" thumbnail is + /// present. Being recognized means only that the handler has determined that the file does + /// contain a native thumbnail. The thumbnail data might be of a format that the file handler + /// cannot (or does not) return a single contiguous block of thumbnail data. A possible case of + /// this is a TIFF uncompressed thumbnail, the handler might not have logic to gather the various + /// disjoint pieces of the thumbnail from the overall TIFF stream. + /// + /// \result Returns true if a recognized native thumbnail is presentand the thumbnail was + /// cached by OpenFile. This requires that kXMPFiles_OpenCacheTNail be passed to OpenFile. Note + /// that GetThumbnail can return true but still not return an actual thumbnail image, see the + /// above note. + + bool GetThumbnail ( XMP_ThumbnailInfo * tnailInfo ); + + // -------------------------------------------------------------------------------------------- + /// \brief Update the XMP. + /// + /// \c PutXMP supplies new XMP for the file. However, the file is not actully written until + /// closed. The options provided when the file was opened determine if reconciliation is done + /// with other forms of metadata. Overloads are provided to pass the XMP as an XMP + /// object, a string object, or a "const char *" plus length. + + void PutXMP ( const SXMPMeta & xmpObj ); + + void PutXMP ( const tStringObj & xmpPacket ); + + void PutXMP ( XMP_StringPtr xmpPacket, + XMP_StringLen xmpLength = kXMP_UseNullTermination ); + + // -------------------------------------------------------------------------------------------- + /// \brief Determine if the XMP can be updated. + /// + /// \c CanPutXMP determines if the XMP can (probably) be updated. The provided XMP is only used + /// to obtain the length of the serialized packet. The new XMP is not kept, calling this will + /// not cause the file to be written when closed. Overloads are provided to pass the XMP as an + /// XMP object, a string object, or a "const char *" plus length. This is implemented roughly + /// as: + /// + /// \code + /// bool CanPutXMP ( XMP_StringPtr xmpPacket ) + /// { + /// XMP_FileFormat format; + /// this->GetFileInfo ( 0, &format, 0 ); + /// + /// XMP_OptionBits formatFlags; + /// GetFormatInfo ( format, &formatFlags ); + /// + /// if ( (formatFlags & kXMPFiles_CanInjectXMP) && (formatFlags & kXMPFiles_CanExpand) ) return true; + /// + /// XMP_PacketInfo packetInfo; + /// bool hasXMP = this->GetXMP ( 0, 0, &packetInfo ); + /// + /// if ( ! hasXMP ) { + /// if ( formatFlags & kXMPFiles_CanInjectXMP ) return true; + /// } else { + /// if ( (formatFlags & kXMPFiles_CanExpand) || + /// (packetInfo.length >= strlen(xmpPacket)) ) return true; + /// } + /// + /// return false; + /// + /// } + /// \endcode + + bool CanPutXMP ( const SXMPMeta & xmpObj ); + + bool CanPutXMP ( const tStringObj & xmpPacket ); + + bool CanPutXMP ( XMP_StringPtr xmpPacket, + XMP_StringLen xmpLength = kXMP_UseNullTermination ); + + /// @} + + // ============================================================================================= + +private: + XMPFilesRef xmpFilesRef; + +}; // class TXMPFiles + +// ================================================================================================= + +#endif // __TXMPFiles_hpp__ diff --git a/public/include/TXMPIterator.hpp b/public/include/TXMPIterator.hpp new file mode 100644 index 0000000..26bb141 --- /dev/null +++ b/public/include/TXMPIterator.hpp @@ -0,0 +1,205 @@ +#ifndef __TXMPIterator_hpp__ +#define __TXMPIterator_hpp__ 1 + +#if ( ! __XMP_hpp__ ) + #error "Do not directly include, use XMP.hpp" +#endif + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file TXMPIterator.hpp +/// \brief Template class for the XMP Toolkit iteration services. +/// +/// This template class provides iteration services for the XMP Toolkit. It should be instantiated +/// with a string class such as <tt>std::string</tt>. Please read the general usage notes for +/// information on the overall architecture of the XMP API. +// ================================================================================================ + +// ================================================================================================ +/// \class TXMPIterator TXMPIterator.hpp +/// \brief Template class for the XMP Toolkit iteration services. +/// +/// This template class provides iteration services for the XMP Toolkit. It should be instantiated +/// with a string class such as <tt>std::string</tt>. Please read the general usage notes for +/// information on the overall architecture of the XMP API. +/// +/// \c TXMPIterator provides a uniform means to iterate over several XMP data structures, including +/// the schema and properties within an XMP object plus global tables such as registered +/// namespaces. The template wraps a string class around the raw XMP API, so that output strings +/// are automatically copied and access is fully thread safe. String objects are only necessary +/// for output strings. Input string are literals and passed as typical C <tt>const char *</tt>. +/// +/// The template parameter, class \c TtStringObj, is described in the XMP.hpp umbrella header. +/// +/// \note Only XMP object iteration is implemented at this time. There are no table iterators yet. +/// +/// Iteration over the schema and properties within an XMP object is the most important and complex +/// use of \c TTXMPIterator. It is helpful to have a thorough understanding of the XMP data tree. +/// One way to learn this is to create some complex XMP and examine the output of +/// <tt>TXMPMeta::DumpObject</tt>. This is also described in the XMP Specification, in the XMP Data +/// Model chapter. +/// +/// The top of the XMP data tree is a single root node. This does not explicitly appear in the dump +/// and is never visited by an iterator (that is, it is never returned from +/// <tt>TXMPIterator::Next</tt>). Beneath the root are schema nodes. These are just collectors for +/// top level properties in the same namespace. They are created and destroyed implicitly. Beneath +/// the schema nodes are the property nodes. The nodes below a property node depend on its type +/// (simple, struct, or array) and whether it has qualifiers. +/// +/// A \c TXMPIterator constructor defines a starting point for the iteration and options that control +/// how it proceeds. By default the iteration starts at the root and visits all nodes beneath it in +/// a depth first manner. The root node is not visited, the first visited node is a schema node. You +/// can provide a schema name or property path to select a different starting node. By default this +/// visits the named root node first then all nodes beneath it in a depth first manner. +/// +/// The <tt>TXMPIterator::Next</tt> method delivers the schema URI, path, and option flags for the +/// node being visited. If the node is simple it also delivers the value. Qualifiers for this node +/// are visited next. The fields of a struct or items of an array are visited after the qualifiers +/// of the parent. +/// +/// The options to control the iteration are: +/// +/// \li \c kXMP_IterJustChildren - Visit just the immediate children of the root. Skip the root +/// itself and all nodes below the immediate children. This omits the qualifiers of the immediate +/// children, the qualifier nodes being below what they qualify. +/// +/// \li \c kXMP_IterJustLeafNodes - Visit just the leaf property nodes and their qualifiers. +/// +/// \li \c kXMP_IterJustLeafName - Return just the leaf component of the node names. The default is +/// to return the full path name. +/// +/// \li \c kXMP_IterIncludeAliases - Include aliases as part of the iteration. Since aliases are not +/// actual nodes the default iteration does not visit them. +/// +/// \li \c kXMP_IterOmitQualifiers - Do not visit the qualifiers of a node. +/// +// ================================================================================================ + +#include "client-glue/WXMPIterator.hpp" + +template <class tStringObj> +class TXMPIterator { + +public: + + // -------------------------------------------------------------------------------------------- + /// \brief Assignment operator, assigns the internal ref and increments the ref count. + /// + /// The assignment operator assigns the internal ref from the rhs object and increments the + /// reference count on the underlying internal XMP iterator. + + void operator= ( const TXMPIterator<tStringObj> & rhs ); + + // -------------------------------------------------------------------------------------------- + /// \brief Copy constructor, creates a client object refering to the same internal object. + /// + /// The copy constructor creates a new client iterator that refers to the same underlying iterator. + + TXMPIterator ( const TXMPIterator<tStringObj> & original ); + + // -------------------------------------------------------------------------------------------- + /// \brief Construct an iterator for the properties within an XMP object. + /// + /// Construct an iterator for the properties within an XMP object. The general operation of an + /// XMP object iterator was described above. Overloaded forms are provided to iterate the entire + /// data tree, properties within a specific schema, or a subtree rooted at a specific node. + /// + /// \param xmpObj The XMP object over which to iterate. + /// + /// \param schemaNS Optional schema namespace URI to restrict the iteration. Omitted (visit all + /// schema) by passing 0 or "". + /// + /// \param propName Optional property name to restrict the iteration. May be an arbitrary path + /// expression. Omitted (visit all properties) by passing 0 or "". If not null/empty a schema + /// URI must also be provided. + /// + /// \param options Option flags to control the iteration. + /// + /// The available option flags are: + /// + /// \li \c kXMP_IterJustChildren - Just visit the immediate children of the root, default is subtree. + /// \li \c kXMP_IterJustLeafNodes - Just visit the leaf nodes, default visits all nodes. + /// \li \c kXMP_IterJustLeafName - Return just the leaf part of the path, default is the full path. + /// \li \c kXMP_IterOmitQualifiers - Omit all qualifiers. + + TXMPIterator ( const TXMPMeta<tStringObj> & xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_OptionBits options = 0 ); + + TXMPIterator ( const TXMPMeta<tStringObj> & xmpObj, + XMP_StringPtr schemaNS, + XMP_OptionBits options = 0 ); + + TXMPIterator ( const TXMPMeta<tStringObj> & xmpObj, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief Construct an iterator for the global tables of the XMP toolkit. + /// + /// \note <b>Not yet implemented.</b> File a bug if you need this. + + TXMPIterator ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_OptionBits options ); + + // -------------------------------------------------------------------------------------------- + /// \brief Destructor, typical virtual destructor. + + virtual ~TXMPIterator() throw(); + + // -------------------------------------------------------------------------------------------- + /// \brief Visit the next node in the iteration. + /// + /// \result Returns true if there was another node to visit, false if the iteration is done. + /// + /// \param schemaNS A pointer to the string that is assigned the schema namespace URI of + /// the current property. May be null if the value is not wanted. + /// + /// \param propPath A pointer to the string that is assigned the XPath name of the current + /// property. May be null if the value is not wanted. + /// + /// \param propValue A pointer to the string that is assigned the value of the current + /// property. May be null if the value is not wanted. + /// + /// \param options A pointer to the XMP_OptionBits variable that is assigned the flags + /// describing the current property. + + bool + Next ( tStringObj * schemaNS = 0, + tStringObj * propPath = 0, + tStringObj * propValue = 0, + XMP_OptionBits * options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief Skip some portion of the remaining iterations. + /// + /// \param options Option flags to control the iteration. + /// + /// The available option flags are: + /// + /// \li \c kXMP_IterSkipSubtree - Skip the subtree below the current node. + /// \li \c kXMP_IterSkipSiblings - Skip the subtree below and remaining siblings of the current node. + + void + Skip ( XMP_OptionBits options ); + +private: + + XMPIteratorRef iterRef; + + TXMPIterator(); // ! Hidden, must choose property or table iteration. + +}; // class TXMPIterator + +// ================================================================================================= + +#endif // __TXMPIterator_hpp__ diff --git a/public/include/TXMPMeta.hpp b/public/include/TXMPMeta.hpp new file mode 100644 index 0000000..ef1a5fc --- /dev/null +++ b/public/include/TXMPMeta.hpp @@ -0,0 +1,1599 @@ +#ifndef __TXMPMeta_hpp__ +#define __TXMPMeta_hpp__ 1 + +#if ( ! __XMP_hpp__ ) + #error "Do not directly include, use XMP.hpp" +#endif + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file TXMPMeta.hpp +/// \brief Template class for the XMP Toolkit core services. +/// +/// TXMPMeta is the template class providing the core services of the XMP Toolkit. It should be +/// instantiated with a string class such as <tt>std::string</tt>. Please read the general toolkit +/// usage notes for information about the overall architecture of the XMP API. +// ================================================================================================ + +// ================================================================================================ +/// \class TXMPMeta TXMPMeta.hpp +/// \brief Template class for the XMP Toolkit core services. +/// +/// \c TXMPMeta is the template class providing the core services of the XMP Toolkit. It should be +/// instantiated with a string class such as std::string. Please read the general toolkit usage notes +/// for information about the overall architecture of the XMP API. +/// +/// This template wraps a string object class around the raw XMP API. This provides two significant +/// benefits, output strings are automatically copied and access is fully thread safe. The +/// umbrella header, \c XMP.hpp, provides an \c SXMPMeta typedef for the instantiated template. String +/// objects are only necessary for output strings. Input string are literals and passed as typical +/// C <tt>const char *</tt>. +/// +/// The template parameter, class \c TtStringObj, is described in the XMP.hpp umbrella header. +/// +/// <b>Be aware that the \c TXMPMeta class is a normal C++ template, it is instantiated and local to +/// each client executable. As are the other TXMP* classes. Different clients might not even use the +/// same string type to instantiate \c TXMPMeta.</b> +/// +/// Because of this you should not pass \c SXMPMeta objects, or pointers to \c SXMPMeta objects, +/// across DLL boundaries. There is a safe internal reference that you can pass, then construct a +/// local object on the callee side. This construction does not create a cloned XMP tree, it is the +/// same underlying XMP object safely wrapped in each client's \c SXMPMeta object. +/// +/// Use GetInternalRef and the associated constructor like this: +/// \code +/// --- The callee's header contains: +/// CalleeMethod ( XMPMetaRef xmpRef ); +/// +/// --- The caller's code contains: +/// SXMPMeta callerXMP; +/// CalleeMethod ( callerXMP.GetInternalRef() ); +/// +/// --- The callee's code contains: +/// SXMPMeta calleeXMP ( xmpRef ); +/// \endcode +// ================================================================================================ + +template <class tStringObj> class TXMPIterator; +template <class tStringObj> class TXMPUtils; + +// ------------------------------------------------------------------------------------------------- + +template <class tStringObj> +class TXMPMeta { + +public: + + // ============================================================================================= + // Initialization and termination + // ============================== + + // -------------------------------------------------------------------------------------------- + /// \name Initialization and termination + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief Obtain version information. + + static void + GetVersionInfo ( XMP_VersionInfo * info ); + + // -------------------------------------------------------------------------------------------- + /// \brief Initialize the XMP Toolkit. + /// + /// The XMP Toolkit may be explicitly initialized before use. The allocate/delete parameters must + /// be either both null (0), or both non-null. + + static bool + Initialize(); + // -------------------------------------------------------------------------------------------- + /// \brief Terminate the XMP Toolkit. + + static void + Terminate(); + + /// @} + + // ============================================================================================= + // Constuctors and destructor + // ========================= + + // -------------------------------------------------------------------------------------------- + /// \name Constructors and destructor + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief Default constructor, creates an empty object. + /// + /// The default constructor creates a new empty \c TXMPMeta object. + + TXMPMeta(); + + // -------------------------------------------------------------------------------------------- + /// \brief Copy constructor, creates a client object refering to the same internal object. + /// + /// The copy constructor creates a new \c TXMPMeta object that refers to the same internal XMP object. + + TXMPMeta ( const TXMPMeta<tStringObj> & original ); + + // -------------------------------------------------------------------------------------------- + /// \brief Assignment operator, assigns the internal ref and increments the ref count. + /// + /// The assignment operator assigns the internal ref from the rhs object and increments the + /// reference count on the underlying internal XMP object. + + void operator= ( const TXMPMeta<tStringObj> & rhs ); + + // -------------------------------------------------------------------------------------------- + /// \brief Reconstruct an XMP object from an internal ref. + /// + /// This constructor creates a new \c TXMPMeta object that refers to the underlying \c xmpRef, + /// which was obtained from some other XMP object by the \c GetInternalRef method. This is used + /// to safely pass XMP objects across DLL boundaries. + + TXMPMeta ( XMPMetaRef xmpRef ); + + // -------------------------------------------------------------------------------------------- + /// \brief Construct an object and parse one buffer of RDF into it. + /// + /// This constructor creates a new \c TXMPMeta object and populates it with metadata from a + /// buffer containing serialized RDF. This buffer must be a complete RDF parse stream. Pass + /// (0,0) to construct an empty \c TXMPMeta object. The result of an actual parse is identical + /// to creating an empty object then calling <tt>TXMPMeta::ParseFromBuffer</tt>. The RDF must be + /// complete. If you need to parse with multiple buffers, create an empty object and use + /// \c TXMPMeta::ParseFromBuffer. + /// + /// \param buffer A pointer to the buffer of RDF to be parsed. May be null if the length is 0. + /// + /// \param xmpSize The length in bytes of the buffer. + + TXMPMeta ( XMP_StringPtr buffer, + XMP_StringLen xmpSize ); + + // -------------------------------------------------------------------------------------------- + /// \brief Destructor, typical virtual destructor. + + virtual ~TXMPMeta() throw(); + + /// @} + + // ============================================================================================= + // Global state functions + // ====================== + + // -------------------------------------------------------------------------------------------- + /// \name Global option flags + /// @{ + /// The global option flags affect the overall behavior of the XMP Toolkit. The available options + /// are declared in <tt>XMP_Const.h</tt>. <b>(There are none at present.)</b> + + /// \brief GetGlobalOptions returns the set of global option flags. + + static XMP_OptionBits + GetGlobalOptions(); + + /// \brief \c SetGlobalOptions updates the set of global option flags. The entire set is + /// replaced with the new values. If only one flag is to be modified, use \c GetGlobalOptions + /// to obtain the current set, modify the desired flag, then use \c SetGlobalOptions. + /// + /// \note There are no options to set yet. + + static void + SetGlobalOptions ( XMP_OptionBits options ); + + /// @} + + // -------------------------------------------------------------------------------------------- + /// \name Internal data structure dump utilities + /// @{ + /// These are debugging utilities that dump internal data structures. The output callback is + /// described in <tt>XMP_Const.h</tt>. + + /// \brief \c DumpNamespaces dumps the list of registered namespace URIs and prefixes. + + static XMP_Status + DumpNamespaces ( XMP_TextOutputProc outProc, + void * refCon ); + + /// \brief \c DumpAliases dumps the list of registered aliases and corresponding actuals. + + static XMP_Status + DumpAliases ( XMP_TextOutputProc outProc, + void * refCon ); + + /// @} + + // -------------------------------------------------------------------------------------------- + /// \name Namespace Functions + /// @{ + /// Namespaces must be registered before use in namespace URI parameters or path expressions. + /// Within the XMP Toolkit the registered namespace URIs and prefixes must be unique. Additional + /// namespaces encountered when parsing RDF are automatically registered. + /// + /// The namespace URI should always end in an XML name separator such as '/' or '#'. This is + /// because some forms of RDF shorthand catenate a namespace URI with an element name to form a + /// new URI. + + // -------------------------------------------------------------------------------------------- + /// \brief Register a namespace URI with a suggested prefix. + /// + /// It is not an error if the URI is already registered, no matter what the prefix is. If the + /// URI is not registered but the suggested prefix is in use, a unique prefix is created from + /// the suggested one. The actual registeed prefix is always returned. The function result + /// tells if the registered prefix is the suggested one. + /// + /// \param namespaceURI The URI for the namespace. Must be a valid XML URI. + /// + /// \param suggestedPrefix The suggested prefix to be used if the URI is not yet registered. + /// Must be a valid XML name. + /// + /// \param registeredPrefix Returns the prefix actually registered for this URI. + /// + /// \result Returns true if the registered prefix matches the suggested prefix. + /// + /// \note No checking is presently done on either the URI or the prefix. + + static bool + RegisterNamespace ( XMP_StringPtr namespaceURI, + XMP_StringPtr suggestedPrefix, + tStringObj * registeredPrefix ); + + // -------------------------------------------------------------------------------------------- + /// \brief Obtain the prefix for a registered namespace URI. + /// + /// It is not an error if the namespace URI is not registered. The output \c namespacePrefix + /// string is not modified if the namespace URI is not registered. + /// + /// \param namespaceURI The URI for the namespace. Must not be null or the empty string. + /// + /// \param namespacePrefix Returns the prefix registered for this URI, with a terminating ':'. + /// + /// \result Returns true if the namespace URI is registered. + + static bool + GetNamespacePrefix ( XMP_StringPtr namespaceURI, + tStringObj * namespacePrefix ); + + // -------------------------------------------------------------------------------------------- + /// \brief Obtain the URI for a registered namespace prefix. + /// + /// It is not an error if the namespace prefix is not registered. The output \c namespaceURI + /// string is not modified if the namespace prefix is not registered. + /// + /// \param namespacePrefix The prefix for the namespace. Must not be null or the empty string. + /// + /// \param namespaceURI Returns the URI registered for this prefix. + /// + /// \result Returns true if the namespace prefix is registered. + + static bool + GetNamespaceURI ( XMP_StringPtr namespacePrefix, + tStringObj * namespaceURI ); + + // -------------------------------------------------------------------------------------------- + /// \brief Delete a namespace from the registry. + /// + /// Does nothing if the URI is not registered, or if the \c namespaceURI parameter is null or the + /// empty string. + /// + /// \param namespaceURI The URI for the namespace. + /// + /// \note <b>Not yet implemented.</b> + + static void + DeleteNamespace ( XMP_StringPtr namespaceURI ); + + /// @} + + // -------------------------------------------------------------------------------------------- + /// \name Alias Functions + /// @{ + /// Aliases in XMP serve the same purpose as Windows file shortcuts, Macintosh file aliases, or + /// UNIX file symbolic links. The aliases are simply multiple names for the same property. One + /// distinction of XMP aliases is that they are ordered, there is an alias name pointing to an + /// actual name. The primary significance of the actual name is that it is the preferred name + /// for output, generally the most widely recognized name. + /// + /// The names that can be aliased in XMP are restricted. The alias must be a top level property + /// name, not a field within a structure or an element within an array. The actual may be a top + /// level property name, the first element within a top level array, or the default element in + /// an alt-text array. This does not mean the alias can only be a simple property. It is OK to + /// alias a top level structure or array to an identical top level structure or array, or to the + /// first item of an array of structures. + + // -------------------------------------------------------------------------------------------- + /// \brief Associates an alias name with an actual name. + /// + /// Define a alias mapping from one namespace/property to another. Both property names must be + /// simple names. An alias can be a direct mapping, where the alias and actual have the same + /// data type. It is also possible to map a simple alias to an item in an array. This can either + /// be to the first item in the array, or to the 'x-default' item in an alt-text array. Multiple + /// alias names may map to the same actual, as long as the forms match. It is a no-op to + /// reregister an alias in an identical fashion. + /// + /// \param aliasNS The namespace URI for the alias. Must not be null or the empty string. + /// + /// \param aliasProp The name of the alias. Must be a simple name, not null or the empty string + /// and not a general path expression. + /// + /// \param actualNS The namespace URI for the actual. Must not be null or the empty string. + /// + /// \param actualProp The name of the actual. Must be a simple name, not null or the empty string + /// and not a general path expression. + /// + /// \param arrayForm Provides the array form for simple aliases to an array item. This is needed + /// to know what kind of array to create if set for the first time via the simple alias. Pass + /// \c kXMP_NoOptions, the default value, for all direct aliases regardless of whether the actual + /// data type is an array or not. + /// + /// Constants for the arrayForm parameter: + /// + /// \li \c kXMP_NoOptions - This is a direct mapping. The actual data type does not matter. + /// \li \c kXMP_PropValueIsArray - The actual is an unordered array, the alias is to the first + /// element of the array. + /// \li \c kXMP_PropArrayIsOrdered - The actual is an ordered array, the alias is to the first + /// element of the array. + /// \li \c kXMP_PropArrayIsAlternate - The actual is an alternate array, the alias is to the first + /// element of the array. + /// \li \c kXMP_PropArrayIsAltText - The actual is an alternate text array, the alias is to the + /// 'x-default' element of the array. + + static void + RegisterAlias ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp, + XMP_StringPtr actualNS, + XMP_StringPtr actualProp, + XMP_OptionBits arrayForm = kXMP_NoOptions ); + + // -------------------------------------------------------------------------------------------- + /// \brief Determines if a name is an alias, and what it is aliased to. + /// + /// \param aliasNS The namespace URI for the alias. Must not be null or the empty string. + /// + /// \param aliasProp The name of the alias. May be an arbitrary path expression path, must not + /// null or the empty string. + /// + /// \param actualNS Untouched if <tt>aliasNS:aliasProp</tt> is not an alias. Otherwise returns + /// the namespace URI for the actual. May be null if the namespace URI is not wanted. + /// + /// \param actualProp Untouched if <tt>aliasNS:aliasProp</tt> is not an alias. Otherwise + /// returns the path of the actual. May be null if the actual's path is not wanted. + /// + /// \param arrayForm Untouched if <tt>aliasNS:aliasProp</tt> is not an alias. Otherwise returns + /// the form of the actual. This is 0 (\c kXMP_NoOptions) if the alias and actual forms match, + /// otherwise it is the options passed to <tt>TXMPMeta::RegisterAlias</tt>. May be null if the + /// actual's form is not wanted. + /// + /// \result Returns true if the input is an alias. + /// + /// \note The client output strings are not written until return, so a call like the following + /// may be used to "reduce" a path to the base form: + /// \code + /// isAlias = SXMPMeta::ResolveAlias ( ns.c_str(), path.c_str(), &ns, &path, 0 ); + /// \endcode + + static bool + ResolveAlias ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp, + tStringObj * actualNS, + tStringObj * actualProp, + XMP_OptionBits * arrayForm ); + + // -------------------------------------------------------------------------------------------- + /// \brief Delete an alias. + /// + /// This only deletes the registration of the alias, it does not delete the actual property. It + /// does delete any view of the property through the alias name. It is OK to attempt to delete + /// an alias that does not exist, that is if the alias name is not registered as an alias. + /// + /// \param aliasNS The namespace URI for the alias. Must not be null or the empty string. + /// + /// \param aliasProp The name of the alias. Must be a simple name, not null or the empty string + /// and not a general path expression. + + static void + DeleteAlias ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp ); + + // -------------------------------------------------------------------------------------------- + /// \brief Registers all of the built-in aliases for a standard namespace. + /// + /// The built-in aliases are documented in the XMP Specification. This registers the aliases in + /// the given namespace, that is the aliases from this namespace to actuals in other namespaces. + /// + /// \param schemaNS The namespace URI for the aliases. Must not be null or the empty string. + + static void + RegisterStandardAliases ( XMP_StringPtr schemaNS ); + + /// @} + + // ============================================================================================= + // Basic property manipulation functions + // ===================================== + + // *** Should add discussion of schemaNS and propName prefix usage. + + // -------------------------------------------------------------------------------------------- + /// \name Functions for getting property values + /// @{ + /// The property value "getters" all take a property specification, The first two parameters + /// are always the top level namespace URI (the "schema" namespace) and the basic name of the + /// property being referenced. See the introductory discussion of path expression usage for + /// more information. + /// + /// All of the functions return a Boolean result telling if the property exists, and if it does + /// they also return option flags describing the property. If the property exists and has a + /// value, the string value is also returned. The string is Unicode in UTF-8 encoding. Arrays + /// and the non-leaf levels of structs do not have values. The possible option flags that + /// describe properties are: + /// + /// \li \c kXMP_PropValueIsURI - The property value is a URI. It is serialized to RDF using the + /// <tt>rdf:resource</tt> attribute. Not mandatory for URIs, but considered RDF-savvy. + /// + /// \li \c kXMP_PropHasQualifiers - The property has qualifiers. These could be an + /// <tt>xml:lang</tt> attribute, an <tt>rdf:type</tt> property, or a general qualifier. See the + /// introductory discussion of qualified properties for more information. + /// + /// \li \c kXMP_PropIsQualifier - This property is a qualifier for some other property. Note + /// that if the qualifier itself has a structured value, this flag is only set for the top node + /// of the qualifier's subtree. Qualifiers may have arbitrary structure, and may even have + /// qualifiers. + /// + /// \li \c kXMP_PropHasLang - This property has an <tt>xml:lang</tt> qualifier. + /// + /// \li \c kXMP_PropHasType - This property has an <tt>rdf:type</tt> qualifier. + /// + /// \li \c kXMP_PropValueIsStruct - This property contains nested fields (models a C struct). + /// + /// \li \c kXMP_PropValueIsArray - This property is an array. By itself (no ...ArrayIs... flags), + /// this indicates a general unordered array. It is serialized using an <tt>rdf:Bag</tt> container. + /// + /// \li \c kXMP_PropArrayIsOrdered - This property is an ordered array. Appears in conjunction + /// with \c kXMP_PropValueIsArray. It is serialized using an <tt>rdf:Seq</tt> container. + /// + /// \li \c kXMP_PropArrayIsAlternate - This property is an alternative array. Appears in + /// conjunction with \c kXMP_PropValueIsArray. It is serialized using an <tt>rdf:Alt</tt> container. + /// + /// \li \c kXMP_PropArrayIsAltText - This property is an alt-text array. Appears in conjunction + /// with \c kXMP_PropArrayIsAlternate. It is serialized using an <tt>rdf:Alt</tt> container. Each + /// array element is a simple property with an <tt>xml:lang</tt> attribute. + /// + /// \li \c kXMP_PropIsAlias - The given property name is an alias. This is only returned by + /// \c GetProperty and then only if the property name is simple, not an path expression. + /// + /// \li \c kXMP_PropHasAliases - The given property name has aliases. This is only returned by + /// \c GetProperty and then only if the property name is simple, not an path expression. + /// + /// \li \c kXMP_PropIsStable - The value of this property is not related to the document + /// content. + /// + /// \li \c kXMP_PropIsDerived - The value of this property is derived from the document + /// content. + /// + /// \li \c kXMP_PropIsInternal - The value of this property is "owned" by the application, it + /// should not generally be editable in a UI. + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetProperty is the simplest property getter, mainly for top level simple + /// properties or after using the path composition functions in \c TXMPUtils. + /// + /// \result Returns true if the property exists. + /// + /// \param schemaNS The namespace URI for the property. May be null or the empty string if the + /// first component of the propName path contains a namespace prefix. The URI must be for a + /// registered namespace. + /// + /// \param propName The name of the property. May be a general path expression, must not be + /// null or the empty string. Using a namespace prefix on the first component is optional. If + /// present without a \c schemaNS value then the prefix specifies the namespace. The prefix + /// must be for a registered namespace. If both a \c schemaNS URI and \c propName prefix are + /// present, they must be corresponding parts of a registered namespace. + /// + /// \param propValue A pointer to the string that is assigned the value of the property, if + /// the property has a value. Arrays and non-leaf levels of structs do not have values. May be + /// null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the property. May be null if the flags are not wanted. + + bool + GetProperty ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + tStringObj * propValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetArrayItem provides access to items within an array. The index is passed as an + /// integer, you need not worry about the path string syntax for array items, convert a loop + /// index to a string, etc. + /// + /// \result Returns true if the array item exists. + /// + /// \param schemaNS The namespace URI for the array. Has the same usage as in \c GetProperty. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. Has the same namespace prefix usage as \c propName in \c GeProperty. + /// + /// \param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The constant + /// \c kXMP_ArrayLastItem always refers to the last existing array item. + /// + /// \param itemValue A pointer to the string that is assigned the value of the array item, if + /// the array item has a value. Arrays and non-leaf levels of structs do not have values. May be + /// null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the array item. May be null if the flags are not wanted. + + bool + GetArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + tStringObj * itemValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetStructField provides access to fields within a nested structure. The namespace + /// for the field is passed as a URI, you need not worry about the path string syntax. + /// + /// The names of fields should be XML qualified names, that is within an XML namespace. The path + /// syntax for a qualified name uses the namespace prefix. This is unreliable since the prefix + /// is never guaranteed. The URI is the formal name, the prefix is just a local shorthand in a + /// given sequence of XML text. + /// + /// \result Returns true if the field exists. + /// + /// \param schemaNS The namespace URI for the struct. Has the same usage as in \c GetProperty. + /// + /// \param structName The name of the struct. May be a general path expression, must not be null + /// or the empty string. Has the same namespace prefix usage as \c propName in \c GetProperty. + /// + /// \param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the + /// \c schemaNS parameter. + /// + /// \param fieldName The name of the field. Must be a single XML name, must not be null or the + /// empty string. Has the same namespace prefix usage as the \c structName parameter. + /// + /// \param fieldValue A pointer to the string that is assigned the value of the field, if + /// the field has a value. Arrays and non-leaf levels of structs do not have values. May be + /// null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the field. May be null if the flags are not wanted. + + bool + GetStructField ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + tStringObj * fieldValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetQualifier provides access to a qualifier attached to a property. The namespace + /// for the qualifier is passed as a URI, you need not worry about the path string syntax. In + /// many regards qualifiers are like struct fields. See the introductory discussion of + /// qualified properties for more information. + /// + /// The names of qualifiers should be XML qualified names, that is within an XML namespace. The + /// path syntax for a qualified name uses the namespace prefix. This is unreliable since the + /// prefix is never guaranteed. The URI is the formal name, the prefix is just a local shorthand + /// in a given sequence of XML text. + /// + /// \note Qualifiers are only supported for simple leaf properties at this time. + /// + /// \result Returns true if the qualifier exists. + /// + /// \param schemaNS The namespace URI for the struct. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property to which the qualifier is attached. May be a general + /// path expression, must not be null or the empty string. Has the same namespace prefix usage + /// as in \c GetProperty. + /// + /// \param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the + /// \c schemaNS parameter. + /// + /// \param qualName The name of the qualifier. Must be a single XML name, must not be null or the + /// empty string. Has the same namespace prefix usage as the \c propName parameter. + /// + /// \param qualValue A pointer to the string that is assigned the value of the qualifier, if + /// the qualifier has a value. Arrays and non-leaf levels of structs do not have values. May be + /// null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the qualifier. May be null if the flags are not wanted. + + bool + GetQualifier ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + tStringObj * qualValue, + XMP_OptionBits * options ) const; + + /// @} + + // ============================================================================================= + + // -------------------------------------------------------------------------------------------- + /// \name Functions for setting property values + /// @{ + /// The property value "setters" all take a property specification, their differences are in + /// the form of this. The first two parameters are always the top level namespace URI (the + /// "schema" namespace) and the basic name of the property being referenced. See the + /// introductory discussion of path expression usage for more information. + /// + /// All of the functions take a string value for the property and option flags describing the + /// property. The value must be Unicode in UTF-8 encoding. Arrays and non-leaf levels of + /// structs do not have values. Empty arrays and structs may be created using appropriate + /// option flags. All levels of structs that is assigned implicitly are created if necessary. + /// \c AppendArayItem implicitly creates the named array if necessary. + /// + /// The canonical form of these functions take the value as an \c XMP_StringPtr, a pointer to a + /// null terminated string. (\c XMP_StringPtr is a typedef for <tt>const char *</tt>.) They + /// also have overloaded forms that take a string object. These are implemented in the template + /// instantiation as a call to the canonical form, using <tt>value.c_str()</tt> to obtain the + /// \c XMP_StringPtr. + /// + /// The possible option flags are: + /// + /// \li \c kXMP_PropValueIsURI - The property value is a URI. It is serialized to RDF using the + /// <tt>rdf:resource</tt> attribute. Not mandatory for URIs, but considered RDF-savvy. + /// + /// \li \c kXMP_PropValueIsStruct - This property contains nested fields (models a C struct). + /// Not necessary, may be used to create an empty struct. A struct is implicitly created when + /// first field is set. + /// + /// \li \c kXMP_PropValueIsArray - This property is an array. By itself (no ...ArrayIs... + /// flags), this indicates a general unordered array. It is serialized using an + /// <tt>rdf:Bag</tt> container. + /// + /// \li \c kXMP_PropArrayIsOrdered - This property is an ordered array. Implies \c + /// kXMP_PropValueIsArray, may be used together. It is serialized using an <tt>rdf:Seq</tt> + /// container. + /// + /// \li \c kXMP_PropArrayIsAlternate - This property is an alternative array. Implies \c + /// kXMP_PropArrayIsOrdered, may be used together. It is serialized using an <tt>rdf:Alt</tt> + /// container. + /// + /// \li \c kXMP_PropArrayIsAltText - This property is an alt-text array. Implies \c + /// kXMP_PropArrayIsAlternate, may be used together. It is serialized using an <tt>rdf:Alt</tt> + /// container. Each array element must be a simple property with an <tt>xml:lang</tt> attribute. + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetProperty is the simplest property setter, mainly for top level simple + /// properties or after using the path composition functions in \c TXMPUtils. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue A pointer to the null terminated UTF-8 string that is the value of the + /// property, if the property has a value. Arrays and non-leaf levels of structs do not have + /// values. Must be null if the value is not relevant. + /// + /// \param options Option flags describing the property. See the earlier description. + + void + SetProperty ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr propValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c SetProperty is a simple overload in the template that calls the above + /// form passing <tt>propValue.c_str()</tt>. + + void + SetProperty ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + const tStringObj & propValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetArrayItem provides access to items within an array. The index is passed as an + /// integer, you need not worry about the path string syntax for array items, convert a loop + /// index to a string, etc. The array passed to \c SetArrayItem must already exist. See also + /// \c AppendArrayItem. + /// + /// In normal usage the selected array item is modified. A new item is automatically + /// appended if the index is the array size plus 1. A new item may be inserted before or after + /// any item by using one of the following option flags: + /// + /// \li \c kXMP_InsertBeforeItem - Insert a new array item before the selected one. + /// \li \c kXMP_InsertAfterItem - Insert a new array item after the selected one. + /// + /// \param schemaNS The namespace URI for the array. Has the same usage as in \c GetProperty. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. Has the same namespace prefix usage as \c propName in \c GetProperty. + /// + /// \param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The + /// constant \c kXMP_ArrayLastItem always refers to the last existing array item. + /// + /// \param itemValue A pointer to the null terminated UTF-8 string that is the value of the array + /// item, if the array item has a value. Has the same usage as \c propValue in \c GetProperty. + /// + /// \param options Option flags describing the item. See the earlier description. + + void + SetArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + XMP_StringPtr itemValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c SetArrayItem is a simple overload in the template that calls the above + /// form passing <tt>itemValue.c_str()</tt>. + + void + SetArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + const tStringObj & itemValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c AppendArrayItem simplifies construction of an array by not requiring that you + /// pre-create an empty array. The array that is assigned is created automatically if it does + /// not yet exist. Each call to \c AppendArrayItem appends an item to the array. The + /// corresponding parameters have the same use as \c SetArrayItem. The \c arrayOptions + /// parameter is used to specify what kind of array. If the array exists, it must have the + /// specified form. + /// + /// \param schemaNS The namespace URI for the array. Has the same usage as in \c GetProperty. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. Has the same namespace prefix usage as \c propPath in \c GetProperty. + /// + /// \param arrayOptions Option flags describing the array form. The only valid bits are those + /// that are part of \c kXMP_PropArrayFormMask: \c kXMP_PropValueIsArray, \c + /// kXMP_PropArrayIsOrdered, \c kXMP_PropArrayIsAlternate, or \c kXMP_PropArrayIsAltText. + /// + /// \param itemValue A pointer to the null terminated UTF-8 string that is the value of the + /// array item, if the array item has a value. Has the same usage as \c propValue in \c + /// GetProperty. + /// + /// \param itemOptions Option flags describing the item. See the earlier description. + + void + AppendArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits arrayOptions, + XMP_StringPtr itemValue, + XMP_OptionBits itemOptions = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c AppendArrayItem is a simple overload in the template that calls the + /// above form passing <tt>itemValue.c_str()</tt>. + + void + AppendArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits arrayOptions, + const tStringObj & itemValue, + XMP_OptionBits itemOptions = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetStructField provides access to fields within a nested structure. The namespace + /// for the field is passed as a URI, you need not worry about the path string syntax. + /// + /// The names of fields should be XML qualified names, that is within an XML namespace. The + /// path syntax for a qualified name uses the namespace prefix, which is unreliable because + /// the prefix is never guaranteed. The URI is the formal name, the prefix is just a local + /// shorthand in a given sequence of XML text. + /// + /// \param schemaNS The namespace URI for the struct. Has the same usage as in \c GetProperty. + /// + /// \param structName The name of the struct. May be a general path expression, must not be + /// null or the empty string. Has the same namespace prefix usage as \c propName in \c + /// GetProperty. + /// + /// \param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the \c + /// schemaNS parameter. + /// + /// \param fieldName The name of the field. Must be a single XML name, must not be null or the + /// empty string. Has the same namespace prefix usage as the \c structName parameter. + /// + /// \param fieldValue A pointer to the null terminated UTF-8 string that is the value of the + /// field, if the field has a value. Has the same usage as \c propValue in \c GetProperty. + /// + /// \param options Option flags describing the field. See the earlier description. + + void + SetStructField ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + XMP_StringPtr fieldValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c SetStructField is a simple overload in the template that calls the + /// above form passing <tt>fieldValue.c_str()</tt>. + + void + SetStructField ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + const tStringObj & fieldValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetQualifier provides access to a qualifier attached to a property. The namespace + /// for the qualifier is passed as a URI, you need not worry about the path string syntax. In + /// many regards qualifiers are like struct fields. See the introductory discussion of + /// qualified properties for more information. + /// + /// The names of qualifiers should be XML qualified names, that is within an XML namespace. The + /// path syntax for a qualified name uses the namespace prefix, which is unreliable because + /// the prefix is never guaranteed. The URI is the formal name, the prefix is just a local + /// shorthand in a given sequence of XML text. + /// + /// \param schemaNS The namespace URI for the struct. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property to which the qualifier is attached. Has the same + /// usage as in \c GetProperty. + /// + /// \param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the + /// \c schemaNS parameter. + /// + /// \param qualName The name of the qualifier. Must be a single XML name, must not be null or + /// the empty string. Has the same namespace prefix usage as the \c propName parameter. + /// + /// \param qualValue A pointer to the null terminated UTF-8 string that is the value of the + /// qualifier, if the qualifier has a value. Has the same usage as \c propValue in \c + /// GetProperty. + /// + /// \param options Option flags describing the qualifier. See the earlier description. + + void + SetQualifier ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + XMP_StringPtr qualValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c SetQualifier is a simple overload in the template that calls the above + /// form passing <tt>qualValue.c_str()</tt>. + + void + SetQualifier ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + const tStringObj & qualValue, + XMP_OptionBits options = 0 ); + + /// @} + + // ============================================================================================= + + // -------------------------------------------------------------------------------------------- + /// \name Functions for deleting and detecting properties. + /// @{ + /// These should be obvious from the descriptions of the getters and setters. + + // -------------------------------------------------------------------------------------------- + /// \brief \c DeleteProperty deletes the given XMP subtree rooted at the given property. It is + /// not an error if the property does not exist. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + + void + DeleteProperty ( XMP_StringPtr schemaNS, + XMP_StringPtr propName ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c DeleteArrayItem deletes the given XMP subtree rooted at the given array item. It + /// is not an error if the array item does not exist. + /// + /// \param schemaNS The namespace URI for the array. Has the same usage as in \c GetProperty. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. Has the same namespace prefix usage as \c propName in \c GetProperty. + /// + /// \param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The + /// constant \c kXMP_ArrayLastItem always refers to the last existing array item. + + void + DeleteArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c DeleteStructField deletes the given XMP subtree rooted at the given struct field. + /// It is not an error if the field does not exist. + /// + /// \param schemaNS The namespace URI for the struct. Has the same usage as in \c GetProperty. + /// + /// \param structName The name of the struct. May be a general path expression, must not be null + /// or the empty string. Has the same namespace prefix usage as \c propName in \c GetProperty. + /// + /// \param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the + /// \c schemaNS parameter. + /// + /// \param fieldName The name of the field. Must be a single XML name, must not be null or the + /// empty string. Has the same namespace prefix usage as the \c structName parameter. + + void + DeleteStructField ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c DeleteQualifier deletes the given XMP subtree rooted at the given qualifier. It + /// is not an error if the qualifier does not exist. + /// + /// \param schemaNS The namespace URI for the struct. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property to which the qualifier is attached. Has the same + /// usage as in \c GetProperty. + /// + /// \param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the + /// \c schemaNS parameter. + /// + /// \param qualName The name of the qualifier. Must be a single XML name, must not be null or the + /// empty string. Has the same namespace prefix usage as the \c propName parameter. + + void + DeleteQualifier ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c DoesPropertyExist tells if the property exists. + /// + /// \result Returns true if the property exists. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + + bool + DoesPropertyExist ( XMP_StringPtr schemaNS, + XMP_StringPtr propName ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c DoesArrayItemExist tells if the array item exists. + /// + /// \result Returns true if the array item exists. + /// + /// \param schemaNS The namespace URI for the array. Has the same usage as in \c GetProperty. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. Has the same namespace prefix usage as \c propName in \c GetProperty. + /// + /// \param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The + /// constant \c kXMP_ArrayLastItem always refers to the last existing array item. + + bool + DoesArrayItemExist ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c DoesStructFieldExist tells if the struct field exists. + /// + /// \result Returns true if the field exists. + /// + /// \param schemaNS The namespace URI for the struct. Has the same usage as in \c GetProperty. + /// + /// \param structName The name of the struct. May be a general path expression, must not be null + /// or the empty string. Has the same namespace prefix usage as \c propName in \c GetProperty. + /// + /// \param fieldNS The namespace URI for the field. Has the same URI and prefix usage as the + /// \c schemaNS parameter. + /// + /// \param fieldName The name of the field. Must be a single XML name, must not be null or the + /// empty string. Has the same namespace prefix usage as the \c structName parameter. + + bool + DoesStructFieldExist ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c DoesQualifierExist tells if the qualifier exists. + /// + /// \result Returns true if the qualifier exists. + /// + /// \param schemaNS The namespace URI for the struct. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property to which the qualifier is attached. Has the same + /// usage as in \c GetProperty. + /// + /// \param qualNS The namespace URI for the qualifier. Has the same URI and prefix usage as the + /// \c schemaNS parameter. + /// + /// \param qualName The name of the qualifier. Must be a single XML name, must not be null or the + /// empty string. Has the same namespace prefix usage as the \c propName parameter. + + bool + DoesQualifierExist ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName ) const; + + /// @} + + // ============================================================================================= + // Specialized Get and Set functions + // ================================= + + // -------------------------------------------------------------------------------------------- + /// \name Functions for accessing localized text (alt-text) properties. + /// @{ + /// These functions provide convenient support for localized text properties, including a number + /// of special and obscure aspects. Localized text properties are stored in alt-text arrays. + /// They allow multiple concurrent localizations of a property value, for example a document + /// title or copyright in several languages. + /// + /// The most important aspect of these functions is that they select an appropriate array item + /// based on one or two RFC 3066 language tags. One of these languages, the "specific" language, + /// is preferred and selected if there is an exact match. For many languages it is also possible + /// to define a "generic" language that may be used if there is no specific language match. The + /// generic language must be a valid RFC 3066 primary subtag, or the empty string. + /// + /// For example, a specific language of "en-US" should be used in the US, and a specific language + /// of "en-UK" should be used in England. It is also appropriate to use "en" as the generic + /// language in each case. If a US document goes to England, the "en-US" title is selected + /// by using the "en" generic language and the "en-UK" specific language. + /// + /// It is considered poor practice, but allowed, to pass a specific language that is just an + /// RFC 3066 primary tag. For example "en" is not a good specific language, it should only be + /// used as a generic language. Passing "i" or "x" as the generic language is also considered + /// poor practice but allowed. + /// + /// Advice from the W3C about the use of RFC 3066 language tags can be found at: + /// \li http://www.w3.org/International/articles/language-tags/ + /// + /// \note RFC 3066 language tags must be treated in a case insensitive manner. The XMP toolkit + /// does this by normalizing their capitalization: + /// + /// \li The primary subtag is lower case, the suggested practice of ISO 639. + /// \li All 2 letter secondary subtags are upper case, the suggested practice of ISO 3166. + /// \li All other subtags are lower case. + /// + /// The XMP specification defines an artificial language, "x-default", that is used to + /// explicitly denote a default item in an alt-text array. The XMP toolkit normalizes alt-text + /// arrays such that the x-default item is the first item. The \c SetLocalizedText function has + /// several special features related to the x-default item, see its description for details. + /// + /// The selection of the array item is the same for \c GetLocalizedText and \c SetLocalizedText: + /// + /// \li Look for an exact match with the specific language. + /// \li If a generic language is given, look for a partial match. + /// \li Look for an x-default item. + /// \li Choose the first item. + /// + /// A partial match with the generic language is where the start of the item's language matches + /// the generic string and the next character is '-'. An exact match is also recognized as a + /// degenerate case. + /// + /// It is fine to pass x-default as the specific language. In this case, selection of an x-default + /// item is an exact match by the first rule, not a selection by the 3rd rule. The last 2 rules + /// are fallbacks used when the specific and generic languages fail to produce a match. + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetLocalizedText returns information about a selected item in an alt-text array. + /// The array item is selected according to the rules given above. + /// + /// \result Returns true if an appropriate array item exists. + /// + /// \param schemaNS The namespace URI for the alt-text array. Has the same usage as in \c + /// GetProperty. + /// + /// \param altTextName The name of the alt-text array. May be a general path expression, must + /// not be null or the empty string. Has the same namespace prefix usage as \c propName in \c + /// GetProperty. + /// + /// \param genericLang The name of the generic language as an RFC 3066 primary subtag. May be + /// null or the empty string if no generic language is wanted. + /// + /// \param specificLang The name of the specific language as an RFC 3066 tag. Must not be null + /// or the empty string. + /// + /// \param actualLang A pointer to the string that is assigned the language of the selected + /// array item, if an appropriate array item is found. May be null if the language is not + /// wanted. + /// + /// \param itemValue A pointer to the string that is assigned the value of the array item, if + /// an appropriate array item is found. May be null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the array item. May be null if the flags are not wanted. + + bool + GetLocalizedText ( XMP_StringPtr schemaNS, + XMP_StringPtr altTextName, + XMP_StringPtr genericLang, + XMP_StringPtr specificLang, + tStringObj * actualLang, + tStringObj * itemValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetLocalizedText modifies the value of a selected item in an alt-text array. + /// Creates an appropriate array item if necessary, and handles special cases for the x-default + /// item. + /// + /// If the selected item is from a match with the specific language, the value of that item is + /// modified. If the existing value of that item matches the existing value of the x-default + /// item, the x-default item is also modified. If the array only has 1 existing item (which is + /// not x-default), an x-default item is added with the given value. + /// + /// If the selected item is from a match with the generic language and there are no other + /// generic matches, the value of that item is modified. If the existing value of that item + /// matches the existing value of the x-default item, the x-default item is also modified. If + /// the array only has 1 existing item (which is not x-default), an x-default item is added + /// with the given value. + /// + /// If the selected item is from a partial match with the generic language and there are other + /// partial matches, a new item is created for the specific language. The x-default item is not + /// modified. + /// + /// If the selected item is from the last 2 rules then a new item is created for the specific + /// language. If the array only had an x-default item, the x-default item is also modified. If + /// the array was empty, items are created for the specific language and x-default. + /// + /// \param schemaNS The namespace URI for the alt-text array. Has the same usage as in \c + /// GetProperty. + /// + /// \param altTextName The name of the alt-text array. May be a general path expression, must + /// not be null or the empty string. Has the same namespace prefix usage as \c propName in \c + /// GetProperty. + /// + /// \param genericLang The name of the generic language as an RFC 3066 primary subtag. May be + /// null or the empty string if no generic language is wanted. + /// + /// \param specificLang The name of the specific language as an RFC 3066 tag. Must not be null + /// or the empty string. + /// + /// \param itemValue A pointer to the null terminated UTF-8 string that is the new value for + /// the appropriate array item. + /// + /// \param options Option flags, none are defined at present. + + void + SetLocalizedText ( XMP_StringPtr schemaNS, + XMP_StringPtr altTextName, + XMP_StringPtr genericLang, + XMP_StringPtr specificLang, + XMP_StringPtr itemValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c SetLocalizedText is a simple overload in the template that calls the + /// above form passing <tt>itemValue.c_str()</tt>. + + void + SetLocalizedText ( XMP_StringPtr schemaNS, + XMP_StringPtr altTextName, + XMP_StringPtr genericLang, + XMP_StringPtr specificLang, + const tStringObj & itemValue, + XMP_OptionBits options = 0 ); + + /// @} + + // ============================================================================================= + + // -------------------------------------------------------------------------------------------- + /// \name Functions accessing properties as binary values. + /// @{ + /// These are very similar to \c GetProperty and \c SetProperty above, but the value is + /// returned or + /// provided in binary form instead of as a UTF-8 string. The path composition functions in + /// \c TXMPUtils may be used to compose an path expression for fields in nested structures, items + /// in arrays, or qualifiers. + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetProperty_Bool returns the value of a Boolean property as a C++ bool. + /// + /// \result Returns true if the property exists. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue A pointer to the bool variable that is assigned the value of the property. + /// May be null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the property. May be null if the flags are not wanted. + + bool + GetProperty_Bool ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + bool * propValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetProperty_Int returns the value of an integer property as a C long integer. + /// + /// \result Returns true if the property exists. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue A pointer to the long integer variable that is assigned the value of + /// the property. May be null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the property. May be null if the flags are not wanted. + + bool + GetProperty_Int ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + long * propValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetProperty_Int64 returns the value of an integer property as a C long long integer. + /// + /// \result Returns true if the property exists. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue A pointer to the long long integer variable that is assigned the value of + /// the property. May be null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the property. May be null if the flags are not wanted. + + bool + GetProperty_Int64 ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + long long * propValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetProperty_Float returns the value of a flaoting point property as a C double float. + /// + /// \result Returns true if the property exists. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue A pointer to the double float variable that is assigned the value of + /// the property. May be null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the property. May be null if the flags are not wanted. + + bool + GetProperty_Float ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + double * propValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c GetProperty_Date returns the value of a date/time property as an \c XMP_DateTime struct. + /// + /// \result Returns true if the property exists. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue A pointer to the \c XMP_DateTime variable that is assigned the value of + /// the property. May be null if the value is not wanted. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the property. May be null if the flags are not wanted. + + bool + GetProperty_Date ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_DateTime * propValue, + XMP_OptionBits * options ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetProperty_Bool sets the value of a Boolean property from a C++ bool. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue The bool value to be assigned to the property. + /// + /// \param options A pointer to the \c XMP_OptionBits variable that is assigned option flags + /// describing the property. May be null if the flags are not wanted. + + void + SetProperty_Bool ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + bool propValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetProperty_Int sets the value of an integer property from a C long integer. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue The long integer value to be assigned to the property. + /// + /// \param options Option flags describing the property. + + void + SetProperty_Int ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + long propValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetProperty_Int64 sets the value of an integer property from a C long long integer. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue The long long integer value to be assigned to the property. + /// + /// \param options Option flags describing the property. + + void + SetProperty_Int64 ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + long long propValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetProperty_Float sets the value of a floating point property from a C double float. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue The double float value to be assigned to the property. + /// + /// \param options Option flags describing the property. + + void + SetProperty_Float ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + double propValue, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c SetProperty_Date sets the value of a date/time property from an \c XMP_DateTime struct. + /// + /// \param schemaNS The namespace URI for the property. Has the same usage as in \c GetProperty. + /// + /// \param propName The name of the property. Has the same usage as in \c GetProperty. + /// + /// \param propValue The \c XMP_DateTime value to be assigned to the property. + /// + /// \param options Option flags describing the property. + + void + SetProperty_Date ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + const XMP_DateTime & propValue, + XMP_OptionBits options = 0 ); + + /// @} + + // ============================================================================================= + // Miscellaneous Member Functions + // ============================== + + // -------------------------------------------------------------------------------------------- + /// \name Misceallaneous functions. + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief GetInternalRef Returns an internal reference that may be safely passed across DLL + /// boundaries and reconstructed. + + XMPMetaRef + GetInternalRef() const; + + // -------------------------------------------------------------------------------------------- + /// \brief GetObjectName --TBD-- + + void + GetObjectName ( tStringObj * name ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief SetObjectName --TBD-- + + void + SetObjectName ( XMP_StringPtr name ); + + // -------------------------------------------------------------------------------------------- + /// \brief SetObjectName --TBD-- + + void + SetObjectName ( tStringObj name ); + + // -------------------------------------------------------------------------------------------- + /// \brief GetObjectOptions --TBD-- + + XMP_OptionBits + GetObjectOptions() const; + + // -------------------------------------------------------------------------------------------- + /// \brief SetObjectOptions --TBD-- + /// + /// \note <b>Not yet implemented.</b> File a bug if you need this. + + void + SetObjectOptions ( XMP_OptionBits options ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c Clone creates a deep clone of the XMP object. + /// + /// This function creates a deep clone of the XMP object. Assignment and copy constructors do + /// not, they just increment a reference count. Note that \c Clone returns an object, not a + /// pointer. This is easy to misuse: + /// + /// \code + /// SXMPMeta * clone1 = &sourceXMP.Clone(); // ! This does not work! + /// SXMPMeta * clone2 = new SXMPMeta ( sourceXMP.Clone() ); // This works. + /// SXMPMeta clone3 ( sourceXMP.Clone ); // This works also. (Not a pointer.) + /// \endcode + /// + /// In the code above, the assignment to \c clone1 creates a temporary object, initializes it + /// with the clone, assigns the address of the temporary to \c clone1, then deletes the + /// temporary. The \c clone3 example also works, you do not have to use an explicit pointer. + /// This is good for local usage, you don't have to worry about memory leaks. + /// + /// \param options Option flags, not are defined at present. + /// + /// \result An XMP object cloned from the original. + + TXMPMeta + Clone ( XMP_OptionBits options = 0 ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief CountArrayItems --TBD-- + + XMP_Index + CountArrayItems ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief \c DumpObject dumps the content of an XMP object. + + XMP_Status + DumpObject ( XMP_TextOutputProc outProc, + void * refCon ) const; + + /// @} + + // ============================================================================================= + + // -------------------------------------------------------------------------------------------- + /// \name Functions for parsing and serializing. + /// @{ + /// These functions support parsing serialized RDF into an XMP object, and serailizing an XMP + /// object into RDF. The input for parsing may be any valid Unicode encoding. ISO Latin-1 is + /// also recognized, but its use is strongly discouraged. Serialization is always as UTF-8. + + // -------------------------------------------------------------------------------------------- + /// \brief \c ParseFromBuffer parses RDF from a series of input buffers. The buffers may be any + /// length. The buffer boundaries need not respect XML tokens or even Unicode characters. + /// + /// \param buffer A pointer to a buffer of input. May be null if \c bufferSize is 0. + /// + /// \param bufferSize The length of this buffer in bytes. Zero is a valid value. Termination of + /// an input loop is convenient by passing \c kXMP_ParseMoreBuffers for all real input, then + /// having a final call with a zero length and \c kXMP_NoOptions. + /// + /// \param options Options controlling the parsing. + /// + /// The available options are: + /// + /// \li \c kXMP_ParseMoreBuffers - This is not the last buffer of input, more calls follow. + /// \li \c kXMP_RequireXMPMeta - The x:xmpmeta XML element is required around <tt>rdf:RDF</tt>. + /// \li \c kXMP_StrictAliasing - Do not reconcile alias differences, throw an exception. + /// + /// \note The \c kXMP_StrictAliasing option is not yet implemented. + + void + ParseFromBuffer ( XMP_StringPtr buffer, + XMP_StringLen bufferSize, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief \c SerializeToBuffer serializes an XMP object into a string as RDF. + /// + /// \param rdfString A pointer to the string to receive the serialized RDF. Must not be null. + /// + /// \param options Option flags to control the serialization. + /// + /// \param padding The amount of padding to be added if a writeable XML packet is created. If + /// zero is passed (the default) an appropriate amount of padding is computed. + /// + /// \param newline The string to be used as a line terminator. If empty it defaults to + /// linefeed, U+000A, the standard XML newline. + /// + /// \param indent The string to be used for each level of indentation in the serialized RDF. If + /// empty it defaults to two ASCII spaces, U+0020. + /// + /// \param baseIndent The number of levels of indentation to be used for the outermost XML + /// element in the serialized RDF. This is convenient when embedding the RDF in other text. + /// + /// The available option flags are: + /// + /// \li \c kXMP_OmitPacketWrapper - Do not include an XML packet wrapper. + /// \li \c kXMP_ReadOnlyPacket - Create a read-only XML packet wapper. + /// \li \c kXMP_UseCompactFormat - Use a highly compact RDF syntax and layout. + /// \li \c kXMP_WriteAliasComments - Include XML comments for aliases. + /// \li \c kXMP_IncludeThumbnailPad - Include typical space for a JPEG thumbnail in the padding + /// if no <tt>xmp:Thumbnails</tt> property is present. + /// \li \c kXMP_ExactPacketLength - The padding parameter provides the overall packet length. + /// The actual amount of padding is computed. An exception is thrown if the packet exceeds this + /// length with no padding. + /// + /// The specified options must be logically consistent, an exception is thrown if not. You + /// cannot specify both \c kXMP_OmitPacketWrapper along with \c kXMP_ReadOnlyPacket, \c + /// kXMP_IncludeThumbnailPad, or \c kXMP_ExactPacketLength. + /// + /// In addition, one of the following encoding options may be included: + /// + /// \li \c kXMP_EncodeUTF8 - Encode as UTF-8, the default. + /// \li \c kXMP_EncodeUTF16Big - Encode as big-endian UTF-16. + /// \li \c kXMP_EncodeUTF16Little - Encode as little-endian UTF-16. + /// \li \c kXMP_EncodeUTF32Big - Encode as big-endian UTF-32. + /// \li \c kXMP_EncodeUTF32Little - Encode as little-endian UTF-32. + + void + SerializeToBuffer ( tStringObj * rdfString, + XMP_OptionBits options, + XMP_StringLen padding, + XMP_StringPtr newline, + XMP_StringPtr indent = "", + XMP_Index baseIndent = 0 ) const; + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c SerializeToBuffer is a simple overload in the template that calls the + /// above form passing default values for the \c newline, \c indent, and \c baseIndent + /// parameters. + + void + SerializeToBuffer ( tStringObj * rdfString, + XMP_OptionBits options = 0, + XMP_StringLen padding = 0 ) const; + + /// @} + + // ============================================================================================= + + XMPMetaRef xmpRef; // *** Should be private, see below. + +private: + +#if 0 // *** VS.Net and gcc seem to not handle the friend declarations properly. + friend class TXMPIterator <class tStringObj>; + friend class TXMPUtils <class tStringObj>; +#endif + +}; // class TXMPMeta + +#endif // __TXMPMeta_hpp__ diff --git a/public/include/TXMPUtils.hpp b/public/include/TXMPUtils.hpp new file mode 100644 index 0000000..95cdc9c --- /dev/null +++ b/public/include/TXMPUtils.hpp @@ -0,0 +1,845 @@ +#ifndef __TXMPUtils_hpp__ +#define __TXMPUtils_hpp__ 1 + +#if ( ! __XMP_hpp__ ) + #error "Do not directly include, use XMP.hpp" +#endif + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file TXMPUtils.hpp +/// \brief Template class for the XMP Toolkit utility services. +/// +/// \c TXMPUtils is the template class providing utility services for the XMP Toolkit. It should be +/// instantiated with a string class such as <tt>std::string</tt>. Please read the general toolkit +/// usage notes for information about the overall architecture of the XMP API. +// ================================================================================================ + +// ================================================================================================ +/// \class TXMPUtils TXMPUtils.hpp +/// \brief Template class for the XMP Toolkit utility services. +/// +/// \c TXMPUtils is the template class providing utility services for the XMP Toolkit. It should be +/// instantiated with a string class such as <tt>std::string</tt>. Please read the general toolkit +/// usage notes for information about the overall architecture of the XMP API. +/// +/// This is a class for C++ scoping purposes only. It has only static functions, you cannot create +/// an object. These are all functions that layer cleanly on top of the core XMP toolkit. The +/// template wraps a string class around the raw XMP API, so that output strings are automatically +/// copied and access is fully thread safe. String objects are only necessary for output strings. +/// Input strings are literals and passed as typical C <tt>const char *</tt>. +/// +/// The template parameter, class \c TtStringObj, is described in the XMP.hpp umbrella header. +// ================================================================================================ + +template <class tStringObj> +class TXMPUtils { + +public: + + // ============================================================================================= + // No constructors or destructor declared or needed + // ================================================ + + // ============================================================================================= + // ============================================================================================= + + // ============================================================================================ + /// \name Path composition functions + /// @{ + /// These functions provide support for composing path expressions to deeply nested properties. + /// The functions in \c TXMPMeta such as \c GetProperty, \c GetArrayItem, and \c GetStructField + /// provide easy access to top level simple properties, items in top level arrays, and fields + /// of top level structs. They do not provide convenient access to more complex things like + /// fields several levels deep in a complex struct, or fields within an array of structs, or + /// items of an array that is a field of a struct. These functions can also be used to compose + /// paths to top level array items or struct fields so that you can use the binary accessors + /// like \c GetProperty_Int. + /// + /// You can use these functions is to compose a complete path expression, or all but the last + /// component. Suppose you have a property that is an array of integers within a struct. You can + /// access one of the array items like this: + /// + /// \verbatim + /// SXMPUtils::ComposeStructFieldPath ( schemaNS, "Struct", fieldNS, "Array", &path ); + /// SXMPUtils::ComposeArrayItemPath ( schemaNS, path, index, &path ); + /// exists = xmpObj.GetProperty_Int ( schemaNS, path, &value, &options ); + /// \endverbatim + /// + /// You could also use this code if you want the string form of the integer: + /// + /// \verbatim + /// SXMPUtils::ComposeStructFieldPath ( schemaNS, "Struct", fieldNS, "Array", &path ); + /// xmpObj.GetArrayItem ( schemaNS, path, index, &value, &options ); + /// \endverbatim + /// + /// \note It might look confusing that the \c schemaNS is passed in all of the calls above. This + /// is because the XMP toolkit keeps the top level "schema" namespace separate from the rest + /// of the path expression. + + // -------------------------------------------------------------------------------------------- + /// \brief Compose the path expression for an item in an array. + /// + /// \param schemaNS The namespace URI for the array. Must not be null or the empty string. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. + /// + /// \param itemIndex The index of the desired item. Arrays in XMP are indexed from 1. The + /// constant \c kXMP_ArrayLastItem always refers to the last existing array item. + /// + /// \param fullPath A pointer to the string that will be assigned the composed path. This will + /// be of the form <tt>ns:arrayName[i]</tt>, where "ns" is the prefix for \c schemaNS and "i" + /// is the decimal representation of \c itemIndex. If the value of \c itemIndex is + /// \c kXMP_ArrayLastItem, the path is <tt>ns:arrayName[last()]</tt>. + + static void + ComposeArrayItemPath ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + tStringObj * fullPath ); + + // -------------------------------------------------------------------------------------------- + /// \brief Compose the path expression for a field in a struct. + /// + /// \param schemaNS The namespace URI for the struct. Must not be null or the empty string. + /// + /// \param structName The name of the struct. May be a general path expression, must not be null + /// or the empty string. + /// + /// \param fieldNS The namespace URI for the field. Must not be null or the empty string. + /// + /// \param fieldName The name of the field. Must be a simple XML name, must not be null or the + /// empty string. + /// + /// \param fullPath A pointer to the string that will be assigned the composed path. This will + /// be of the form <tt>ns:structName/fNS:fieldName</tt>, where "ns" is the prefix for + /// \c schemaNS and "fNS" is the prefix for \c fieldNS. + + static void + ComposeStructFieldPath ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + tStringObj * fullPath ); + + // -------------------------------------------------------------------------------------------- + /// \brief Compose the path expression for a qualifier. + /// + /// \param schemaNS The namespace URI for the property to which the qualifier is attached. Must + /// not be null or the empty string. + /// + /// \param propName The name of the property to which the qualifier is attached. May be a general + /// path expression, must not be null or the empty string. + /// + /// \param qualNS The namespace URI for the qualifier. May be null or the empty string if the + /// qualifier is in the XML empty namespace. + /// + /// \param qualName The name of the qualifier. Must be a simple XML name, must not be null or the + /// empty string. + /// + /// \param fullPath A pointer to the string that will be assigned the composed path. This will + /// be of the form <tt>ns:propName/?qNS:qualName</tt>, where "ns" is the prefix for \c schemaNS + /// and "qNS" is the prefix for \c qualNS. + + static void + ComposeQualifierPath ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + tStringObj * fullPath ); + + // -------------------------------------------------------------------------------------------- + /// \brief Compose the path expression to select an alternate item by language. + /// + /// The path syntax allows two forms of "content addressing" that may be used to select an item + /// in an array of alternatives. The form used in \c ComposeLangSelector lets you select an + /// item in an alt-text array based on the value of its <tt>xml:lang</tt> qualifier. The other + /// form of content addressing is shown in \c ComposeFieldSelector. + /// + /// \note \c ComposeLangSelector does not supplant \c SetLocalizedText or \c GetLocalizedText. + /// They should generally be used, as they provide extra logic to choose the appropriate + /// language and maintain consistency with the 'x-default' value. \c ComposeLangSelector gives + /// you an path expression that is explicitly and only for the language given in the + /// \c langName parameter. + /// + /// \param schemaNS The namespace URI for the array. Must not be null or the empty string. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. + /// + /// \param langName The RFC 3066 code for the desired language. + /// + /// \param fullPath A pointer to the string that will be assigned the composed path. This will + /// be of the form <tt>ns:arrayName[\@xml:lang='langName']</tt>, + /// where "ns" is the prefix for \c schemaNS. + + static void + ComposeLangSelector ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr langName, + tStringObj * fullPath ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c ComposeLangSelector is a simple overload in the template that calls + /// the above form passing <tt>langName.c_str()</tt>. + + static void + ComposeLangSelector ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + const tStringObj & langName, + tStringObj * fullPath ); + + // -------------------------------------------------------------------------------------------- + /// \brief Compose the path expression to select an alternate item by a field's value. + /// + /// The path syntax allows two forms of "content addressing" that may be used to select an item + /// in an array of alternatives. The form used in \c ComposeFieldSelector lets you select an + /// item in an array of structs based on the value of one of the fields in the structs. The + /// other form of content addressing is shown in \c ComposeLangSelector. + /// + /// For example, consider a simple struct that has two fields, the name of a city and the URI + /// of an FTP site in that city. Use this to create an array of download alternatives. You can + /// show the user a popup built from the values of the city fields. You can then get the + /// corresponding URI as follows: + /// + /// \verbatim + /// ComposeFieldSelector ( schemaNS, "Downloads", fieldNS, "City", chosenCity, &path ); + /// exists = GetStructField ( schemaNS, path, fieldNS, "URI", &uri ); + /// \endverbatim + /// + /// \param schemaNS The namespace URI for the array. Must not be null or the empty string. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. + /// + /// \param fieldNS The namespace URI for the field used as the selector. Must not be null or the + /// empty string. + /// + /// \param fieldName The name of the field used as the selector. Must be a simple XML name, must + /// not be null or the empty string. It must be the name of a field that is itself simple. + /// + /// \param fieldValue The desired value of the field. + /// + /// \param fullPath A pointer to the string that will be assigned the composed path. This will + /// be of the form <tt>ns:arrayName[fNS:fieldName='fieldValue']</tt>, where "ns" is the prefix + /// for \c schemaNS and "fNS" is the prefix for \c fieldNS. + + static void + ComposeFieldSelector ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + XMP_StringPtr fieldValue, + tStringObj * fullPath ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of ComposeFieldSelector is a simple overload in the template that calls the + /// above form passing <tt>fieldValue.c_str()</tt>. + + static void + ComposeFieldSelector ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + const tStringObj & fieldValue, + tStringObj * fullPath ); + + /// @} + + // ============================================================================================= + // ============================================================================================= + + // ============================================================================================ + /// \name Binary-String conversion functions + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from Boolean to string. + /// + /// \param binValue The Boolean value to be converted. + /// + /// \param strValue The string representation of the Boolean. The values used are given by the + /// macros \c kXMP_TrueStr and \c kXMP_FalseStr found in \c XMP_Const.h. + + static void + ConvertFromBool ( bool binValue, + tStringObj * strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from integer to string. + /// + /// \param binValue The integer value to be converted. + /// + /// \param format Optional C sprintf format for the conversion. Defaults to "%d". + /// + /// \param strValue The string representation of the integer. + + static void + ConvertFromInt ( long binValue, + XMP_StringPtr format, + tStringObj * strValue ); + + static void + ConvertFromInt64 ( long long binValue, + XMP_StringPtr format, + tStringObj * strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from floating point to string. + /// + /// \param binValue The floating point value to be converted. + /// + /// \param format Optional C sprintf format for the conversion. Defaults to "%f". + /// + /// \param strValue The string representation of the floating point value. + + static void + ConvertFromFloat ( double binValue, + XMP_StringPtr format, + tStringObj * strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from date/time to string. + /// + /// Format a date according to the ISO 8601 profile in http://www.w3.org/TR/NOTE-datetime: + /// YYYY + /// YYYY-MM + /// YYYY-MM-DD + /// YYYY-MM-DDThh:mmTZD + /// YYYY-MM-DDThh:mm:ssTZD + /// YYYY-MM-DDThh:mm:ss.sTZD + /// + /// YYYY = four-digit year + /// MM = two-digit month (01=January, etc.) + /// DD = two-digit day of month (01 through 31) + /// hh = two digits of hour (00 through 23) + /// mm = two digits of minute (00 through 59) + /// ss = two digits of second (00 through 59) + /// s = one or more digits representing a decimal fraction of a second + /// TZD = time zone designator (Z or +hh:mm or -hh:mm) + /// + /// \note ISO 8601 does not seem to allow years less than 1000 or greater than 9999. We allow + /// any year, even negative ones. The year is formatted as "%.4d". + /// + /// \note As a compatibility "tactic" (OK, a hack), so-called time-only input is allowed where + /// the year, month, and day are all zero. This is output as "0000-00-00...". + /// + /// \param binValue The \c XMP_DateTime value to be converted. + /// + /// \param strValue The ISO 8601 string representation of the date/time. + + static void + ConvertFromDate ( const XMP_DateTime & binValue, + tStringObj * strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from string to Boolean. + /// + /// \param strValue The string representation of the Boolean. + /// + /// \result The appropriate C++ bool value for the string. The preferred strings are + /// \c kXMP_TrueStr and \c kXMP_FalseStr. If these do not match, a case insensitive comparison is + /// tried, then simply 't' or 'f', and finally non-zero and zero integer representations. + + static bool + ConvertToBool ( XMP_StringPtr strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c ConvertToBool is a simple overload in the template that calls the + /// above form passing <tt>strValue.c_str()</tt>. + + static bool + ConvertToBool ( const tStringObj & strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from string to integer. + /// + /// \param strValue The string representation of the integer. + /// + /// \result The integer value as a C long. + + static long + ConvertToInt ( XMP_StringPtr strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c ConvertToInt is a simple overload in the template that calls the above + /// form passing <tt>strValue.c_str()</tt>. + + static long + ConvertToInt ( const tStringObj & strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from string to 64 bit integer. + /// + /// \param strValue The string representation of the integer. + /// + /// \result The integer value as a C long long. + + static long long + ConvertToInt64 ( XMP_StringPtr strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of ConvertToInt64 is a simple overload in the template that calls the above + /// form passing <tt>strValue.c_str()</tt>. + + static long long + ConvertToInt64 ( const tStringObj & strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from string to floating point. + /// + /// \param strValue The string representation of the floating point value. + /// + /// \result The floating point value. + + static double + ConvertToFloat ( XMP_StringPtr strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c ConvertToFloat is a simple overload in the template that calls the + /// above form passing <tt>strValue.c_str()</tt>. + + static double + ConvertToFloat ( const tStringObj & strValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from string to date/time. + /// + /// Parse a date according to the ISO 8601 profile in http://www.w3.org/TR/NOTE-datetime: + /// YYYY + /// YYYY-MM + /// YYYY-MM-DD + /// YYYY-MM-DDThh:mmTZD + /// YYYY-MM-DDThh:mm:ssTZD + /// YYYY-MM-DDThh:mm:ss.sTZD + /// + /// YYYY = four-digit year + /// MM = two-digit month (01=January, etc.) + /// DD = two-digit day of month (01 through 31) + /// hh = two digits of hour (00 through 23) + /// mm = two digits of minute (00 through 59) + /// ss = two digits of second (00 through 59) + /// s = one or more digits representing a decimal fraction of a second + /// TZD = time zone designator (Z or +hh:mm or -hh:mm) + /// + /// \note ISO 8601 does not seem to allow years less than 1000 or greater than 9999. We allow + /// any year, even negative ones. The year is assumed to be formatted as "%.4d". + /// + /// \note As compatibility "tactics" (OK, hacks), a missing date portion or missing TZD are + /// tolerated. A missing date value may begin with "Thh:" or "hh:"; the year, month, and day are + /// all set to zero in the XMP_DateTime value. A missing TZD is assumed to be UTC. + /// + /// \param strValue The ISO 8601 string representation of the date/time. + /// + /// \param binValue A pointer to the \c XMP_DateTime variable to be assigned the date/time components. + + static void + ConvertToDate ( XMP_StringPtr strValue, + XMP_DateTime * binValue ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c ConvertToDate is a simple overload in the template that calls the above + /// form passing s<tt>strValue.c_str()</tt>. + + static void + ConvertToDate ( const tStringObj & strValue, + XMP_DateTime * binValue ); + + /// @} + + // ============================================================================================= + // ============================================================================================= + + // ============================================================================================ + /// \name Date/Time functions + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief Obtain the current date and time. + /// + /// \param time A pointer to the \c XMP_DateTime variable to be assigned the current date + /// and time. The returned time is UTC, properly adjusted for the local time zone. The + /// resolution of the time is not guaranteed to be finer than seconds. + + static void + CurrentDateTime ( XMP_DateTime * time ); + + // -------------------------------------------------------------------------------------------- + /// \brief Set the local time zone. + /// + /// \param time A pointer to the \c XMP_DateTime variable containing the value to be modified. Any + /// existing time zone value is replaced, the other date/time fields are not adjusted in any way. + + static void + SetTimeZone ( XMP_DateTime * time ); + + // -------------------------------------------------------------------------------------------- + /// \brief Make sure a time is UTC. + /// + /// \param time A pointer to the \c XMP_DateTime variable containing the time to be modified. If + /// the time zone is not UTC, the time is adjusted and the time zone set to be UTC. + + static void + ConvertToUTCTime ( XMP_DateTime * time ); + + // -------------------------------------------------------------------------------------------- + /// \brief Make sure a time is local. + /// + /// \param time A pointer to the \c XMP_DateTime variable containing the time to be modified. If + /// the time zone is not the local zone, the time is adjusted and the time zone set to be local. + + static void + ConvertToLocalTime ( XMP_DateTime * time ); + + // -------------------------------------------------------------------------------------------- + /// \brief Compare the order of two date/time values. + /// + /// \param left The "lefthand" date/time. + /// + /// \param right The "righthand" date/time. + /// + /// \result + /// \li -1 if left is before right + /// \li 0 if left matches right + /// \li +1 if left is after right + + static int + CompareDateTime ( const XMP_DateTime & left, + const XMP_DateTime & right ); + + /// @} + + // ============================================================================================= + // ============================================================================================= + + // ============================================================================================ + /// \name Base 64 Encoding and Decoding + /// @{ + + // -------------------------------------------------------------------------------------------- + /// \brief Convert from raw data to Base64 encoded string. + /// + /// \param rawStr The pointer to raw data to be converted. + /// + /// \param rawLen The length of raw data to be converted. + /// + /// \param encodedStr The XMP object to contain the encoded string. + + static void + EncodeToBase64 ( XMP_StringPtr rawStr, + XMP_StringLen rawLen, + tStringObj * encodedStr ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c EncodeToBase64 is a simple overload in the template that calls the + /// above form passing <tt>rawStr.c_str()</tt>, and <tt>rawStr.size()</tt>. + + static void + EncodeToBase64 ( const tStringObj & rawStr, + tStringObj * encodedStr ); + + // -------------------------------------------------------------------------------------------- + /// \brief Decode from Base64 encoded string to raw data. + /// + /// \param encodedStr The pointer to encoded data to be converted. + /// + /// \param encodedLen The length of encoded datavto be converted. + /// + /// \param rawStr The XMP object to contain the decoded string. + + static void + DecodeFromBase64 ( XMP_StringPtr encodedStr, + XMP_StringLen encodedLen, + tStringObj * rawStr ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c DecodeFromBase64 is a simple overload in the template that calls the + /// above form passing <tt>encodedStr.c_str()</tt>, and <tt>encodedStr.size()</tt>. + + static void + DecodeFromBase64 ( const tStringObj & encodedStr, + tStringObj * rawStr ); + + /// @} + + // ============================================================================================= + // ============================================================================================= + + // ============================================================================================ + /// \name JPEG file handling + /// @{ + /// These functions support the partitioning of XMP in JPEG files into standard and extended + /// portions in order to work around the 64KB size limit of JPEG marker segments. + + // -------------------------------------------------------------------------------------------- + /// \brief Create XMP serializations appropriate for a JPEG file. The standard XMP in a JPEG + /// file is limited to about 65500 bytes. \c PackageForJPEG attempts to fit the serialization + /// within that limit. If necessary it will partition the XMP into 2 serializations. + /// + /// \param xmpObj The XMP for the JPEG file. + /// + /// \param standardXMP The full standard XMP packet. + /// + /// \param extendedXMP The serialized extended XMP, empty if not needed. + /// + /// \param extendedDigest An MD5 digest of the serialized extended XMP, empty if not needed. + + static void + PackageForJPEG ( const TXMPMeta<tStringObj> & xmpObj, + tStringObj * standardXMP, + tStringObj * extendedXMP, + tStringObj * extendedDigest ); + + // -------------------------------------------------------------------------------------------- + /// \brief Put the extended XMP properties back into the full XMP. + /// + /// \param fullXMP The full XMP, presumed to be initialized from the standard XMP packet. + /// + /// \param extendedXMP The properties that were partitioned into the extended XMP. + + static void + MergeFromJPEG ( TXMPMeta<tStringObj> * fullXMP, + const TXMPMeta<tStringObj> & extendedXMP ); + + /// @} + + // ============================================================================================= + // ============================================================================================= + + // ============================================================================================ + /// \name UI helper functions + /// @{ + /// These functions are mainly of interest in implementing a user interface for editing XMP. + + // -------------------------------------------------------------------------------------------- + /// \brief Create a single edit string from an array of strings. + /// + /// TBD - needs more description + /// + /// \param xmpObj The XMP object containing the array to be catenated. + /// + /// \param schemaNS The schema namespace URI for the array. Must not be null or the empty string. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. Each item in the array must be a simple string value. + /// + /// \param separator The string to be used to separate the items in the catenated string. + /// Defaults to "; ", ASCII semicolon and space (U+003B, U+0020). + /// + /// \param quotes The characters to be used as quotes around array items that contain a separator. + /// Defaults to '"', ASCII quote (U+0022). + /// + /// \param options Option flags to control the catenation. + /// + /// \param catedStr A pointer to the string to be assigned the catenated array items. + + static void + CatenateArrayItems ( const TXMPMeta<tStringObj> & xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr separator, + XMP_StringPtr quotes, + XMP_OptionBits options, + tStringObj * catedStr ); + + // -------------------------------------------------------------------------------------------- + /// \brief Separate a single edit string into an array of strings. + /// + /// TBD - needs more description + /// + /// \param xmpObj The XMP object containing the array to be updated. + /// + /// \param schemaNS The schema namespace URI for the array. Must not be null or the empty string. + /// + /// \param arrayName The name of the array. May be a general path expression, must not be null + /// or the empty string. Each item in the array must be a simple string value. + /// + /// \param options Option flags to control the separation. + /// + /// \param catedStr The string to be separated into the array items. + + static void + SeparateArrayItems ( TXMPMeta<tStringObj> * xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits options, + XMP_StringPtr catedStr ); + + // -------------------------------------------------------------------------------------------- + /// \brief This form of \c SeparateArrayItems is a simple overload in the template that calls + /// the aboveform passing <tt>catedStr.c_str()</tt>. + + static void + SeparateArrayItems ( TXMPMeta<tStringObj> * xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits options, + const tStringObj & catedStr ); + + // -------------------------------------------------------------------------------------------- + /// \brief Remove multiple properties from an XMP object. + /// + /// \c RemoveProperties was created to support the File Info dialog's Delete button, and has + /// been been generalized somewhat from those specific needs. It operates in one of three main + /// modes depending on the schemaNS and propName parameters: + /// + /// \li Non-empty \c schemaNS and \c propName - The named property is removed if it is an + /// external property, or if the \c kXMPUtil_DoAllProperties option is passed. It does not + /// matter whether the named property is an actual property or an alias. + /// + /// \li Non-empty \c schemaNS and empty \c propName - The all external properties in the named + /// schema are removed. Internal properties are also removed if the \c kXMPUtil_DoAllProperties + /// option is passed. In addition, aliases from the named schema will be removed if the \c + /// kXMPUtil_IncludeAliases option is passed. + /// + /// \li Empty \c schemaNS and empty \c propName - All external properties in all schema are + /// removed. Internal properties are also removed if the \c kXMPUtil_DoAllProperties option is + /// passed. Aliases are implicitly handled because the associated actuals are. + /// + /// It is an error to pass and empty schemaNS and non-empty propName. + /// + /// \param xmpObj The XMP object containing the properties to be removed. + /// + /// \param schemaNS Optional schema namespace URI for the properties to be removed. + /// + /// \param propName Optional path expression for the property to be removed. + /// + /// \param options Option flags to control the deletion. The defined flags are: + /// \li \c kXMPUtil_DoAllProperties - Do internal properties in addition to external properties. + /// \li \c kXMPUtil_IncludeAliases - Include aliases in the "named schema" case above. + + static void + RemoveProperties ( TXMPMeta<tStringObj> * xmpObj, + XMP_StringPtr schemaNS = 0, + XMP_StringPtr propName = 0, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief Append properties from one XMP object to another. + /// + /// \c AppendProperties was created to support the File Info dialog's Append button, and has + /// been been generalized somewhat from those specific needs. It appends information from one + /// XMP object (\c source) to another (\c dest). The default operation is to append only external + /// properties that do not already exist in the destination. The kXMPUtil_DoAllProperties option + /// can be used to operate on all properties, external and internal. The kXMPUtil_ReplaceOldValues + /// option can be used to replace the values of existing properties. The notion of external + /// versus internal applies only to top level properties. The keep-or-replace-old notion applies + /// within structs and arrays as described below. + /// + /// If kXMPUtil_ReplaceOldValues is passed then the processing is restricted to the top level + /// properties. The processed properties from the source (according to kXMPUtil_DoAllProperties) + /// are propagated to the destination, replacing any existing values. Properties in the destination + /// that are not in the source are left alone. + /// + /// If kXMPUtil_ReplaceOldValues is not passed then the processing is more complicated. Top level + /// properties are added to the destination if they do not already exist. If they do exist but + /// differ in form (simple/struct/array) then the destination is left alone. If the forms match, + /// simple properties are left unchanged while structs and arrays are merged. + /// + /// If kXMPUtil_DeleteEmptyValues is passed then an empty value in the source XMP causes the + /// corresponding Dest XMP property to be deleted. The default is to treat empty values the same + /// as non-empty values. An empty value is any of a simple empty string, an array with no items, + /// or a struct with no fields. Qualifiers are ignored. + /// + /// The detailed behavior is defined by the following pseudo-code: + /// \verbatim + /// AppendProperties ( sourceXMP, destXMP, options ): + /// doAll = options & kXMPUtil_DoAllProperties + /// replaceOld = options & kXMPUtil_ReplaceOldValues + /// deleteEmpty = options & kXMPUtil_DeleteEmptyValues + /// for all source schema (top level namespaces): + /// for all top level properties in sourceSchema: + /// if doAll or prop is external: + /// AppendSubtree ( sourceNode, destSchema, replaceOld, deleteEmpty ) + /// + /// AppendSubtree ( sourceNode, destParent, replaceOld, deleteEmpty ): + /// if deleteEmpty and source value is empty: + /// delete the corresponding child from destParent + /// else if sourceNode not in destParent (by name): + /// copy sourceNode's subtree to destParent + /// else if replaceOld: + /// delete subtree from destParent + /// copy sourceNode's subtree to destParent + /// else: + /// // Already exists in dest and not replacing, merge structs and arrays + /// if sourceNode and destNode forms differ: + /// return, leave the destNode alone + /// else if form is a struct: + /// for each field in sourceNode: + /// AppendSubtree ( sourceNode.field, destNode, replaceOld ) + /// else if form is an alt-text array: + /// copy new items by xml:lang value into the destination + /// else if form is an array: + /// copy new items by value into the destination, ignoring order and duplicates + /// \endverbatim + /// + /// \note \c AppendProperties can be expensive if replaceOld is not passed and the XMP contains + /// large arrays. The array item checking described above is n-squared. Each source item is + /// checked to see if it already exists in the destination, without regard to order or duplicates. + /// Simple items are compared by value and xml:lang qualifier, other qualifiers are ignored. + /// Structs are recursively compared by field names, without regard to field order. Arrays are + /// compared by recursively comparing all items. + /// + /// \param source The source XMP object. + /// + /// \param dest The destination XMP object. + /// + /// \param options Option flags to control the copying. + /// \li \c kXMPUtil_DoAllProperties - Do internal properties in addition to external properties. + /// \li \c kXMPUtil_ReplaceOldValues - Replace the values of existing properties. + /// \li \c kXMPUtil_DeleteEmptyValues - Delete properties if the new value is empty. + + static void + AppendProperties ( const TXMPMeta<tStringObj> & source, + TXMPMeta<tStringObj> * dest, + XMP_OptionBits options = 0 ); + + // -------------------------------------------------------------------------------------------- + /// \brief Replicate a subtree from one XMP object into another, possibly at a different location. + /// + /// TBD - needs more description + /// + /// \param source The source XMP object. + /// + /// \param dest The destination XMP object. + /// + /// \param sourceNS The schema namespace URI for the source subtree. + /// + /// \param sourceRoot The root location for the source subtree. May be a general path expression, + /// must not be null or the empty string. + /// + /// \param destNS The schema namespace URI for the destination. Defaults to the source namespace. + /// + /// \param destRoot The root location for the destination. May be a general path expression. + /// Defaults to the source location. + /// + /// \param options Option flags to control the separation. + + 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 ); + + + /// @} + + // ============================================================================================= + +}; // class TXMPUtils + +// ================================================================================================= + +#endif // __TXMPUtils_hpp__ diff --git a/public/include/XMP.hpp b/public/include/XMP.hpp new file mode 100644 index 0000000..2ceb936 --- /dev/null +++ b/public/include/XMP.hpp @@ -0,0 +1,98 @@ +#ifndef __XMP_hpp__ +#define __XMP_hpp__ 1 + +// ================================================================================================= +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved. +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file XMP.hpp +/// \brief Overall header file for the XMP toolkit. +/// +/// This is an overall header file, the only one that C++ clients should #include. The full client +/// API is in the \c TXMPMeta.hpp, \c TXMPIterator.hpp, \c TXMPUtils.hpp headers. Read these for +/// information, but do not #include them directly. The \c TXMP... classes are C++ template classes +/// that must be instantiated with a string class such as <tt>std::string<\tt>. The string class is +/// used to return text strings for property values, serialized XMP, etc. +/// +/// Clients must also compile <tt>XMP.incl_cpp<\tt> to ensure that all client-side glue code is +/// generated. This should be done by #including it in exactly one client source file. +/// +/// There are two C preprocessor macros that simplify use of the templates: +/// +/// \li \c TXMP_STRING_TYPE - Define this as the string class to use with the template. You will get +/// the template headers included and typedefs (\c SXMPMeta, and so on) to use in your code. +/// +/// \li \c TXMP_EXPAND_INLINE - Define this as 1 if you want to have the template functions expanded +/// inline in your code. Leave it undefined, or defined as 0, to use out-of-line instantiations of +/// the template functions. Compiling <tt>XMP.incl_cpp<\tt> generates explicit out-of-line +/// instantiations if \c TXMP_EXPAND_INLINE is off. +/// +/// The template parameter, class \c tStringObj, must have the following member functions (which match +/// those for <tt>std::string<\tt>): +/// \code +/// tStringObj& assign ( const char * str, size_t len ) +/// size_t size() const +/// const char * c_str() const +/// \endcode +/// The string class must be suitable for at least UTF-8. This is the encoding used for all general +/// values, and is the default encoding for serialized XMP. The string type must also be suitable +/// for UTF-16 or UTF-32 if those serialization encodings are used. This mainly means tolerating +/// embedded 0 bytes, which std::string does. +// ================================================================================================ + + +#include "XMP_Environment.h" // ! This must be the first include! +#include "XMP_Version.h" +#include "XMP_Const.h" + +#if XMP_WinBuild + #if XMP_DebugBuild + #pragma warning ( push, 4 ) + #else + #pragma warning ( push, 3 ) + #endif + #pragma warning ( disable : 4702 ) // unreachable code + #pragma warning ( disable : 4800 ) // forcing value to bool 'true' or 'false' (performance warning) +#endif + +#if defined ( TXMP_STRING_TYPE ) + + #include "TXMPMeta.hpp" + #include "TXMPIterator.hpp" + #include "TXMPUtils.hpp" + + typedef class TXMPMeta <TXMP_STRING_TYPE> SXMPMeta; // For client convenience. + typedef class TXMPIterator <TXMP_STRING_TYPE> SXMPIterator; + typedef class TXMPUtils <TXMP_STRING_TYPE> SXMPUtils; + + #if TXMP_EXPAND_INLINE + #error "TXMP_EXPAND_INLINE is not working at present. Please don't use it." + #include "client-glue/TXMPMeta.incl_cpp" + #include "client-glue/TXMPIterator.incl_cpp" + #include "client-glue/TXMPUtils.incl_cpp" + #include "client-glue/TXMPFiles.incl_cpp" + #endif + + #if XMP_INCLUDE_XMPFILES + #include "TXMPFiles.hpp" // ! Needs typedef for SXMPMeta. + typedef class TXMPFiles <TXMP_STRING_TYPE> SXMPFiles; + #if TXMP_EXPAND_INLINE + #include "client-glue/TXMPFiles.incl_cpp" + #endif + #endif + +#endif // TXMP_STRING_TYPE + +#if XMP_WinBuild + #pragma warning ( pop ) +#endif + + +// ================================================================================================= + +#endif // __XMP_hpp__ diff --git a/public/include/XMP.incl_cpp b/public/include/XMP.incl_cpp new file mode 100644 index 0000000..19b4b5f --- /dev/null +++ b/public/include/XMP.incl_cpp @@ -0,0 +1,69 @@ +#ifndef __XMP_incl_cpp__ +#define __XMP_incl_cpp__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file XMP.incl_cpp +/// \brief Overall client glue file for the XMP toolkit. +/// +/// This is an overall client source file of XMP toolkit glue, the only XMP-specific one that +/// clients should build in projects. This ensures that all of the client-side glue code for the +/// XMP toolkit gets compiled. +/// +/// You cannot compile this file directly, because the template's string type must be declared and +/// only the client can do that. Instead, include this in some other source file. For example, +/// to use <tt>std::string</tt> you only need these two lines: +/// +/// \code +/// #include <string> +/// #include "XMP.incl_cpp" +/// \endcode + + +#include "XMP.hpp" // ! This must be the first include! + +#define XMP_ClientBuild 1 + +#if XMP_WinBuild + #if XMP_DebugBuild + #pragma warning ( push, 4 ) + #else + #pragma warning ( push, 3 ) + #endif + #pragma warning ( disable : 4189 ) // local variable is initialized but not referenced + #pragma warning ( disable : 4702 ) // unreachable code + #pragma warning ( disable : 4800 ) // forcing value to bool 'true' or 'false' (performance warning) +#endif + +#if defined ( TXMP_STRING_TYPE ) && (! TXMP_EXPAND_INLINE) + + // We're using a single out of line instantiation. Do it here. + + #include "client-glue/TXMPMeta.incl_cpp" + #include "client-glue/TXMPIterator.incl_cpp" + #include "client-glue/TXMPUtils.incl_cpp" + + template class TXMPMeta <TXMP_STRING_TYPE>; + template class TXMPIterator <TXMP_STRING_TYPE>; + template class TXMPUtils <TXMP_STRING_TYPE>; + + #if XMP_INCLUDE_XMPFILES + #include "client-glue/TXMPFiles.incl_cpp" + template class TXMPFiles <TXMP_STRING_TYPE>; + #endif + +#endif + +#if XMP_WinBuild + #pragma warning ( pop ) +#endif + +#endif // __XMP_incl_cpp__ diff --git a/public/include/XMP_Const.h b/public/include/XMP_Const.h new file mode 100644 index 0000000..57605bd --- /dev/null +++ b/public/include/XMP_Const.h @@ -0,0 +1,913 @@ +#ifndef __XMP_Const_h__ +#define __XMP_Const_h__ 1 + +/* --------------------------------------------------------------------------------------------- */ +/* ** IMPORTANT ** This file must be usable by strict ANSI C compilers. No "//" comments, etc. */ +/* --------------------------------------------------------------------------------------------- */ + +/* +// ================================================================================================= +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved. +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= +*/ + +#include "XMP_Environment.h" + + #include <stddef.h> + +#if XMP_MacBuild /* ! No stdint.h on Windows and some UNIXes. */ + #include <stdint.h> +#endif + +#if __cplusplus +extern "C" { +#endif + + +/** ================================================================================================ + * \file XMP_Const.h + * \brief Common C/C++ types and constants for the XMP toolkit. + */ + + +/* ============================================================================================== */ +/* Basic types and constants */ +/* ========================= */ + +/* The XMP_... types are used on the off chance that the ..._t types present a problem. In that */ +/* 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 + + typedef int8_t XMP_Int8; + typedef int16_t XMP_Int16; + typedef int32_t XMP_Int32; + typedef int64_t XMP_Int64; + + typedef uint8_t XMP_Uns8; + typedef uint16_t XMP_Uns16; + typedef uint32_t XMP_Uns32; + typedef uint64_t XMP_Uns64; + +#else + + typedef signed char XMP_Int8; + typedef signed short XMP_Int16; + typedef signed long XMP_Int32; + typedef signed long long XMP_Int64; + + typedef unsigned char XMP_Uns8; + typedef unsigned short XMP_Uns16; + typedef unsigned long XMP_Uns32; + typedef unsigned long long XMP_Uns64; + +#endif + +typedef XMP_Uns8 XMP_Bool; + +/* Typedefs to preserve old, unfortunate spellings: */ + +#if 0 /* *** Enable after internal compiles work. */ +typedef XMP_Int8 XMPInt8; +typedef XMP_Int16 XMPInt16; +typedef XMP_Int32 XMPInt32; +typedef XMP_Int64 XMPInt64; +typedef XMP_Uns8 XMPUns8; +typedef XMP_Uns16 XMPUns16; +typedef XMP_Uns32 XMPUns32; +typedef XMP_Uns64 XMPUns64; +typedef XMP_Bool XMPBool; +#endif + +/** + * \typedef XMPMetaRef + * \brief An "ABI safe" pointer to the internal part of an XMP object. + * + * \c XMPMetaRef is an "ABI safe" pointer to the internal part of an XMP object. It should be used + * for passing an XMP object across client DLL boundaries. See the discussion in <tt>TXMPMeta.hpp</tt>. + */ + +typedef struct __XMPMeta__ * XMPMetaRef; +typedef struct __XMPIterator__ * XMPIteratorRef; +typedef struct __XMPFiles__ * XMPFilesRef; + +/* ============================================================================================== */ + +/** + * \name General scalar types and constants + * @{ + */ + +/** + * \typedef XMP_StringPtr + * \brief The type for input string parameters. A <tt>const char *</tt>, a null-terminated UTF-8 string. + * + */ + +/** + * \typedef XMP_StringLen + * \brief The type for string length parameters. A 32-bit unsigned integer, as big as will be + * practically needed. + */ + +/** + * \typedef XMP_Index + * \brief The type for offsets and indices. A 32-bit signed integer. It is signed because that + * often makes loop termination tests safer. + */ + +/** + * \typedef XMP_OptionBits + * \brief The type for a collection of 32 flag bits. Individual flags are defined as enum value + * bit masks. A number of macros provide common set or set operations, e.g. \c XMP_PropIsSimple. + * For other tests use an expression like "options & kXMP_<theOption>". When passing multiple + * option flags use the bitwise-or operator. '|', not the arithmatic plus, '+'. + */ + +typedef const char * XMP_StringPtr; /* Points to a null terminated UTF-8 string. */ +typedef XMP_Uns32 XMP_StringLen; +typedef XMP_Int32 XMP_Index; /* Signed, sometimes -1 is handy. */ +typedef XMP_Uns32 XMP_OptionBits; /* Used as 32 individual bits. */ + +/** + * \def kXMP_TrueStr + * \brief The canonical true string value for Booleans in serialized XMP. Code that converts + * from the string to a bool should be case insensitive, and even allow "1". + */ + +/** + * \def kXMP_FalseStr + * \brief The canonical false string value for Booleans in serialized XMP. Code that converts + * from the string to a bool should be case insensitive, and even allow "0". + */ + +#define kXMP_TrueStr "True" /* Serialized XMP spellings, not for the type bool. */ +#define kXMP_FalseStr "False" + +/** + * @} + */ + +/* ============================================================================================== */ + +/** + * \struct XMP_DateTime + * \brief The expanded type for a date and time. Dates and time in the serialized XMP are ISO 8601 + * strings. The \c XMP_DateTime struct allows easy conversion with other formats. + * + * All of the fields are 32 bit, even though most could be 8 bit. This avoids overflow when doing + * carries for arithmetic or normalization. All fields have signed values for the same reasons. + * + * The fields of the \c XMP_DateTime struct are: + * + * \li year- The year, can be negative. + * \li month - The month in the range 1..12. + * \li day - The day of the month in the range 1..31. + * \li hour - The hour in the range 0..23. + * \li minute - The minute in the range 0..59. + * \li second - The second in the range 0..59. + * \li tzSign - The "sign" of the time zone, 0 means UTC, -1 is west, +1 is east. + * \li tzHour - The time zone hour in the range 0..23. + * \li tzMinute - The time zone minute in the range 0..59. + * \li nanoSecond - Nanoseconds within a second, often left as zero. + * + * Constants for the \c tzSign are: + * + * \li \c kXMP_TimeIsUTC - The time is UTC. + * \li \c kXMP_TimeWestOfUTC - The time zone is west of UTC, behind in time. + * \li \c kXMP_TimeEastOfUTC - The time zone is east of UTC, ahead in time. + * + * DateTime values are occasionally used in cases with only a date or only a time component. A date + * without a time has zeros in the \c XMP_DateTime struct for all time fields. A time without a date + * has zeros for all date fields (year, month, and day). + */ + +struct XMP_DateTime { + XMP_Int32 year; + XMP_Int32 month; /* 1..12 */ + XMP_Int32 day; /* 1..31 */ + XMP_Int32 hour; /* 0..23 */ + XMP_Int32 minute; /* 0..59 */ + XMP_Int32 second; /* 0..59 */ + XMP_Int32 tzSign; /* -1..+1, 0 means UTC, -1 is west, +1 is east. */ + XMP_Int32 tzHour; /* 0..23 */ + XMP_Int32 tzMinute; /* 0..59 */ + XMP_Int32 nanoSecond; +}; + +enum { /* Values used for tzSign field. */ + kXMP_TimeWestOfUTC = -1, + kXMP_TimeIsUTC = 0, + kXMP_TimeEastOfUTC = +1 +}; + + +/* ============================================================================================== */ +/* Standard namespace URI constants */ +/* ================================ */ + +/** + * \name XML namespace constants for standard XMP schema. + * @{ + */ + +/** + * \def kXMP_NS_XMP + * \brief The XML namespace for the XMP "basic" schema. + */ + +/** + * \def kXMP_NS_XMP_Rights + * \brief The XML namespace for the XMP copyright schema. + */ + +/** + * \def kXMP_NS_XMP_MM + * \brief The XML namespace for the XMP digital asset management schema. + */ + +/** + * \def kXMP_NS_XMP_BJ + * \brief The XML namespace for the job management schema. + */ + +/** + * \def kXMP_NS_XMP_T + * \brief The XML namespace for the XMP text document schema. + */ + +/** + * \def kXMP_NS_XMP_T_PG + * \brief The XML namespace for the XMP paged document schema. + */ + +/** + * \def kXMP_NS_PDF + * \brief The XML namespace for the PDF schema. + */ + +/** + * \def kXMP_NS_Photoshop + * \brief The XML namespace for the Photoshop custom schema. + */ + +/** + * \def kXMP_NS_EXIF + * \brief The XML namespace for Adobe's EXIF schema. + */ + +/** + * \def kXMP_NS_TIFF + * \brief The XML namespace for Adobe's TIFF schema. + */ + +/** + * @} + */ + +#define kXMP_NS_XMP "http://ns.adobe.com/xap/1.0/" + +#define kXMP_NS_XMP_Rights "http://ns.adobe.com/xap/1.0/rights/" +#define kXMP_NS_XMP_MM "http://ns.adobe.com/xap/1.0/mm/" +#define kXMP_NS_XMP_BJ "http://ns.adobe.com/xap/1.0/bj/" + +#define kXMP_NS_PDF "http://ns.adobe.com/pdf/1.3/" +#define kXMP_NS_Photoshop "http://ns.adobe.com/photoshop/1.0/" +#define kXMP_NS_PSAlbum "http://ns.adobe.com/album/1.0/" +#define kXMP_NS_EXIF "http://ns.adobe.com/exif/1.0/" +#define kXMP_NS_EXIF_Aux "http://ns.adobe.com/exif/1.0/aux/" +#define kXMP_NS_TIFF "http://ns.adobe.com/tiff/1.0/" +#define kXMP_NS_PNG "http://ns.adobe.com/png/1.0/" +#define kXMP_NS_SWF "http://ns.adobe.com/swf/1.0/" +#define kXMP_NS_JPEG "http://ns.adobe.com/jpeg/1.0/" +#define kXMP_NS_JP2K "http://ns.adobe.com/jp2k/1.0/" +#define kXMP_NS_CameraRaw "http://ns.adobe.com/camera-raw-settings/1.0/" +#define kXMP_NS_DM "http://ns.adobe.com/xmp/1.0/DynamicMedia/" +#define kXMP_NS_ASF "http://ns.adobe.com/asf/1.0/" +#define kXMP_NS_WAV "http://ns.adobe.com/xmp/wav/1.0/" + +#define kXMP_NS_XMP_Note "http://ns.adobe.com/xmp/note/" + +#define kXMP_NS_AdobeStockPhoto "http://ns.adobe.com/StockPhoto/1.0/" + +/** + * \name XML namespace constants for qualifiers and structured property fields. + * @{ + */ + +/** + * \def kXMP_NS_XMP_IdentifierQual + * \brief The XML namespace for qualifiers of the xmp:Identifier property. + */ + +/** + * \def kXMP_NS_XMP_Dimensions + * \brief The XML namespace for fields of the Dimensions type. + */ + +/** + * \def kXMP_NS_XMP_Image + * \brief The XML namespace for fields of a graphical image. Used for the Thumbnail type. + */ + +/** + * \def kXMP_NS_XMP_ResourceEvent + * \brief The XML namespace for fields of the ResourceEvent type. + */ + +/** + * \def kXMP_NS_XMP_ResourceRef + * \brief The XML namespace for fields of the ResourceRef type. + */ + +/** + * \def kXMP_NS_XMP_ST_Version + * \brief The XML namespace for fields of the Version type. + */ + +/** + * \def kXMP_NS_XMP_ST_Job + * \brief The XML namespace for fields of the JobRef type. + */ + +/** + * @} + */ + +#define kXMP_NS_XMP_IdentifierQual "http://ns.adobe.com/xmp/Identifier/qual/1.0/" +#define kXMP_NS_XMP_Dimensions "http://ns.adobe.com/xap/1.0/sType/Dimensions#" +#define kXMP_NS_XMP_Text "http://ns.adobe.com/xap/1.0/t/" +#define kXMP_NS_XMP_PagedFile "http://ns.adobe.com/xap/1.0/t/pg/" +#define kXMP_NS_XMP_Graphics "http://ns.adobe.com/xap/1.0/g/" +#define kXMP_NS_XMP_Image "http://ns.adobe.com/xap/1.0/g/img/" +#define kXMP_NS_XMP_Font "http://ns.adobe.com/xap/1.0/sType/Font#" +#define kXMP_NS_XMP_ResourceEvent "http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" +#define kXMP_NS_XMP_ResourceRef "http://ns.adobe.com/xap/1.0/sType/ResourceRef#" +#define kXMP_NS_XMP_ST_Version "http://ns.adobe.com/xap/1.0/sType/Version#" +#define kXMP_NS_XMP_ST_Job "http://ns.adobe.com/xap/1.0/sType/Job#" +#define kXMP_NS_XMP_ManifestItem "http://ns.adobe.com/xap/1.0/sType/ManifestItem#" + +/* Deprecated constant names */ +#define kXMP_NS_XMP_T "http://ns.adobe.com/xap/1.0/t/" +#define kXMP_NS_XMP_T_PG "http://ns.adobe.com/xap/1.0/t/pg/" +#define kXMP_NS_XMP_G_IMG "http://ns.adobe.com/xap/1.0/g/img/" + +/** + * \name XML namespace constants from outside Adobe. + * @{ + */ + +/** + * \def kXMP_NS_DC + * \brief The XML namespace for the Dublin Core schema. + */ + +/** + * \def kXMP_NS_IPTCCore + * \brief The XML namespace for the IPTC Core schema. + */ + +/** + * \def kXMP_NS_RDF + * \brief The XML namespace for RDF. + */ + +/** + * \def kXMP_NS_XML + * \brief The XML namespace for XML. + */ + +/** + * @} + */ + +#define kXMP_NS_DC "http://purl.org/dc/elements/1.1/" + +#define kXMP_NS_IPTCCore "http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" + +#define kXMP_NS_PDFA_Schema "http://www.aiim.org/pdfa/ns/schema#" +#define kXMP_NS_PDFA_Property "http://www.aiim.org/pdfa/ns/property#" +#define kXMP_NS_PDFA_Type "http://www.aiim.org/pdfa/ns/type#" +#define kXMP_NS_PDFA_Field "http://www.aiim.org/pdfa/ns/field#" +#define kXMP_NS_PDFA_ID "http://www.aiim.org/pdfa/ns/id/" +#define kXMP_NS_PDFA_Extension "http://www.aiim.org/pdfa/ns/extension/" + +#define kXMP_NS_PDFX "http://ns.adobe.com/pdfx/1.3/" +#define kXMP_NS_PDFX_ID "http://www.npes.org/pdfx/ns/id/" + +#define kXMP_NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" +#define kXMP_NS_XML "http://www.w3.org/XML/1998/namespace" + + +/* ============================================================================================== */ +/* Enums and macros used for option bits */ +/* ===================================== */ + +#define kXMP_ArrayLastItem ((XMP_Index)(-1L)) +#define kXMP_UseNullTermination ((XMP_StringLen)(~0UL)) + +#define kXMP_NoOptions ((XMP_OptionBits)0UL) + +#define XMP_SetOption(var,opt) var |= (opt) +#define XMP_ClearOption(var,opt) var &= ~(opt) +#define XMP_TestOption(var,opt) (((var) & (opt)) != 0) +#define XMP_OptionIsSet(var,opt) (((var) & (opt)) != 0) +#define XMP_OptionIsClear(var,opt) (((var) & (opt)) == 0) + +#define XMP_PropIsSimple(opt) (((opt) & kXMP_PropCompositeMask) == 0) +#define XMP_PropIsStruct(opt) (((opt) & kXMP_PropValueIsStruct) != 0) +#define XMP_PropIsArray(opt) (((opt) & kXMP_PropValueIsArray) != 0) +#define XMP_ArrayIsUnordered(opt) (((opt) & kXMP_PropArrayIsOrdered) == 0) +#define XMP_ArrayIsOrdered(opt) (((opt) & kXMP_PropArrayIsOrdered) != 0) +#define XMP_ArrayIsAlternate(opt) (((opt) & kXMP_PropArrayIsAlternate) != 0) +#define XMP_ArrayIsAltText(opt) (((opt) & kXMP_PropArrayIsAltText) != 0) + +#define XMP_PropHasQualifiers(opt) (((opt) & kXMP_PropHasQualifiers) != 0) +#define XMP_PropIsQualifier(opt) (((opt) & kXMP_PropIsQualifier) != 0) +#define XMP_PropHasLang(opt) (((opt) & kXMP_PropHasLang) != 0) + +#define XMP_NodeIsSchema(opt) (((opt) & kXMP_SchemaNode) != 0) +#define XMP_PropIsAlias(opt) (((opt) & kXMP_PropIsAlias) != 0) + +/* ---------------------------------------------------------------------------------------------- */ + +enum { /* Option bits returned from the TXMPMeta::GetXyz functions. */ + + /* Options relating to the XML string form of the property value. */ + kXMP_PropValueIsURI = 0x00000002UL, /* The value is a URI, use rdf:resource attribute. DISCOURAGED */ + + /* Options relating to qualifiers attached to a property. */ + kXMP_PropHasQualifiers = 0x00000010UL, /* The property has qualifiers, includes rdf:type and xml:lang. */ + kXMP_PropIsQualifier = 0x00000020UL, /* This is a qualifier, includes rdf:type and xml:lang. */ + kXMP_PropHasLang = 0x00000040UL, /* Implies kXMP_PropHasQualifiers, property has xml:lang. */ + kXMP_PropHasType = 0x00000080UL, /* Implies kXMP_PropHasQualifiers, property has rdf:type. */ + + /* Options relating to the data structure form. */ + kXMP_PropValueIsStruct = 0x00000100UL, /* The value is a structure with nested fields. */ + kXMP_PropValueIsArray = 0x00000200UL, /* The value is an array (RDF alt/bag/seq). */ + kXMP_PropArrayIsUnordered = kXMP_PropValueIsArray, /* The item order does not matter. */ + kXMP_PropArrayIsOrdered = 0x00000400UL, /* Implies kXMP_PropValueIsArray, item order matters. */ + kXMP_PropArrayIsAlternate = 0x00000800UL, /* Implies kXMP_PropArrayIsOrdered, items are alternates. */ + + /* Additional struct and array options. */ + kXMP_PropArrayIsAltText = 0x00001000UL, /* Implies kXMP_PropArrayIsAlternate, items are localized text. */ + /* kXMP_InsertBeforeItem = 0x00004000UL, ! Used by SetXyz functions. */ + /* kXMP_InsertAfterItem = 0x00008000UL, ! Used by SetXyz functions. */ + + /* Other miscellaneous options. */ + kXMP_PropIsAlias = 0x00010000UL, /* This property is an alias name for another property. */ + kXMP_PropHasAliases = 0x00020000UL, /* This property is the base value for a set of aliases. */ + kXMP_PropIsInternal = 0x00040000UL, /* This property is an "internal" property, owned by applications. */ + kXMP_PropIsStable = 0x00100000UL, /* This property is not derived from the document content. */ + kXMP_PropIsDerived = 0x00200000UL, /* This property is derived from the document content. */ + /* kXMPUtil_AllowCommas = 0x10000000UL, ! Used by TXMPUtils::CatenateArrayItems and ::SeparateArrayItems. */ + /* kXMP_DeleteExisting = 0x20000000UL, ! Used by TXMPMeta::SetXyz functions to delete any pre-existing property. */ + /* kXMP_SchemaNode = 0x80000000UL, ! Returned by iterators - #define to avoid warnings */ + + /* Masks that are multiple flags. */ + kXMP_PropArrayFormMask = kXMP_PropValueIsArray | kXMP_PropArrayIsOrdered | kXMP_PropArrayIsAlternate | kXMP_PropArrayIsAltText, + kXMP_PropCompositeMask = kXMP_PropValueIsStruct | kXMP_PropArrayFormMask, /* Is it simple or composite (array or struct)? */ + kXMP_ImplReservedMask = 0x70000000L /* Reserved for transient use by the implementation. */ +}; + +#define kXMP_SchemaNode ((XMP_OptionBits)0x80000000UL) + +enum { /* Option bits for the TXMPMeta::SetXyz functions. */ + + /* Options shared with GetXyz functions. */ + /* + kXMP_PropValueIsURI = 0x00000002UL, DISCOURAGED + kXMP_PropValueIsStruct = 0x00000100UL, + kXMP_PropValueIsArray = 0x00000200UL, + kXMP_PropArrayIsOrdered = 0x00000400UL, + kXMP_PropArrayIsAlternate = 0x00000800UL, + kXMP_PropArrayIsAltText = 0x00001000UL, + kXMP_PropValueIsCompact = 0x00002000UL, RESERVED + */ + + /* Options for array item location. */ + kXMP_InsertBeforeItem = 0x00004000UL, /* Insert a new item before the given index. */ + kXMP_InsertAfterItem = 0x00008000UL, /* Insert a new item after the given index. */ + + /* Miscellaneous options */ + kXMP_DeleteExisting = 0x20000000UL, /* Delete any pre-existing property. */ + + /* Masks that are multiple flags. */ + kXMP_PropValueOptionsMask = kXMP_PropValueIsURI, + kXMP_PropArrayLocationMask = kXMP_InsertBeforeItem | kXMP_InsertAfterItem + +}; + +/* ---------------------------------------------------------------------------------------------- */ + +enum { /* Options for TXMPMeta::ParseFromBuffer. */ + kXMP_RequireXMPMeta = 0x0001UL, /* Require a surrounding x:xmpmeta element. */ + kXMP_ParseMoreBuffers = 0x0002UL, /* This is the not last input buffer for this parse stream. */ + kXMP_StrictAliasing = 0x0004UL /* Do not reconcile alias differences, throw an exception. */ +}; + +enum { /* Options for TXMPMeta::SerializeToBuffer. */ + + /* *** Option to remove empty struct/array, or leaf with empty value? */ + + kXMP_OmitPacketWrapper = 0x0010UL, /* Omit the XML packet wrapper. */ + kXMP_ReadOnlyPacket = 0x0020UL, /* Default is a writeable packet. */ + kXMP_UseCompactFormat = 0x0040UL, /* Use a compact form of RDF. */ + + kXMP_IncludeThumbnailPad = 0x0100UL, /* Include a padding allowance for a thumbnail image. */ + kXMP_ExactPacketLength = 0x0200UL, /* The padding parameter is the overall packet length. */ + kXMP_WriteAliasComments = 0x0400UL, /* Show aliases as XML comments. */ + kXMP_OmitAllFormatting = 0x0800UL, /* Omit all formatting whitespace. */ + + _XMP_LittleEndian_Bit = 0x0001UL, /* ! Don't use directly, see the combined values below! */ + _XMP_UTF16_Bit = 0x0002UL, + _XMP_UTF32_Bit = 0x0004UL, + + kXMP_EncodingMask = 0x0007UL, + kXMP_EncodeUTF8 = 0UL, + kXMP_EncodeUTF16Big = _XMP_UTF16_Bit, + kXMP_EncodeUTF16Little = _XMP_UTF16_Bit | _XMP_LittleEndian_Bit, + kXMP_EncodeUTF32Big = _XMP_UTF32_Bit, + kXMP_EncodeUTF32Little = _XMP_UTF32_Bit | _XMP_LittleEndian_Bit + +}; + +/* ---------------------------------------------------------------------------------------------- */ + +enum { /* Options for TXMPIterator construction. */ + + kXMP_IterClassMask = 0x00FFUL, /* The low 8 bits are an enum of what data structure to iterate. */ + kXMP_IterProperties = 0x0000UL, /* Iterate the property tree of a TXMPMeta object. */ + kXMP_IterAliases = 0x0001UL, /* Iterate the global alias table. */ + kXMP_IterNamespaces = 0x0002UL, /* Iterate the global namespace table. */ + kXMP_IterJustChildren = 0x0100UL, /* Just do the immediate children of the root, default is subtree. */ + kXMP_IterJustLeafNodes = 0x0200UL, /* Just do the leaf nodes, default is all nodes in the subtree. */ + kXMP_IterJustLeafName = 0x0400UL, /* Return just the leaf part of the path, default is the full path. */ + kXMP_IterIncludeAliases = 0x0800UL, /* Include aliases, default is just actual properties. */ + + kXMP_IterOmitQualifiers = 0x1000UL /* Omit all qualifiers. */ + +}; + +enum { /* Options for TXMPIterator::Skip. */ + kXMP_IterSkipSubtree = 0x0001UL, /* Skip the subtree below the current node. */ + kXMP_IterSkipSiblings = 0x0002UL /* Skip the subtree below and remaining siblings of the current node. */ +}; + +/* ---------------------------------------------------------------------------------------------- */ + +enum { /* Options for TXMPUtils::CatenateArrayItems and TXMPUtils::SeparateArrayItems. */ + + /* Options shared with GetXyz functions. */ + /* + kXMP_PropValueIsArray = 0x00000200UL, + kXMP_PropArrayIsOrdered = 0x00000400UL, + kXMP_PropArrayIsAlternate = 0x00000800UL, + kXMP_PropArrayIsAltText = 0x00001000UL, + */ + + kXMPUtil_AllowCommas = 0x10000000UL /* Allow commas in item values, default is separator. */ + +}; + +enum { /* Options for TXMPUtils::RemoveProperties and TXMPUtils::AppendProperties. */ + kXMPUtil_DoAllProperties = 0x0001UL, /* Do all properties, default is just external properties. */ + kXMPUtil_ReplaceOldValues = 0x0002UL, /* Replace existing values, default is to leave them. */ + kXMPUtil_DeleteEmptyValues = 0x0004UL, /* Delete properties if the new value is empty. */ + kXMPUtil_IncludeAliases = 0x0800UL /* == kXMP_IterIncludeAliases */ +}; + +/* ============================================================================================== */ +/* Types and Constants for XMP File Handler */ +/* ======================================== */ + +enum { + + /* Public file formats. Hex used to avoid gcc warnings. */ + /* ! Leave them as big endian. There seems to be no decent way on UNIX to determine the target */ + /* ! endianness at compile time. Forcing it on the client isn't acceptable. */ + + kXMP_PDFFile = 0x50444620UL, /* 'PDF ' */ + kXMP_PostScriptFile = 0x50532020UL, /* 'PS ', general PostScript following DSC conventions. */ + kXMP_EPSFile = 0x45505320UL, /* 'EPS ', encapsulated PostScript. */ + + kXMP_JPEGFile = 0x4A504547UL, /* 'JPEG' */ + kXMP_JPEG2KFile = 0x4A505820UL, /* 'JPX ', ISO 15444-1 */ + kXMP_TIFFFile = 0x54494646UL, /* 'TIFF' */ + kXMP_GIFFile = 0x47494620UL, /* 'GIF ' */ + kXMP_PNGFile = 0x504E4720UL, /* 'PNG ' */ + + kXMP_SWFFile = 0x53574620UL, /* 'SWF ' */ + kXMP_FLAFile = 0x464C4120UL, /* 'FLA ' */ + kXMP_FLVFile = 0x464C5620UL, /* 'FLV ' */ + + kXMP_MOVFile = 0x4D4F5620UL, /* 'MOV ', Quicktime */ + kXMP_AVIFile = 0x41564920UL, /* 'AVI ' */ + kXMP_CINFile = 0x43494E20UL, /* 'CIN ', Cineon */ + kXMP_WAVFile = 0x57415620UL, /* 'WAV ' */ + kXMP_MP3File = 0x4D503320UL, /* 'MP3 ' */ + kXMP_SESFile = 0x53455320UL, /* 'SES ', Audition session */ + kXMP_CELFile = 0x43454C20UL, /* 'CEL ', Audition loop */ + kXMP_MPEGFile = 0x4D504547UL, /* 'MPEG' */ + kXMP_MPEG2File = 0x4D503220UL, /* 'MP2 ' */ + kXMP_MPEG4File = 0x4D503420UL, /* 'MP4 ', ISO 14494-12 and -14 */ + kXMP_WMAVFile = 0x574D4156UL, /* 'WMAV', Windows Media Audio and Video */ + kXMP_AIFFFile = 0x41494646UL, /* 'AIFF' */ + + kXMP_HTMLFile = 0x48544D4CUL, /* 'HTML' */ + kXMP_XMLFile = 0x584D4C20UL, /* 'XML ' */ + kXMP_TextFile = 0x74657874UL, /* 'text' */ + + /* Adobe application file formats. */ + + kXMP_PhotoshopFile = 0x50534420UL, /* 'PSD ' */ + kXMP_IllustratorFile = 0x41492020UL, /* 'AI ' */ + kXMP_InDesignFile = 0x494E4444UL, /* 'INDD' */ + kXMP_AEProjectFile = 0x41455020UL, /* 'AEP ' */ + kXMP_AEProjTemplateFile = 0x41455420UL, /* 'AET ', After Effects Project Template */ + kXMP_AEFilterPresetFile = 0x46465820UL, /* 'FFX ' */ + kXMP_EncoreProjectFile = 0x4E434F52UL, /* 'NCOR' */ + kXMP_PremiereProjectFile = 0x5052504AUL, /* 'PRPJ' */ + kXMP_PremiereTitleFile = 0x5052544CUL, /* 'PRTL' */ + + /* Catch all. */ + + kXMP_UnknownFile = 0x20202020UL /* ' ' */ + +}; +typedef XMP_Uns32 XMP_FileFormat; + +/* ---------------------------------------------------------------------------------------------- */ + +enum { + kXMP_CharLittleEndianMask = 1, + kXMP_Char16BitMask = 2, /* Don't use these directly. */ + kXMP_Char32BitMask = 4 +}; + +enum { /* The values allow easy testing for 16/32 bit and big/little endian. */ + kXMP_Char8Bit = 0, + kXMP_Char16BitBig = kXMP_Char16BitMask, + kXMP_Char16BitLittle = kXMP_Char16BitMask | kXMP_CharLittleEndianMask, + kXMP_Char32BitBig = kXMP_Char32BitMask, + kXMP_Char32BitLittle = kXMP_Char32BitMask | kXMP_CharLittleEndianMask, + kXMP_CharUnknown = 1 /* ! A bit of a hack, for variable or not-yet-known cases. */ +}; + +#define XMP_CharFormIs16Bit(f) ( ((int)(f) & kXMP_Char16BitMask) != 0 ) +#define XMP_CharFormIs32Bit(f) ( ((int)(f) & kXMP_Char32BitMask) != 0 ) + +#define XMP_CharFormIsBigEndian(f) ( ((int)(f) & kXMP_CharLittleEndianMask) == 0 ) +#define XMP_CharFormIsLittleEndian(f) ( ((int)(f) & kXMP_CharLittleEndianMask) != 0 ) + +#define XMP_GetCharSize(f) ( ((int)(f)&6) == 0 ? 1 : (int)(f)&6 ) + +#define XMP_CharToSerializeForm(cf) ( (XMP_OptionBits)(cf) ) +#define XMP_CharFromSerializeForm(sf) ( (XMP_Uns8)(sf) ) + +struct XMP_PacketInfo { + XMP_Int64 offset; + XMP_Int32 length; + XMP_Int32 padSize; /* Zero if unknown. */ + XMP_Uns8 charForm; + XMP_Bool writeable; + XMP_Uns8 pad1, pad2; + #if __cplusplus + XMP_PacketInfo() : offset(0), length(0), padSize(0), charForm(0), writeable(0), pad1(0), pad2(0) {}; + #endif +}; +#if ! __cplusplus + typedef struct XMP_PacketInfo XMP_PacketInfo; +#endif +enum { kXMP_PacketInfoVersion = 3 }; + +/* ---------------------------------------------------------------------------------------------- */ + +enum { /* Values for XMP_ThumbnailInfo.tnailFormat. */ + kXMP_UnknownTNail = 0, /* The thumbnail data has an unknown format. */ + kXMP_JPEGTNail = 1, /* The thumbnail data is a JPEG stream, presumably compressed. */ + kXMP_TIFFTNail = 2, /* The thumbnail data is a TIFF stream, presumably uncompressed. */ + kXMP_PShopTNail = 3 /* The thumbnail data is in the format of Photoshop Image Resource 1036. */ +}; + +struct XMP_ThumbnailInfo { + XMP_FileFormat fileFormat; /* The format of the containing file. */ + XMP_Uns32 fullWidth, fullHeight; /* Full image size in pixels. */ + XMP_Uns32 tnailWidth, tnailHeight; /* Thumbnail image size in pixels. */ + XMP_Uns16 fullOrientation, tnailOrientation; /* Orientation of full image and thumbnail, as defined by Exif for tag 274. */ + const XMP_Uns8 * tnailImage; /* Raw data from the host file, valid for life of the owning XMPFiles object. Do not modify! */ + XMP_Uns32 tnailSize; /* The size in bytes of the tnailImage data. */ + XMP_Uns8 tnailFormat; /* The format of the tnailImage data. */ + XMP_Uns8 pad1, pad2, pad3; + #if __cplusplus + XMP_ThumbnailInfo() : fileFormat(kXMP_UnknownFile), fullWidth(0), fullHeight(0), + tnailWidth(0), tnailHeight(0), fullOrientation(0), tnailOrientation(0), + tnailImage(0), tnailSize(0), tnailFormat(kXMP_UnknownTNail) {}; + #endif +}; +#if ! __cplusplus + typedef struct XMP_ThumbnailInfo XMP_ThumbnailInfo; +#endif +enum { kXMP_ThumbnailInfoVersion = 1 }; + +/* ---------------------------------------------------------------------------------------------- */ + +#define kXMPFiles_UnknownOffset ((XMP_Int64)-1) +#define kXMPFiles_UnknownLength ((XMP_Int32)-1) + +enum { /* Options for Initialize. */ + kXMPFiles_NoQuickTimeInit = 0x0001 /* Don't initialize QuickTime, the client will. */ +}; + +enum { /* Options for GetFormatInfo. */ + kXMPFiles_CanInjectXMP = 0x00000001, /* Can inject first-time XMP into an existing file. */ + kXMPFiles_CanExpand = 0x00000002, /* Can expand XMP or other metadata in an existing file. */ + kXMPFiles_CanRewrite = 0x00000004, /* Can copy one file to another, writing new metadata. */ + kXMPFiles_PrefersInPlace = 0x00000008, /* Can expand, but prefers in-place update. */ + kXMPFiles_CanReconcile = 0x00000010, /* Supports reconciliation between XMP and other forms. */ + kXMPFiles_AllowsOnlyXMP = 0x00000020, /* Allows access to just the XMP, ignoring other forms. */ + kXMPFiles_ReturnsRawPacket = 0x00000040, /* File handler returns raw XMP packet information. */ + kXMPFiles_ReturnsTNail = 0x00000080, /* File handler returns native thumbnail. */ + kXMPFiles_HandlerOwnsFile = 0x00000100, /* The file handler does the file open and close. */ + kXMPFiles_AllowsSafeUpdate = 0x00000200, /* The file handler allows crash-safe file updates. */ + kXMPFiles_NeedsReadOnlyPacket = 0x00000400, /* The file format needs the XMP packet to be read-only. */ + kXMPFiles_UsesSidecarXMP = 0x00000800 /* The file handler uses a "sidecar" file for the XMP. */ +}; + +enum { /* Options for OpenFile. */ + kXMPFiles_OpenForRead = 0x00000001, /* Open for read-only access. */ + kXMPFiles_OpenForUpdate = 0x00000002, /* Open for reading and writing. */ + kXMPFiles_OpenOnlyXMP = 0x00000004, /* Only the XMP is wanted, allows space/time optimizations. */ + kXMPFiles_OpenCacheTNail = 0x00000008, /* Cache thumbnail if possible, GetThumbnail will be called. */ + kXMPFiles_OpenStrictly = 0x00000010, /* Be strict about locating XMP and reconciling with other forms. */ + kXMPFiles_OpenUseSmartHandler = 0x00000020, /* Require the use of a smart handler. */ + kXMPFiles_OpenUsePacketScanning = 0x00000040, /* Force packet scanning, don't use a smart handler. */ + kXMPFiles_OpenLimitedScanning = 0x00000080, /* Only packet scan files "known" to need scanning. */ + kXMPFiles_OpenInBackground = 0x10000000 /* Set if calling from background thread. */ +}; + +/* A note about kXMPFiles_OpenInBackground. The XMPFiles handler for .mov files currently uses */ +/* QuickTime. On Macintosh, calls to Enter/ExitMovies versus Enter/ExitMoviesOnThread must be made. */ +/* This option is used to signal background use so that the .mov handler can behave appropriately. */ + +enum { /* Options for CloseFile. */ + kXMPFiles_UpdateSafely = 0x0001 /* Write into a temporary file and swap for crash safety. */ +}; + +/* ============================================================================================== */ +/* Exception codes */ +/* =============== */ + +/** + * \name Exception codes. + * @{ + * 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. The \c XMP_Error struct + * 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 explanations try to + * be precise about the specific circumstances causing the error. + * + * \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. + */ + +#if ! __cplusplus + + typedef struct XMP_Error { + XMP_Int32 id; + XMP_StringPtr errMsg; + } XMP_Error; + +#else + + class XMP_Error { + public: + XMP_Error ( XMP_Int32 _id, XMP_StringPtr _errMsg ) : id(_id), errMsg(_errMsg) {}; + inline XMP_Int32 GetID() const { return id; }; + inline XMP_StringPtr GetErrMsg() const { return errMsg; }; + private: + XMP_Int32 id; + XMP_StringPtr errMsg; + }; + +#endif + +enum { + + /* More or less generic error codes. */ + kXMPErr_Unknown = 0, + kXMPErr_TBD = 1, + kXMPErr_Unavailable = 2, + kXMPErr_BadObject = 3, + kXMPErr_BadParam = 4, + kXMPErr_BadValue = 5, + kXMPErr_AssertFailure = 6, + kXMPErr_EnforceFailure = 7, + kXMPErr_Unimplemented = 8, + kXMPErr_InternalFailure = 9, + kXMPErr_Deprecated = 10, + kXMPErr_ExternalFailure = 11, + kXMPErr_UserAbort = 12, + kXMPErr_StdException = 13, + kXMPErr_UnknownException = 14, + kXMPErr_NoMemory = 15, + + /* More specific parameter error codes. */ + kXMPErr_BadSchema = 101, + kXMPErr_BadXPath = 102, + kXMPErr_BadOptions = 103, + kXMPErr_BadIndex = 104, + kXMPErr_BadIterPosition = 105, + kXMPErr_BadParse = 106, + kXMPErr_BadSerialize = 107, + kXMPErr_BadFileFormat = 108, + kXMPErr_NoFileHandler = 109, + kXMPErr_TooLargeForJPEG = 110, + + /* File format and internal structure error codes. */ + kXMPErr_BadXML = 201, + kXMPErr_BadRDF = 202, + kXMPErr_BadXMP = 203, + kXMPErr_EmptyIterator = 204, + kXMPErr_BadUnicode = 205, + kXMPErr_BadTIFF = 206, + kXMPErr_BadJPEG = 207, + kXMPErr_BadPSD = 208, + kXMPErr_BadPSIR = 209, + kXMPErr_BadIPTC = 210, + kXMPErr_BadMPEG = 211 + +}; + +/** + * @} + */ + + +/* ============================================================================================== */ +/* Client callbacks */ +/* ================ */ + + +/** + * \name Special purpose callback functions + * @{ + */ + +/** + * \typedef XMP_Status + * \brief A signed 32 bit integer used as a status result for the output callback routine. + * Zero means no error, all other values except -1 are private to the callback. The callback is + * wrapped to prevent exceptions being thrown across DLL boundaries. Any exceptions thrown out + * of the callback cause a return status of -1. + */ + +/** + * \typedef XMP_TextOutputProc + * \brief Direct text output from the XMP toolkit, such as debugging dumps, is done using client + * supplied callbacks. The callback is invoked one or more times for each line of output. The + * end of a line is signaled by a '\n' character at the end of the buffer. Formatting newlines + * are never present in the middle of a buffer, but values of properties might contain any UTF-8 + * characters. A success/fail status is returned by the callback. Any failure result aborts + * the output. + */ + +typedef XMP_Int32 XMP_Status; + +typedef XMP_Status (* XMP_TextOutputProc) ( void * refCon, + XMP_StringPtr buffer, + XMP_StringLen bufferSize ); + +/** + * @} + */ + + +/* ============================================================================================== */ +/* Stuff with no better place to be */ +/* ================================ */ + +typedef struct XMP_VersionInfo { + XMP_Uns8 major; /* The primary release number, the "1" in version "1.2.3". */ + XMP_Uns8 minor; /* The secondary release number, the "2" in version "1.2.3". */ + XMP_Uns8 micro; /* The tertiary release number, the "3" in version "1.2.3". */ + XMP_Bool isDebug; /* Really a 0/1 bool value. True if this is a debug build. */ + XMP_Uns32 build; /* A rolling build number, monotonically increasing in a release. */ + XMP_Uns32 flags; /* Individual feature implementation flags. */ + XMP_StringPtr message; /* A comprehensive version information string. */ +} XMP_VersionInfo; + +typedef bool (* XMP_AbortProc) ( void * arg ); /* Used by SXMPFiles::SetAbortProc. */ + +/* ============================================================================================== */ + +#if __cplusplus +} /* extern "C" */ +#endif + +#endif /* __XMP_Const_h__ */ diff --git a/public/include/XMP_Environment.h b/public/include/XMP_Environment.h new file mode 100644 index 0000000..f25676e --- /dev/null +++ b/public/include/XMP_Environment.h @@ -0,0 +1,121 @@ +#ifndef __XMP_Environment_h__ +#define __XMP_Environment_h__ 1 + +/* --------------------------------------------------------------------------------------------- */ +/* ** IMPORTANT ** This file must be usable by strict ANSI C compilers. No "//" comments, etc. */ +/* --------------------------------------------------------------------------------------------- */ + +/* +// ================================================================================================= +// XMP_Environment.h - Build environment flags for the XMP toolkit. +// ================================================================ +// +// This header is just C preprocessor macro definitions to set up the XMP toolkit build environment. +// It must be the first #include in any chain since it might affect things in other #includes. +// +// ================================================================================================= +*/ + +/* +// ================================================================================================= +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved. +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= +*/ + +/* ============================================================================================== */ +/* Determine the Platform */ +/* ====================== */ + +/* One of MAC_ENV, WIN_ENV, or UNIX_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. */ + +/* ! Tempting though it might be to have a standard macro for big or little endian, there seems */ +/* ! to be no decent way to do that on our own in UNIX. Forcing it on the client isn't acceptable. */ + +#if defined ( MAC_ENV ) + + #if 0 /* ! maybe someday - ! MAC_ENV */ + #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" + #endif + + #define XMP_MacBuild 1 + #define XMP_WinBuild 0 + #define XMP_UNIXBuild 0 + +#elif defined ( WIN_ENV ) + + #if 0 /* ! maybe someday - ! WIN_ENV */ + #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" + #endif + + #define XMP_MacBuild 0 + #define XMP_WinBuild 1 + #define XMP_UNIXBuild 0 + +#elif defined ( UNIX_ENV ) + + #if 0 /* ! maybe someday - ! UNIX_ENV */ + #error "UNIX_ENV must be defined so that \"#if UNIX_ENV\" is true" + #endif + + #define XMP_MacBuild 0 + #define XMP_WinBuild 0 + #define XMP_UNIXBuild 1 + +#else + + #error "XMP environment error - must define one of MAC_ENV, WIN_ENV, or UNIX_ENV" + +#endif + +/* ============================================================================================== */ +/* Common Macros */ +/* ============= */ + +#if defined ( DEBUG ) + #if defined ( NDEBUG ) + #error "XMP environment error - both DEBUG and NDEBUG are defined" + #endif + #define XMP_DebugBuild 1 +#endif + +#if defined ( NDEBUG ) + #define XMP_DebugBuild 0 +#endif + +#ifndef XMP_DebugBuild + #define XMP_DebugBuild 0 +#endif + +#if XMP_DebugBuild + #include <stdio.h> /* The assert macro needs printf. */ +#endif + +/* ============================================================================================== */ +/* Macintosh Specific Settings */ +/* =========================== */ + +/* ============================================================================================== */ +/* Windows Specific Settings */ +/* ========================= */ + +/* ============================================================================================== */ +/* UNIX Specific Settings */ +/* ====================== */ + +/* ============================================================================================== */ + +#endif /* __XMP_Environment_h__ */ diff --git a/public/include/XMP_Version.h b/public/include/XMP_Version.h new file mode 100644 index 0000000..ed41d14 --- /dev/null +++ b/public/include/XMP_Version.h @@ -0,0 +1,45 @@ +#ifndef __XMP_Version_h__ +#define __XMP_Version_h__ 1 + +/* --------------------------------------------------------------------------------------------- */ +/* ** IMPORTANT ** This file must be usable by strict ANSI C compilers. No "//" comments, etc. */ +/* --------------------------------------------------------------------------------------------- */ + +/* +// ================================================================================================= +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved. +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= +*/ + +/* ============================================================================================= */ +/** +XMP Toolkit Version Information + +Version information for the XMP toolkit is stored in the executable and available through a runtime +call, <tt>SXMPMeta::GetVersionInfo</tt>. In addition a static version number is defined in this +header. The information in the executable or returned by <tt>SXMPMeta::GetVersionInfo</tt> is about +the implementation internals, it is runtime version information. The values defined in this header +describe the version of the API used at client compile time. They do not necessarily relate to the +runtime version. + +Important: Do not display the static values defined here to users as the version of XMP in use. Do +not base runtime decisions on just this static version. It is OK to compare the static and runtime +versions. + +*/ +/* ============================================================================================= */ + +#define XMP_API_VERSION_MAJOR 4 +#define XMP_API_VERSION_MINOR 1 +#define XMP_API_VERSION_MICRO 1 + +#define XMP_API_VERSION 4.1 +#define XMP_API_VERSION_STRING "4.1.1" + +/* ============================================================================================= */ + +#endif /* __XMP_Version_h__ */ diff --git a/public/include/client-glue/TXMPFiles.incl_cpp b/public/include/client-glue/TXMPFiles.incl_cpp new file mode 100644 index 0000000..83867df --- /dev/null +++ b/public/include/client-glue/TXMPFiles.incl_cpp @@ -0,0 +1,347 @@ +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file TXMPFiles.incl_cpp +/// \brief The implementation of the TXMPFiles template class. + +#if WIN_ENV + #pragma warning ( disable : 4003 ) // not enough actual parameters for macro + #pragma warning ( disable : 4800 ) // forcing value to bool 'true' or 'false' (performance warning) +#endif + +#include "client-glue/WXMP_Common.hpp" +#include "client-glue/WXMPFiles.hpp" + +// ================================================================================================= +// Implementation Guidelines +// ========================= +// +// The implementations of the template functions are very stylized. The jobs done in this code are: +// +// 1. ... +// +// ================================================================================================= + +#ifndef XMPFiles_TraceCTorDTor + #define XMPFiles_TraceCTorDTor 0 +#endif + +#if XMPFiles_TraceCTorDTor + class XFPeek { // Hack to peek at the client ref count in the internal object. + public: + XFPeek(); + virtual ~XFPeek(); + XMP_Int32 clientRefs; + }; +#endif + +// ================================================================================================= + +XMP_MethodIntro(TXMPFiles,void):: +GetVersionInfo ( XMP_VersionInfo * versionInfo ) +{ + WrapNoCheckVoid ( zXMPFiles_GetVersionInfo_1 ( versionInfo ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +Initialize() +{ + WrapCheckBool ( ok, zXMPFiles_Initialize_2 ( 0 ) ); + return ok; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +Initialize ( XMP_OptionBits options ) +{ + WrapCheckBool ( ok, zXMPFiles_Initialize_2 ( options ) ); + return ok; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +Terminate() +{ + WrapNoCheckVoid ( zXMPFiles_Terminate_1() ); +} + +// ================================================================================================= + +static XMPFilesRef Default_CTor() +{ + WrapCheckXMPFilesRef ( newRef, zXMPFiles_CTor_1() ); + return newRef; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPFiles):: +TXMPFiles() : xmpFilesRef(Default_CTor()) +{ + #if XMPFiles_TraceCTorDTor + XFPeek* xfPtr = (XFPeek*)this->xmpFilesRef; + printf ( "Default construct TXMPFiles @ %.8X, ref = %.8X, count = %d\n", this, xfPtr, xfPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPFiles):: +TXMPFiles ( const TXMPFiles<tStringObj> & original ) : xmpFilesRef(original.xmpFilesRef) +{ + WXMPFiles_IncrementRefCount_1 ( this->xmpFilesRef ); + #if XMPFiles_TraceCTorDTor + XFPeek* xfPtr = (XFPeek*)this->xmpFilesRef; + printf ( "Copy construct TXMPFiles @ %.8X, ref = %.8X, count = %d\n", this, xfPtr, xfPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +operator= ( const TXMPFiles<tStringObj> & rhs ) +{ + #if XMPFiles_TraceCTorDTor + XFPeek* xfLHS = (XFPeek*)this->xmpFilesRef; + XFPeek* xfRHS = (XFPeek*)rhs.xmpFilesRef; + printf ( "Assign TXMPFiles, lhs @ %.8X, rhs @ %.8X\n", this, &rhs ); + printf ( " original lhs ref = %.8X, count = %d\n", xfLHS, xfLHS->clientRefs ); + printf ( " original rhs ref = %.8X, count = %d\n", xfRHS, xfRHS->clientRefs ); + #endif + XMPFilesRef oldRef = this->xmpFilesRef; // ! Decrement last so errors leave client object OK. + this->xmpFilesRef = rhs.xmpFilesRef; + WXMPFiles_IncrementRefCount_1 ( this->xmpFilesRef ); // Increment the count on the new ref. + WXMPFiles_DecrementRefCount_1 ( oldRef ); // Decrement the count on the old ref. + #if XMPFiles_TraceCTorDTor + printf ( " result lhs ref = %.8X, count = %d\n", xfLHS, xfLHS->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPFiles):: +TXMPFiles ( XMPFilesRef _xmpFilesRef ) : xmpFilesRef(_xmpFilesRef) +{ + WXMPFiles_IncrementRefCount_1 ( this->xmpFilesRef ); + #if XMPFiles_TraceCTorDTor + XFPeek* xfPtr = (XFPeek*)this->xmpFilesRef; + printf ( "Ref construct TXMPFiles @ %.8X, ref = %.8X, count = %d\n", this, xfPtr, xfPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPFiles):: +TXMPFiles ( XMP_StringPtr filePath, + XMP_FileFormat format /* = kXMP_UnknownFile */, + XMP_OptionBits openFlags /* = 0 */ ) : xmpFilesRef(Default_CTor()) +{ + #if XMPFiles_TraceCTorDTor + XFPeek* xfPtr = (XFPeek*)this->xmpFilesRef; + printf ( "File construct TXMPFiles @ %.8X, ref = %.8X, count = %d\n", this, xfPtr, xfPtr->clientRefs ); + #endif + bool ok = this->OpenFile ( filePath, format, openFlags ); + if ( ! ok ) throw XMP_Error ( kXMPErr_NoFileHandler, "OpenFile returned false" ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPFiles):: +TXMPFiles ( const tStringObj & filePath, + XMP_FileFormat format /* = kXMP_UnknownFile */, + XMP_OptionBits openFlags /* = 0 */ ) : xmpFilesRef(Default_CTor()) +{ + #if XMPFiles_TraceCTorDTor + XFPeek* xfPtr = (XFPeek*)this->xmpFilesRef; + printf ( "File construct TXMPFiles @ %.8X, ref = %.8X, count = %d\n", this, xfPtr, xfPtr->clientRefs ); + #endif + bool ok = this->OpenFile ( filePath.c_str(), format, openFlags ); + if ( ! ok ) throw XMP_Error ( kXMPErr_NoFileHandler, "OpenFile returned false" ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPFiles):: +~TXMPFiles () throw() +{ + #if XMPFiles_TraceCTorDTor + XFPeek* xfPtr = (XFPeek*)this->xmpFilesRef; + printf ( "Destruct TXMPFiles @ %.8X, ref= %.8X, count = %d\n", this, xfPtr, xfPtr->clientRefs ); + #endif + WXMPFiles_DecrementRefCount_1 ( this->xmpFilesRef ); + this->xmpFilesRef = 0; +} + +// ================================================================================================= + +XMP_MethodIntro(TXMPFiles,bool):: +GetFormatInfo ( XMP_FileFormat format, + XMP_OptionBits * flags ) +{ + WrapCheckBool ( found, zXMPFiles_GetFormatInfo_1 ( format, flags ) ); + return found; +} + +// ================================================================================================= + +XMP_MethodIntro(TXMPFiles,XMPFilesRef):: +GetInternalRef() +{ + return this->xmpFilesRef; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +OpenFile ( XMP_StringPtr filePath, + XMP_FileFormat format /* = kXMP_UnknownFile */, + XMP_OptionBits openFlags /* =0 */ ) +{ + WrapCheckBool ( ok, zXMPFiles_OpenFile_1 ( filePath, format, openFlags ) ); + return ok; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +OpenFile ( const tStringObj & filePath, + XMP_FileFormat format /* = kXMP_UnknownFile */, + XMP_OptionBits openFlags /* =0 */ ) +{ + return this->OpenFile ( filePath.c_str(), format, openFlags ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +CloseFile ( XMP_OptionBits closeFlags /* =0 */ ) +{ + WrapCheckVoid ( zXMPFiles_CloseFile_1 ( closeFlags ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +GetFileInfo ( tStringObj * filePath /* = 0 */, + XMP_OptionBits * openFlags /* =0 */, + XMP_FileFormat * format /* = 0 */, + XMP_OptionBits * handlerFlags /* =0 */ ) +{ + XMP_StringPtr pathStr; + XMP_StringLen pathLen; + + WrapCheckBool ( isOpen, zXMPFiles_GetFileInfo_1 ( &pathStr, &pathLen, openFlags, format, handlerFlags ) ); + if ( isOpen ) { + if ( filePath != 0 ) filePath->assign ( pathStr, pathLen ); + WXMPFiles_UnlockObj_1 ( this->xmpFilesRef ); + } + return isOpen; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +SetAbortProc ( XMP_AbortProc abortProc, + void * abortArg ) +{ + WrapCheckVoid ( zXMPFiles_SetAbortProc_1 ( abortProc, abortArg ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +GetXMP ( SXMPMeta * xmpObj /* = 0 */, + tStringObj * xmpPacket /* = 0 */, + XMP_PacketInfo * packetInfo /* =0 */ ) +{ + XMP_StringPtr xmpStr; + XMP_StringLen xmpLen; + + XMPMetaRef xmpRef = 0; + if ( xmpObj != 0 ) { + SXMPUtils::RemoveProperties ( xmpObj, 0, 0, kXMPUtil_DoAllProperties ); + // *** Need an SXMPMeta::Clear method: + xmpRef = xmpObj->GetInternalRef(); + } + + WrapCheckBool ( hasXMP, zXMPFiles_GetXMP_1 ( xmpRef, &xmpStr, &xmpLen, packetInfo ) ); + if ( hasXMP ) { + if ( xmpPacket != 0 ) xmpPacket->assign ( xmpStr, xmpLen ); + WXMPFiles_UnlockObj_1 ( this->xmpFilesRef ); + } + return hasXMP; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +GetThumbnail ( XMP_ThumbnailInfo * tnailInfo ) +{ + WrapCheckBool ( hasTNail, zXMPFiles_GetThumbnail_1 ( tnailInfo ) ); + return hasTNail; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +PutXMP ( const SXMPMeta & xmpObj ) +{ + WrapCheckVoid ( zXMPFiles_PutXMP_1 ( xmpObj.GetInternalRef(), 0, 0 ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +PutXMP ( XMP_StringPtr xmpPacket, + XMP_StringLen xmpLength /* = kXMP_UseNullTermination */ ) +{ + WrapCheckVoid ( zXMPFiles_PutXMP_1 ( 0, xmpPacket, xmpLength ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,void):: +PutXMP ( const tStringObj & xmpPacket ) +{ + this->PutXMP ( xmpPacket.c_str(), xmpPacket.size() ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +CanPutXMP ( const SXMPMeta & xmpObj ) +{ + WrapCheckBool ( canPut, zXMPFiles_CanPutXMP_1 ( xmpObj.GetInternalRef(), 0, 0 ) ); + return canPut; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +CanPutXMP ( XMP_StringPtr xmpPacket, + XMP_StringLen xmpLength /* = kXMP_UseNullTermination */ ) +{ + WrapCheckBool ( canPut, zXMPFiles_CanPutXMP_1 ( 0, xmpPacket, xmpLength ) ); + return canPut; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPFiles,bool):: +CanPutXMP ( const tStringObj & xmpPacket ) +{ + return this->CanPutXMP ( xmpPacket.c_str(), xmpPacket.size() ); +} + +// ================================================================================================= diff --git a/public/include/client-glue/TXMPIterator.incl_cpp b/public/include/client-glue/TXMPIterator.incl_cpp new file mode 100644 index 0000000..318fa66 --- /dev/null +++ b/public/include/client-glue/TXMPIterator.incl_cpp @@ -0,0 +1,226 @@ +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file TXMPIterator.incl_cpp +/// \brief The implementation of the TXMPIterator template class. + +#include "XMP.hpp" +#include "client-glue/WXMP_Common.hpp" +#include "client-glue/WXMPIterator.hpp" + +// ================================================================================================= +// Implementation Guidelines +// ========================= +// +// The implementations of the template functions are very stylized. The jobs done in this code are: +// +// 1. Set up the xmpIter template data member in the constructors. +// 2. Call through to the appropriate WXMPIterator function. +// 3. Copy returned strings and release the threading lock. +// +// The various kinds of functions follow similar patterns, first assuming no returned string: +// +// Constructors - Use an initializer for the xmpIter data member to call the WXMPIterator constructor. +// Destructor - Let the WXMPIterator destructor be implicitly called for the xmpIter data member. +// Static function - Simply call the corresponding WXMPIterator static function. +// Non-static function - Simply call the corresponding WXMPIterator function using xmpIter. +// +// If a member function has returned strings the code looks roughly like this: +// +// <<<callthrough>>> +// <<<checkfailure>>> +// if ( <<<appropriate>>> ) { +// if ( outStr != 0 ) outStr->assign ( outPtr, outLen ); +// <<<unlock>>> +// } +// return result; +// +// The <<<callthrough>>> is the call to the wrapper, and <<<checkfailure>>> is the check and throw +// if the wrapper reports failure. The <<<appropriate>>> check is used to determine if the string +// should actually be assigned. For example, GetProperty can't assign the value if the property +// does not exist. There is no <<<appropriate>>> check if it isn't, well, appropriate. Outputs are +// always passed as explicit pointers, and null can be passed if the string is not wanted. The +// inner implementation holds the threading lock if an output string is returned, regardless of +// whether the client wants it or not (which the implementation does not know). +// +// ================================================================================================= + +#ifndef XMP_TraceCTorDTor + #define XMP_TraceCTorDTor 0 +#endif + +#if XMP_TraceCTorDTor + class XIPeek { // Hack to peek at the client ref count in the internal object. + public: + XIPeek(); + virtual ~XIPeek(); + XMP_Int32 clientRefs; + }; +#endif + +// ------------------------------------------------------------------------------------------------- + +#define PropIterCTor(xmpRef,schemaNS,propName,options) \ + WrapCheckIterRef ( newRef, zXMPIterator_PropCTor_1 ( xmpRef, schemaNS, propName, options ) ); \ + this->iterRef = newRef + +// ------------------------------------------------------------------------------------------------- + +#define TableIterCTor(schemaNS,propName,options) \ + WrapCheckIterRef ( newRef, zXMPIterator_TableCTor_1 ( schemaNS, propName, options ) ); \ + this->iterRef = newRef + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPIterator):: +TXMPIterator ( const TXMPIterator<tStringObj> & original ) : iterRef(original.iterRef) +{ + WXMPIterator_IncrementRefCount_1 ( this->iterRef ); + #if XMP_TraceCTorDTor + XIPeek* xiPtr = (XIPeek*)this->iterRef; + printf ( "Copy construct TXMPIterator @ %.8X, ref = %.8X, count = %d\n", this, xiPtr, xiPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPIterator,void):: +operator= ( const TXMPIterator<tStringObj> & rhs ) +{ + #if XMP_TraceCTorDTor + XIPeek* xiLHS = (XIPeek*)this->iterRef; + XIPeek* xiRHS = (XIPeek*)rhs.iterRef; + printf ( "Assign TXMPIterator, lhs @ %.8X, rhs @ %.8X\n", this, &rhs ); + printf ( " original lhs ref = %.8X, count = %d\n", xiLHS, xiLHS->clientRefs ); + printf ( " original rhs ref = %.8X, count = %d\n", xiRHS, xiRHS->clientRefs ); + #endif + XMPIteratorRef oldRef = this->iterRef; // ! Decrement last so errors leave client object OK. + this->iterRef = rhs.iterRef; + WXMPIterator_IncrementRefCount_1 ( this->iterRef ); + WXMPIterator_DecrementRefCount_1 ( oldRef ); + #if XMP_TraceCTorDTor + printf ( " result lhs ref = %.8X, count = %d\n", xiLHS, xiLHS->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPIterator):: +TXMPIterator() : iterRef(0) +{ + throw XMP_Error ( kXMPErr_Unavailable, "No default construction for XMP iterators" ); + #if XMP_TraceCTorDTor + XIPeek* xiPtr = (XIPeek*)this->iterRef; + printf ( "Default construct TXMPIterator @ %.8X, ref = %.8X, count = %d\n", this, xiPtr, xiPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPIterator):: +TXMPIterator ( const TXMPMeta<tStringObj> & xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_OptionBits options /* = 0 */ ) : iterRef(0) +{ + PropIterCTor ( xmpObj.GetInternalRef(), schemaNS, propName, options ); + #if XMP_TraceCTorDTor + XIPeek* xiPtr = (XIPeek*)this->iterRef; + printf ( "Construct property TXMPIterator @ %.8X, ref = %.8X, count = %d\n", this, xiPtr, xiPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPIterator):: +TXMPIterator ( const TXMPMeta<tStringObj> & xmpObj, + XMP_StringPtr schemaNS, + XMP_OptionBits options /* = 0 */ ) : iterRef(0) +{ + PropIterCTor ( xmpObj.GetInternalRef(), schemaNS, "", options ); + #if XMP_TraceCTorDTor + XIPeek* xiPtr = (XIPeek*)this->iterRef; + printf ( "Construct schema TXMPIterator @ %.8X, ref = %.8X, count = %d\n", this, xiPtr, xiPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPIterator):: +TXMPIterator ( const TXMPMeta<tStringObj> & xmpObj, + XMP_OptionBits options /* = 0 */ ) : iterRef(0) +{ + PropIterCTor ( xmpObj.GetInternalRef(), "", "", options ); + #if XMP_TraceCTorDTor + XIPeek* xiPtr = (XIPeek*)this->iterRef; + printf ( "Construct tree TXMPIterator @ %.8X, ref = %.8X, count = %d\n", this, xiPtr, xiPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPIterator):: +TXMPIterator ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_OptionBits options ) : iterRef(0) +{ + TableIterCTor ( schemaNS, propName, options ); + #if XMP_TraceCTorDTor + XIPeek* xiPtr = (XIPeek*)this->iterRef; + printf ( "Construct table TXMPIterator @ %.8X, ref = %.8X, count = %d\n", this, xiPtr, xiPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPIterator):: +~TXMPIterator () throw() +{ + #if XMP_TraceCTorDTor + XIPeek* xiPtr = (XIPeek*)this->iterRef; + printf ( "Destruct TXMPIterator @ %.8X, ref = %.8X, count = %d\n", this, xiPtr, xiPtr->clientRefs ); + #endif + WXMPIterator_DecrementRefCount_1 ( this->iterRef ); + this->iterRef = 0; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPIterator,bool):: +Next ( tStringObj * schemaNS /* = 0 */, + tStringObj * propPath /* = 0 */, + tStringObj * propValue /* = 0 */, + XMP_OptionBits * options /* = 0 */ ) +{ + XMP_StringPtr schemaPtr = 0; + XMP_StringLen schemaLen = 0; + XMP_StringPtr pathPtr = 0; + XMP_StringLen pathLen = 0; + XMP_StringPtr valuePtr = 0; + XMP_StringLen valueLen = 0; + WrapCheckBool ( found, zXMPIterator_Next_1 ( &schemaPtr, &schemaLen, &pathPtr, &pathLen, &valuePtr, &valueLen, options ) ); + if ( found ) { + if ( schemaNS != 0 ) schemaNS->assign ( schemaPtr, schemaLen ); + if ( propPath != 0 ) propPath->assign ( pathPtr, pathLen ); + if ( propValue != 0 ) propValue->assign ( valuePtr, valueLen ); + WXMPUtils_UnlockIter_1 ( this->iterRef, 0 ); + } + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPIterator,void):: +Skip ( XMP_OptionBits options ) +{ + WrapCheckVoid ( zXMPIterator_Skip_1 ( options ) ); +} + +// ================================================================================================= diff --git a/public/include/client-glue/TXMPMeta.incl_cpp b/public/include/client-glue/TXMPMeta.incl_cpp new file mode 100644 index 0000000..60bd8e7 --- /dev/null +++ b/public/include/client-glue/TXMPMeta.incl_cpp @@ -0,0 +1,927 @@ +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file TXMPMeta.incl_cpp +/// \brief The implementation of the TXMPMeta template class. + +#include "XMP.hpp" +#include "client-glue/WXMP_Common.hpp" +#include "client-glue/WXMPMeta.hpp" + +// ================================================================================================= +// Implementation Guidelines +// ========================= +// +// The implementations of the template functions are very stylized. ... +// +// ================================================================================================= + +#ifndef XMP_TraceCTorDTor + #define XMP_TraceCTorDTor 0 +#endif + +#if XMP_TraceCTorDTor + class XMPeek { // Hack to peek at the client ref count in the internal object. + public: + XMPeek(); + virtual ~XMPeek(); + XMP_Int32 clientRefs; + }; +#endif + +// ================================================================================================= + +// ================================================================================================= +// Local utilities +// =============== + +// ------------------------------------------------------------------------------------------------- + +class TOPW_Info { +public: + XMP_TextOutputProc clientProc; + void * clientRefCon; + TOPW_Info ( XMP_TextOutputProc proc, void * refCon ) : clientProc(proc), clientRefCon(refCon) {}; +private: + TOPW_Info() {}; // ! Hide default constructor. +}; + +static XMP_Status TextOutputProcWrapper ( void * refCon, + XMP_StringPtr buffer, + XMP_StringLen bufferSize ) +{ + try { // Don't let client callback exceptions propagate across DLL boundaries. + TOPW_Info * info = (TOPW_Info*)refCon; + return info->clientProc ( info->clientRefCon, buffer, bufferSize ); + } catch ( ... ) { + return -1; + } +} + +// ================================================================================================= +// Initialization and termination +// ============================== + +XMP_MethodIntro(TXMPMeta,void):: +GetVersionInfo ( XMP_VersionInfo * info ) +{ + WrapNoCheckVoid ( zXMPMeta_GetVersionInfo_1 ( info ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +Initialize() +{ + WrapCheckBool ( ok, zXMPMeta_Initialize_1() ); + return ok; +} +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +Terminate() +{ + WrapNoCheckVoid ( zXMPMeta_Terminate_1() ); +} + +// ================================================================================================= +// Constuctors, destructor, operators +// ================================== + +static XMPMetaRef DefaultCTor() +{ + WrapCheckMetaRef ( newRef, zXMPMeta_CTor_1() ); + return newRef; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPMeta):: +TXMPMeta() : xmpRef(DefaultCTor()) +{ + #if XMP_TraceCTorDTor + XMPeek* xmPtr = (XMPeek*)this->xmpRef; + printf ( "Default construct TXMPMeta @ %.8X, ref = %.8X, count = %d\n", this, xmPtr, xmPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPMeta):: +TXMPMeta ( const TXMPMeta<tStringObj> & original ) : xmpRef(original.xmpRef) +{ + WXMPMeta_IncrementRefCount_1 ( this->xmpRef ); + #if XMP_TraceCTorDTor + XMPeek* xmPtr = (XMPeek*)this->xmpRef; + printf ( "Copy construct TXMPMeta @ %.8X, ref = %.8X, count = %d\n", this, xmPtr, xmPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +operator= ( const TXMPMeta<tStringObj> & rhs ) +{ + #if XMP_TraceCTorDTor + XMPeek* xmLHS = (XMPeek*)this->xmpRef; + XMPeek* xmRHS = (XMPeek*)rhs.xmpRef; + printf ( "Assign TXMPMeta, lhs @ %.8X, rhs @ %.8X\n", this, &rhs ); + printf ( " original lhs ref = %.8X, count = %d\n", xmLHS, xmLHS->clientRefs ); + printf ( " original rhs ref = %.8X, count = %d\n", xmRHS, xmRHS->clientRefs ); + #endif + XMPMetaRef oldRef = this->xmpRef; // ! Decrement last so errors leave client object OK. + this->xmpRef = rhs.xmpRef; + WXMPMeta_IncrementRefCount_1 ( this->xmpRef ); // Increment the count on the new ref. + WXMPMeta_DecrementRefCount_1 ( oldRef ); // Decrement the count on the old ref. + #if XMP_TraceCTorDTor + printf ( " result lhs ref = %.8X, count = %d\n", xmLHS, xmLHS->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPMeta):: +TXMPMeta ( XMPMetaRef _xmpRef ) : xmpRef(_xmpRef) +{ + WXMPMeta_IncrementRefCount_1 ( this->xmpRef ); + #if XMP_TraceCTorDTor + XMPeek* xmPtr = (XMPeek*)this->xmpRef; + printf ( "Ref construct TXMPMeta @ %.8X, ref = %.8X, count = %d\n", this, xmPtr, xmPtr->clientRefs ); + #endif +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPMeta):: +TXMPMeta ( XMP_StringPtr buffer, + XMP_StringLen xmpSize ) : xmpRef(DefaultCTor()) +{ + #if XMP_TraceCTorDTor + XMPeek* xmPtr = (XMPeek*)this->xmpRef; + printf ( "Parse construct TXMPMeta @ %.8X, ref = %.8X, count = %d\n", this, xmPtr, xmPtr->clientRefs ); + #endif + try { + this->ParseFromBuffer ( buffer, xmpSize ); + } catch ( ... ) { + WXMPMeta_DecrementRefCount_1 ( this->xmpRef ); + this->xmpRef = 0; + throw; + } +} + +// ------------------------------------------------------------------------------------------------- + +XMP_CTorDTorIntro(TXMPMeta):: +~TXMPMeta() throw() +{ + #if XMP_TraceCTorDTor + XMPeek* xmPtr = (XMPeek*)this->xmpRef; + printf ( "Destruct TXMPMeta @ %.8X, ref = %.8X, count = %d\n", this, xmPtr, xmPtr->clientRefs ); + #endif + WXMPMeta_DecrementRefCount_1 ( this->xmpRef ); + this->xmpRef = 0; + +} // ~TXMPMeta () + +// ================================================================================================= +// Global state functions +// ====================== + +XMP_MethodIntro(TXMPMeta,XMP_OptionBits):: +GetGlobalOptions() +{ + WrapCheckOptions ( options, zXMPMeta_GetGlobalOptions_1() ); + return options; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetGlobalOptions ( XMP_OptionBits options ) +{ + WrapCheckVoid ( zXMPMeta_SetGlobalOptions_1 ( options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,XMP_Status):: +DumpNamespaces ( XMP_TextOutputProc outProc, + void * refCon ) +{ + TOPW_Info info ( outProc, refCon ); + WrapCheckStatus ( status, zXMPMeta_DumpNamespaces_1 ( TextOutputProcWrapper, &info ) ); + return status; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,XMP_Status):: +DumpAliases ( XMP_TextOutputProc outProc, + void * refCon ) +{ + TOPW_Info info ( outProc, refCon ); + WrapCheckStatus ( status, zXMPMeta_DumpAliases_1 ( TextOutputProcWrapper, &info ) ); + return status; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +RegisterNamespace ( XMP_StringPtr namespaceURI, + XMP_StringPtr suggestedPrefix, + tStringObj * registeredPrefix ) +{ + XMP_StringPtr resultPtr = 0; + XMP_StringLen resultLen = 0; + WrapCheckBool ( prefixMatch, zXMPMeta_RegisterNamespace_1 ( namespaceURI, suggestedPrefix, &resultPtr, &resultLen ) ); + if ( registeredPrefix != 0 ) registeredPrefix->assign ( resultPtr, resultLen ); + WXMPMeta_Unlock_1 ( 0 ); + return prefixMatch; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetNamespacePrefix ( XMP_StringPtr namespaceURI, + tStringObj * namespacePrefix ) +{ + XMP_StringPtr resultPtr = 0; + XMP_StringLen resultLen = 0; + WrapCheckBool ( found, zXMPMeta_GetNamespacePrefix_1 ( namespaceURI, &resultPtr, &resultLen ) ); + if ( found ) { + if ( namespacePrefix != 0 ) namespacePrefix->assign ( resultPtr, resultLen ); + WXMPMeta_Unlock_1 ( 0 ); + } + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetNamespaceURI ( XMP_StringPtr namespacePrefix, + tStringObj * namespaceURI ) +{ + XMP_StringPtr resultPtr = 0; + XMP_StringLen resultLen = 0; + WrapCheckBool ( found, zXMPMeta_GetNamespaceURI_1 ( namespacePrefix, &resultPtr, &resultLen ) ); + if ( found ) { + if ( namespaceURI != 0 ) namespaceURI->assign ( resultPtr, resultLen ); + WXMPMeta_Unlock_1 ( 0 ); + } + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +DeleteNamespace ( XMP_StringPtr namespaceURI ) +{ + WrapCheckVoid ( zXMPMeta_DeleteNamespace_1 ( namespaceURI ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +RegisterAlias ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp, + XMP_StringPtr actualNS, + XMP_StringPtr actualProp, + XMP_OptionBits arrayForm ) +{ + WrapCheckVoid ( zXMPMeta_RegisterAlias_1 ( aliasNS, aliasProp, actualNS, actualProp, arrayForm ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +ResolveAlias ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp, + tStringObj * actualNS, + tStringObj * actualProp, + XMP_OptionBits * arrayForm ) +{ + XMP_StringPtr nsPtr = 0; + XMP_StringLen nsLen = 0; + XMP_StringPtr propPtr = 0; + XMP_StringLen propLen = 0; + WrapCheckBool ( found, zXMPMeta_ResolveAlias_1 ( aliasNS, aliasProp, &nsPtr, &nsLen, &propPtr, &propLen, arrayForm ) ); + if ( found ) { + if ( actualNS != 0 ) actualNS->assign ( nsPtr, nsLen ); + if ( actualProp != 0 ) actualProp->assign ( propPtr, propLen ); + WXMPMeta_Unlock_1 ( 0 ); + } + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +DeleteAlias ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp ) +{ + WrapCheckVoid ( zXMPMeta_DeleteAlias_1 ( aliasNS, aliasProp ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +RegisterStandardAliases ( XMP_StringPtr schemaNS ) +{ + WrapCheckVoid ( zXMPMeta_RegisterStandardAliases_1 ( schemaNS ) ); +} + +// ================================================================================================= +// Basic property manipulation functions +// ===================================== + +XMP_MethodIntro(TXMPMeta,bool):: +GetProperty ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + tStringObj * propValue, + XMP_OptionBits * options ) const +{ + XMP_StringPtr resultPtr = 0; + XMP_StringLen resultLen = 0; + WrapCheckBool ( found, zXMPMeta_GetProperty_1 ( schemaNS, propName, &resultPtr, &resultLen, options ) ); + if ( found ) { + if ( propValue != 0 ) propValue->assign ( resultPtr, resultLen ); + WXMPMeta_UnlockObject_1 ( this->xmpRef, 0 ); + } + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + tStringObj * itemValue, + XMP_OptionBits * options ) const +{ + XMP_StringPtr resultPtr = 0; + XMP_StringLen resultLen = 0; + WrapCheckBool ( found, zXMPMeta_GetArrayItem_1 ( schemaNS, arrayName, itemIndex, &resultPtr, &resultLen, options ) ); + if ( found ) { + if ( itemValue != 0 ) itemValue->assign ( resultPtr, resultLen ); + WXMPMeta_UnlockObject_1 ( this->xmpRef, 0 ); + } + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetStructField ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + tStringObj * fieldValue, + XMP_OptionBits * options ) const +{ + XMP_StringPtr resultPtr = 0; + XMP_StringLen resultLen = 0; + WrapCheckBool ( found, zXMPMeta_GetStructField_1 ( schemaNS, structName, fieldNS, fieldName, &resultPtr, &resultLen, options ) ); + if ( found ) { + if ( fieldValue != 0 ) fieldValue->assign ( resultPtr, resultLen ); + WXMPMeta_UnlockObject_1 ( this->xmpRef, 0 ); + } + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetQualifier ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + tStringObj * qualValue, + XMP_OptionBits * options ) const +{ + XMP_StringPtr resultPtr = 0; + XMP_StringLen resultLen = 0; + WrapCheckBool ( found, zXMPMeta_GetQualifier_1 ( schemaNS, propName, qualNS, qualName, &resultPtr, &resultLen, options ) ); + if ( found ) { + if ( qualValue != 0 ) qualValue->assign ( resultPtr, resultLen ); + WXMPMeta_UnlockObject_1 ( this->xmpRef, 0 ); + } + return found; +} //GetQualifier () + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetProperty ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr propValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetProperty_1 ( schemaNS, propName, propValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetProperty ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + const tStringObj & propValue, + XMP_OptionBits options /* = 0 */ ) +{ + this->SetProperty ( schemaNS, propName, propValue.c_str(), options ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + XMP_StringPtr itemValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetArrayItem_1 ( schemaNS, arrayName, itemIndex, itemValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + const tStringObj & itemValue, + XMP_OptionBits options /* = 0 */ ) +{ + this->SetArrayItem ( schemaNS, arrayName, itemIndex, itemValue.c_str(), options ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +AppendArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits arrayOptions, + XMP_StringPtr itemValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_AppendArrayItem_1 ( schemaNS, arrayName, arrayOptions, itemValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +AppendArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits arrayOptions, + const tStringObj & itemValue, + XMP_OptionBits options /* = 0 */ ) +{ + this->AppendArrayItem ( schemaNS, arrayName, arrayOptions, itemValue.c_str(), options ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetStructField ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + XMP_StringPtr fieldValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetStructField_1 ( schemaNS, structName, fieldNS, fieldName, fieldValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetStructField ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + const tStringObj & fieldValue, + XMP_OptionBits options /* = 0 */ ) +{ + this->SetStructField ( schemaNS, structName, fieldNS, fieldName, fieldValue.c_str(), options ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetQualifier ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + XMP_StringPtr qualValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetQualifier_1 ( schemaNS, propName, qualNS, qualName, qualValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetQualifier ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + const tStringObj & qualValue, + XMP_OptionBits options /* = 0 */ ) +{ + this->SetQualifier ( schemaNS, propName, qualNS, qualName, qualValue.c_str(), options ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +DeleteProperty ( XMP_StringPtr schemaNS, + XMP_StringPtr propName ) +{ + WrapCheckVoid ( zXMPMeta_DeleteProperty_1 ( schemaNS, propName ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +DeleteArrayItem ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex ) +{ + WrapCheckVoid ( zXMPMeta_DeleteArrayItem_1 ( schemaNS, arrayName, itemIndex ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +DeleteStructField ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName ) +{ + WrapCheckVoid ( zXMPMeta_DeleteStructField_1 ( schemaNS, structName, fieldNS, fieldName ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +DeleteQualifier ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName ) +{ + WrapCheckVoid ( zXMPMeta_DeleteQualifier_1 ( schemaNS, propName, qualNS, qualName ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +DoesPropertyExist ( XMP_StringPtr schemaNS, + XMP_StringPtr propName ) const +{ + WrapCheckBool ( exists, zXMPMeta_DoesPropertyExist_1 ( schemaNS, propName ) ); + return exists; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +DoesArrayItemExist ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex ) const +{ + WrapCheckBool ( exists, zXMPMeta_DoesArrayItemExist_1 ( schemaNS, arrayName, itemIndex ) ); + return exists; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +DoesStructFieldExist ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName ) const +{ + WrapCheckBool ( exists, zXMPMeta_DoesStructFieldExist_1 ( schemaNS, structName, fieldNS, fieldName ) ); + return exists; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +DoesQualifierExist ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName ) const +{ + WrapCheckBool ( exists, zXMPMeta_DoesQualifierExist_1 ( schemaNS, propName, qualNS, qualName ) ); + return exists; +} + +// ================================================================================================= +// Specialized Get and Set functions +// ================================= + +XMP_MethodIntro(TXMPMeta,bool):: +GetLocalizedText ( XMP_StringPtr schemaNS, + XMP_StringPtr altTextName, + XMP_StringPtr genericLang, + XMP_StringPtr specificLang, + tStringObj * actualLang, + tStringObj * itemValue, + XMP_OptionBits * options ) const +{ + XMP_StringPtr langPtr = 0; + XMP_StringLen langLen = 0; + XMP_StringPtr itemPtr = 0; + XMP_StringLen itemLen = 0; + WrapCheckBool ( found, zXMPMeta_GetLocalizedText_1 ( schemaNS, altTextName, genericLang, specificLang, + &langPtr, &langLen, &itemPtr, &itemLen, options ) ); + if ( found ) { + if ( actualLang != 0 ) actualLang->assign ( langPtr, langLen ); + if ( itemValue != 0 ) itemValue->assign ( itemPtr, itemLen ); + WXMPMeta_UnlockObject_1 ( this->xmpRef, kXMP_NoOptions ); + } + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetLocalizedText ( XMP_StringPtr schemaNS, + XMP_StringPtr altTextName, + XMP_StringPtr genericLang, + XMP_StringPtr specificLang, + XMP_StringPtr itemValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetLocalizedText_1 ( schemaNS, altTextName, genericLang, specificLang, itemValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetLocalizedText ( XMP_StringPtr schemaNS, + XMP_StringPtr altTextName, + XMP_StringPtr genericLang, + XMP_StringPtr specificLang, + const tStringObj & itemValue, + XMP_OptionBits options /* = 0 */ ) +{ + this->SetLocalizedText ( schemaNS, altTextName, genericLang, specificLang, itemValue.c_str(), options ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetProperty_Bool ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + bool * propValue, + XMP_OptionBits * options ) const +{ + XMP_Bool binValue; + WrapCheckBool ( found, zXMPMeta_GetProperty_Bool_1 ( schemaNS, propName, &binValue, options ) ); + if ( found && (propValue != 0) ) *propValue = binValue; + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetProperty_Int ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + long * propValue, + XMP_OptionBits * options ) const +{ + XMP_Int32 abiValue; + WrapCheckBool ( found, zXMPMeta_GetProperty_Int_1 ( schemaNS, propName, &abiValue, options ) ); + if ( found && (propValue != 0) ) *propValue = abiValue; + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetProperty_Int64 ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + long long * propValue, + XMP_OptionBits * options ) const +{ + XMP_Int64 abiValue; + WrapCheckBool ( found, zXMPMeta_GetProperty_Int64_1 ( schemaNS, propName, &abiValue, options ) ); + if ( found && (propValue != 0) ) *propValue = abiValue; + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetProperty_Float ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + double * propValue, + XMP_OptionBits * options ) const +{ + WrapCheckBool ( found, zXMPMeta_GetProperty_Float_1 ( schemaNS, propName, propValue, options ) ); + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,bool):: +GetProperty_Date ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_DateTime * propValue, + XMP_OptionBits * options ) const +{ + WrapCheckBool ( found, zXMPMeta_GetProperty_Date_1 ( schemaNS, propName, propValue, options ) ); + return found; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetProperty_Bool ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + bool propValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetProperty_Bool_1 ( schemaNS, propName, propValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetProperty_Int ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + long propValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetProperty_Int_1 ( schemaNS, propName, propValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetProperty_Int64 ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + long long propValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetProperty_Int64_1 ( schemaNS, propName, propValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetProperty_Float ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + double propValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetProperty_Float_1 ( schemaNS, propName, propValue, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetProperty_Date ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + const XMP_DateTime & propValue, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_SetProperty_Date_1 ( schemaNS, propName, propValue, options ) ); +} + +// ================================================================================================= +// Miscellaneous Member Functions +// ============================== + +XMP_MethodIntro(TXMPMeta,XMPMetaRef):: +GetInternalRef() const +{ + return this->xmpRef; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +GetObjectName ( tStringObj * name ) const +{ + XMP_StringPtr namePtr = 0; + XMP_StringLen nameLen = 0; + WrapCheckVoid ( zXMPMeta_GetObjectName_1 ( &namePtr, &nameLen ) ); + if ( name != 0 ) name->assign ( namePtr, nameLen ); + WXMPMeta_UnlockObject_1 ( this->xmpRef, 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetObjectName ( XMP_StringPtr name ) +{ + WrapCheckVoid ( zXMPMeta_SetObjectName_1 ( name ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetObjectName ( tStringObj name ) +{ + this->SetObjectName ( name.c_str() ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,XMP_OptionBits):: +GetObjectOptions() const +{ + WrapCheckOptions ( options, zXMPMeta_GetObjectOptions_1() ); + return options; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SetObjectOptions ( XMP_OptionBits options ) +{ + WrapCheckVoid ( zXMPMeta_SetObjectOptions_1 ( options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,TXMPMeta<tStringObj>):: +Clone ( XMP_OptionBits options ) const +{ + WrapCheckMetaRef ( cloneRef, zXMPMeta_Clone_1 ( options ) ); + return TXMPMeta<tStringObj> ( cloneRef ); // Ref construct will increment the clientRefs. +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,XMP_Index):: +CountArrayItems ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName ) const +{ + WrapCheckIndex ( count, zXMPMeta_CountArrayItems_1 ( schemaNS, arrayName ) ); + return count; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,XMP_Status):: +DumpObject ( XMP_TextOutputProc outProc, + void * refCon ) const +{ + TOPW_Info info ( outProc, refCon ); + WrapCheckStatus ( status, zXMPMeta_DumpObject_1 ( TextOutputProcWrapper, &info ) ); + return status; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +ParseFromBuffer ( XMP_StringPtr buffer, + XMP_StringLen bufferSize, + XMP_OptionBits options /* = 0 */ ) +{ + WrapCheckVoid ( zXMPMeta_ParseFromBuffer_1 ( buffer, bufferSize, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SerializeToBuffer ( tStringObj * pktString, + XMP_OptionBits options, + XMP_StringLen padding, + XMP_StringPtr newline, + XMP_StringPtr indent, + XMP_Index baseIndent /* = 0 */ ) const +{ + XMP_StringPtr resultPtr = 0; + XMP_StringLen resultLen = 0; + WrapCheckVoid ( zXMPMeta_SerializeToBuffer_1 ( &resultPtr, &resultLen, options, padding, newline, indent, baseIndent ) ); + if ( pktString != 0 ) pktString->assign ( resultPtr, resultLen ); + WXMPMeta_UnlockObject_1 ( this->xmpRef, 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPMeta,void):: +SerializeToBuffer ( tStringObj * pktString, + XMP_OptionBits options /* = 0 */, + XMP_StringLen padding /* = 0 */ ) const +{ + this->SerializeToBuffer ( pktString, options, padding, "", "", 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +// ================================================================================================= diff --git a/public/include/client-glue/TXMPUtils.incl_cpp b/public/include/client-glue/TXMPUtils.incl_cpp new file mode 100644 index 0000000..761ac4e --- /dev/null +++ b/public/include/client-glue/TXMPUtils.incl_cpp @@ -0,0 +1,491 @@ +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +// ================================================================================================ +/// \file TXMPUtils.incl_cpp +/// \brief The implementation of the TXMPUtils template class. + +#include "XMP.hpp" +#include "client-glue/WXMP_Common.hpp" +#include "client-glue/WXMPUtils.hpp" + +// ================================================================================================= +// Implementation Guidelines +// ========================= +// +// The implementations of the template functions are very stylized. ... +// +// ================================================================================================= + +XMP_MethodIntro(TXMPUtils,void):: +ComposeArrayItemPath ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + tStringObj * fullPath ) +{ + XMP_StringPtr pathPtr = 0; + XMP_StringLen pathLen = 0; + WrapCheckVoid ( zXMPUtils_ComposeArrayItemPath_1 ( schemaNS, arrayName, itemIndex, &pathPtr, &pathLen ) ); + if ( fullPath != 0 ) fullPath->assign ( pathPtr, pathLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ComposeStructFieldPath ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + tStringObj * fullPath ) +{ + XMP_StringPtr pathPtr = 0; + XMP_StringLen pathLen = 0; + WrapCheckVoid ( zXMPUtils_ComposeStructFieldPath_1 ( schemaNS, structName, fieldNS, fieldName, &pathPtr, &pathLen ) ); + if ( fullPath != 0 ) fullPath->assign ( pathPtr, pathLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ComposeQualifierPath ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + tStringObj * fullPath ) +{ + XMP_StringPtr pathPtr = 0; + XMP_StringLen pathLen = 0; + WrapCheckVoid ( zXMPUtils_ComposeQualifierPath_1 ( schemaNS, propName, qualNS, qualName, &pathPtr, &pathLen ) ); + if ( fullPath != 0 ) fullPath->assign ( pathPtr, pathLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ComposeLangSelector ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr langName, + tStringObj * fullPath ) +{ + XMP_StringPtr pathPtr = 0; + XMP_StringLen pathLen = 0; + WrapCheckVoid ( zXMPUtils_ComposeLangSelector_1 ( schemaNS, arrayName, langName, &pathPtr, &pathLen ) ); + if ( fullPath != 0 ) fullPath->assign ( pathPtr, pathLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ComposeLangSelector ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + const tStringObj & langName, + tStringObj * fullPath ) +{ + TXMPUtils::ComposeLangSelector ( schemaNS, arrayName, langName.c_str(), fullPath ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ComposeFieldSelector ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + XMP_StringPtr fieldValue, + tStringObj * fullPath ) +{ + XMP_StringPtr pathPtr = 0; + XMP_StringLen pathLen = 0; + WrapCheckVoid ( zXMPUtils_ComposeFieldSelector_1 ( schemaNS, arrayName, fieldNS, fieldName, fieldValue, + &pathPtr, &pathLen ) ); + if ( fullPath != 0 ) fullPath->assign ( pathPtr, pathLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ComposeFieldSelector ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + const tStringObj & fieldValue, + tStringObj * fullPath ) +{ + TXMPUtils::ComposeFieldSelector ( schemaNS, arrayName, fieldNS, fieldName, fieldValue.c_str(), fullPath ); +} + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertFromBool ( bool binValue, + tStringObj * strValue ) +{ + XMP_StringPtr strPtr = 0; + XMP_StringLen strLen = 0; + WrapCheckVoid ( zXMPUtils_ConvertFromBool_1 ( binValue, &strPtr, &strLen ) ); + if ( strValue != 0 ) strValue->assign ( strPtr, strLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertFromInt ( long binValue, + XMP_StringPtr format, + tStringObj * strValue ) +{ + XMP_StringPtr strPtr = 0; + XMP_StringLen strLen = 0; + WrapCheckVoid ( zXMPUtils_ConvertFromInt_1 ( binValue, format, &strPtr, &strLen ) ); + if ( strValue != 0 ) strValue->assign ( strPtr, strLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertFromInt64 ( long long binValue, + XMP_StringPtr format, + tStringObj * strValue ) +{ + XMP_StringPtr strPtr = 0; + XMP_StringLen strLen = 0; + WrapCheckVoid ( zXMPUtils_ConvertFromInt64_1 ( binValue, format, &strPtr, &strLen ) ); + if ( strValue != 0 ) strValue->assign ( strPtr, strLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertFromFloat ( double binValue, + XMP_StringPtr format, + tStringObj * strValue ) +{ + XMP_StringPtr strPtr = 0; + XMP_StringLen strLen = 0; + WrapCheckVoid ( zXMPUtils_ConvertFromFloat_1 ( binValue, format, &strPtr, &strLen ) ); + if ( strValue != 0 ) strValue->assign ( strPtr, strLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertFromDate ( const XMP_DateTime & binValue, + tStringObj * strValue ) +{ + XMP_StringPtr strPtr = 0; + XMP_StringLen strLen = 0; + WrapCheckVoid ( zXMPUtils_ConvertFromDate_1 ( binValue, &strPtr, &strLen ) ); + if ( strValue != 0 ) strValue->assign ( strPtr, strLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,bool):: +ConvertToBool ( XMP_StringPtr strValue ) +{ + WrapCheckBool ( value, zXMPUtils_ConvertToBool_1 ( strValue ) ); + return value; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,bool):: +ConvertToBool ( const tStringObj & strValue ) +{ + return TXMPUtils::ConvertToBool ( strValue.c_str() ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,long):: +ConvertToInt ( XMP_StringPtr strValue ) +{ + WrapCheckInt32 ( value, zXMPUtils_ConvertToInt_1 ( strValue ) ); + return value; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,long):: +ConvertToInt ( const tStringObj & strValue ) +{ + return TXMPUtils::ConvertToInt ( strValue.c_str() ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,long long):: +ConvertToInt64 ( XMP_StringPtr strValue ) +{ + WrapCheckInt64 ( value, zXMPUtils_ConvertToInt64_1 ( strValue ) ); + return value; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,long long):: +ConvertToInt64 ( const tStringObj & strValue ) +{ + return TXMPUtils::ConvertToInt64 ( strValue.c_str() ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,double):: +ConvertToFloat ( XMP_StringPtr strValue ) +{ + WrapCheckFloat ( value, zXMPUtils_ConvertToFloat_1 ( strValue ) ); + return value; +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,double):: +ConvertToFloat ( const tStringObj & strValue ) +{ + return TXMPUtils::ConvertToFloat ( strValue.c_str() ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertToDate ( XMP_StringPtr strValue, + XMP_DateTime * binValue ) +{ + WrapCheckVoid ( zXMPUtils_ConvertToDate_1 ( strValue, binValue ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertToDate ( const tStringObj & strValue, + XMP_DateTime * binValue ) +{ + TXMPUtils::ConvertToDate ( strValue.c_str(), binValue ); +} + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +CurrentDateTime ( XMP_DateTime * time ) +{ + WrapCheckVoid ( zXMPUtils_CurrentDateTime_1 ( time ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +SetTimeZone ( XMP_DateTime * time ) +{ + WrapCheckVoid ( zXMPUtils_SetTimeZone_1 ( time ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertToUTCTime ( XMP_DateTime * time ) +{ + WrapCheckVoid ( zXMPUtils_ConvertToUTCTime_1 ( time ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +ConvertToLocalTime ( XMP_DateTime * time ) +{ + WrapCheckVoid ( zXMPUtils_ConvertToLocalTime_1 ( time ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,int):: +CompareDateTime ( const XMP_DateTime & left, + const XMP_DateTime & right ) +{ + WrapCheckInt32 ( result, zXMPUtils_CompareDateTime_1 ( left, right ) ); + return result; +} + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +EncodeToBase64 ( XMP_StringPtr rawStr, + XMP_StringLen rawLen, + tStringObj * encodedStr ) +{ + XMP_StringPtr encPtr = 0; + XMP_StringLen encLen = 0; + WrapCheckVoid ( zXMPUtils_EncodeToBase64_1 ( rawStr, rawLen, &encPtr, &encLen ) ); + if ( encodedStr != 0 ) encodedStr->assign ( encPtr, encLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +EncodeToBase64 ( const tStringObj & rawStr, + tStringObj * encodedStr ) +{ + TXMPUtils::EncodeToBase64 ( rawStr.c_str(), (XMP_StringLen)rawStr.size(), encodedStr ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +DecodeFromBase64 ( XMP_StringPtr encodedStr, + XMP_StringLen encodedLen, + tStringObj * rawStr ) +{ + XMP_StringPtr rawPtr = 0; + XMP_StringLen rawLen = 0; + WrapCheckVoid ( zXMPUtils_DecodeFromBase64_1 ( encodedStr, encodedLen, &rawPtr, &rawLen ) ); + if ( rawStr != 0 ) rawStr->assign ( rawPtr, rawLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +DecodeFromBase64 ( const tStringObj & encodedStr, + tStringObj * rawStr ) +{ + TXMPUtils::DecodeFromBase64 ( encodedStr.c_str(), (XMP_StringLen)encodedStr.size(), rawStr ); +} + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +PackageForJPEG ( const TXMPMeta<tStringObj> & xmpObj, + tStringObj * standardXMP, + tStringObj * extendedXMP, + tStringObj * extendedDigest ) +{ + XMP_StringPtr stdStr = 0; + XMP_StringLen stdLen = 0; + XMP_StringPtr extStr = 0; + XMP_StringLen extLen = 0; + XMP_StringPtr digestStr = 0; + XMP_StringLen digestLen = 0; + WrapCheckVoid ( zXMPUtils_PackageForJPEG_1 ( xmpObj.GetInternalRef(), + &stdStr, &stdLen, &extStr, &extLen, &digestStr, &digestLen ) ); + if ( standardXMP != 0 ) standardXMP->assign ( stdStr, stdLen ); + if ( extendedXMP != 0 ) extendedXMP->assign ( extStr, extLen ); + if ( extendedDigest != 0 ) extendedDigest->assign ( digestStr, digestLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +MergeFromJPEG ( TXMPMeta<tStringObj> * fullXMP, + const TXMPMeta<tStringObj> & extendedXMP ) +{ + WrapCheckVoid ( zXMPUtils_MergeFromJPEG_1 ( fullXMP->GetInternalRef(), extendedXMP.GetInternalRef() ) ); +} + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +CatenateArrayItems ( const TXMPMeta<tStringObj> & xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr separator, + XMP_StringPtr quotes, + XMP_OptionBits options, + tStringObj * catedStr ) +{ + XMP_StringPtr catedPtr = 0; + XMP_StringLen catedLen = 0; + WrapCheckVoid ( zXMPUtils_CatenateArrayItems_1 ( xmpObj.GetInternalRef(), schemaNS, arrayName, + separator, quotes, options, &catedPtr, &catedLen ) ); + if ( catedStr != 0 ) catedStr->assign ( catedPtr, catedLen ); + WXMPUtils_Unlock_1 ( 0 ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +SeparateArrayItems ( TXMPMeta<tStringObj> * xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits options, + XMP_StringPtr catedStr ) +{ + if ( xmpObj == 0 ) throw XMP_Error ( kXMPErr_BadParam, "Null output SXMPMeta pointer" ); + WrapCheckVoid ( zXMPUtils_SeparateArrayItems_1 ( xmpObj->GetInternalRef(), schemaNS, arrayName, options, catedStr ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +SeparateArrayItems ( TXMPMeta<tStringObj> * xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits options, + const tStringObj & catedStr ) +{ + TXMPUtils::SeparateArrayItems ( xmpObj, schemaNS, arrayName, options, catedStr.c_str() ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +RemoveProperties ( TXMPMeta<tStringObj> * xmpObj, + XMP_StringPtr schemaNS /* = 0 */, + XMP_StringPtr propName /* = 0 */, + XMP_OptionBits options /* = 0 */ ) +{ + if ( xmpObj == 0 ) throw XMP_Error ( kXMPErr_BadParam, "Null output SXMPMeta pointer" ); + WrapCheckVoid ( zXMPUtils_RemoveProperties_1 ( xmpObj->GetInternalRef(), schemaNS, propName, options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,void):: +AppendProperties ( const TXMPMeta<tStringObj> & source, + TXMPMeta<tStringObj> * dest, + XMP_OptionBits options /* = 0 */ ) +{ + if ( dest == 0 ) throw XMP_Error ( kXMPErr_BadParam, "Null output SXMPMeta pointer" ); + WrapCheckVoid ( zXMPUtils_AppendProperties_1 ( source.GetInternalRef(), dest->GetInternalRef(), options ) ); +} + +// ------------------------------------------------------------------------------------------------- + +XMP_MethodIntro(TXMPUtils,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 */ ) +{ + if ( dest == 0 ) throw XMP_Error ( kXMPErr_BadParam, "Null output SXMPMeta pointer" ); + WrapCheckVoid ( zXMPUtils_DuplicateSubtree_1 ( source.GetInternalRef(), dest->GetInternalRef(), + sourceNS, sourceRoot, destNS, destRoot, options ) ); +} + +// ================================================================================================= diff --git a/public/include/client-glue/WXMPFiles.hpp b/public/include/client-glue/WXMPFiles.hpp new file mode 100644 index 0000000..556ad54 --- /dev/null +++ b/public/include/client-glue/WXMPFiles.hpp @@ -0,0 +1,155 @@ +#ifndef __WXMPFiles_hpp__ +#define __WXMPFiles_hpp__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "client-glue/WXMP_Common.hpp" + +#if __cplusplus +extern "C" { +#endif + +// ================================================================================================= +/// \file WXMPFiles.h +/// \brief High level support to access metadata in files of interest to Adobe applications. +/// +/// This header ... +/// +// ================================================================================================= + +// ================================================================================================= + +#define WrapCheckXMPFilesRef(result,WCallProto) \ + WXMP_Result wResult; \ + WCallProto; \ + PropagateException ( wResult ); \ + XMPFilesRef result = XMPFilesRef(wResult.ptrResult) + +// ================================================================================================= + +#define zXMPFiles_GetVersionInfo_1(versionInfo) \ + WXMPFiles_GetVersionInfo_1 ( versionInfo /* no wResult */ ) + +#define zXMPFiles_Initialize_1() \ + WXMPFiles_Initialize_1 ( &wResult ) + +#define zXMPFiles_Initialize_2(options) \ + WXMPFiles_Initialize_2 ( options, &wResult ) + +#define zXMPFiles_Terminate_1() \ + WXMPFiles_Terminate_1 ( /* no wResult */ ) + +#define zXMPFiles_CTor_1() \ + WXMPFiles_CTor_1 ( &wResult ) + +#define zXMPFiles_GetFormatInfo_1(format,flags) \ + WXMPFiles_GetFormatInfo_1 ( format, flags, &wResult ) + +#define zXMPFiles_OpenFile_1(filePath,format,openFlags) \ + WXMPFiles_OpenFile_1 ( this->xmpFilesRef, filePath, format, openFlags, &wResult ) + +#define zXMPFiles_CloseFile_1(closeFlags) \ + WXMPFiles_CloseFile_1 ( this->xmpFilesRef, closeFlags, &wResult ) + +#define zXMPFiles_GetFileInfo_1(filePath,filePathLen,openFlags,format,handlerFlags) \ + WXMPFiles_GetFileInfo_1 ( this->xmpFilesRef, filePath, filePathLen, openFlags, format, handlerFlags, &wResult ) + +#define zXMPFiles_SetAbortProc_1(abortProc,abortArg) \ + WXMPFiles_SetAbortProc_1 ( this->xmpFilesRef, abortProc, abortArg, &wResult ) + +#define zXMPFiles_GetXMP_1(xmpRef,xmpPacket,xmpPacketLen,packetInfo) \ + WXMPFiles_GetXMP_1 ( this->xmpFilesRef, xmpRef, xmpPacket, xmpPacketLen, packetInfo, &wResult ) + +#define zXMPFiles_GetThumbnail_1(tnailInfo) \ + WXMPFiles_GetThumbnail_1 ( this->xmpFilesRef, tnailInfo, &wResult ) + +#define zXMPFiles_PutXMP_1(xmpRef,xmpPacket,xmpPacketLen) \ + WXMPFiles_PutXMP_1 ( this->xmpFilesRef, xmpRef, xmpPacket, xmpPacketLen, &wResult ) + +#define zXMPFiles_CanPutXMP_1(xmpRef,xmpPacket,xmpPacketLen) \ + WXMPFiles_CanPutXMP_1 ( this->xmpFilesRef, xmpRef, xmpPacket, xmpPacketLen, &wResult ) + +// ================================================================================================= + +extern void WXMPFiles_GetVersionInfo_1 ( XMP_VersionInfo * versionInfo ); + +extern void WXMPFiles_Initialize_1 ( WXMP_Result * result ); + +extern void WXMPFiles_Initialize_2 ( XMP_OptionBits options, WXMP_Result * result ); + +extern void WXMPFiles_Terminate_1(); + +extern void WXMPFiles_CTor_1 ( WXMP_Result * result ); + +extern void WXMPFiles_UnlockLib_1(); + +extern void WXMPFiles_UnlockObj_1 ( XMPFilesRef xmpFilesRef ); + +extern void WXMPFiles_IncrementRefCount_1 ( XMPFilesRef xmpFilesRef ); + +extern void WXMPFiles_DecrementRefCount_1 ( XMPFilesRef xmpFilesRef ); + +extern void WXMPFiles_GetFormatInfo_1 ( XMP_FileFormat format, + XMP_OptionBits * flags, // ! Can be null. + WXMP_Result * result ); + +extern void WXMPFiles_OpenFile_1 ( XMPFilesRef xmpFilesRef, + XMP_StringPtr filePath, + XMP_FileFormat format, + XMP_OptionBits openFlags, + WXMP_Result * result ); + +extern void WXMPFiles_CloseFile_1 ( XMPFilesRef xmpFilesRef, + XMP_OptionBits closeFlags, + WXMP_Result * result ); + +extern void WXMPFiles_GetFileInfo_1 ( XMPFilesRef xmpFilesRef, + XMP_StringPtr * filePath, + XMP_StringLen * filePathLen, + XMP_OptionBits * openFlags, // ! Can be null. + XMP_FileFormat * format, // ! Can be null. + XMP_OptionBits * handlerFlags, // ! Can be null. + WXMP_Result * result ); + +extern void WXMPFiles_SetAbortProc_1 ( XMPFilesRef xmpFilesRef, + XMP_AbortProc abortProc, + void * abortArg, + WXMP_Result * result ); + +extern void WXMPFiles_GetXMP_1 ( XMPFilesRef xmpFilesRef, + XMPMetaRef xmpRef, // ! Can be null. + XMP_StringPtr * xmpPacket, + XMP_StringLen * xmpPacketLen, + XMP_PacketInfo * packetInfo, // ! Can be null. + WXMP_Result * result ); + +extern void WXMPFiles_GetThumbnail_1 ( XMPFilesRef xmpFilesRef, + XMP_ThumbnailInfo * tnailInfo, // ! Can be null. + WXMP_Result * result ); + +extern void WXMPFiles_PutXMP_1 ( XMPFilesRef xmpFilesRef, + XMPMetaRef xmpRef, // ! Only one of the XMP object or packet are passed. + XMP_StringPtr xmpPacket, + XMP_StringLen xmpPacketLen, + WXMP_Result * result ); + +extern void WXMPFiles_CanPutXMP_1 ( XMPFilesRef xmpFilesRef, + XMPMetaRef xmpRef, // ! Only one of the XMP object or packet are passed. + XMP_StringPtr xmpPacket, + XMP_StringLen xmpPacketLen, + WXMP_Result * result ); + +// ================================================================================================= + +#if __cplusplus +} +#endif + +#endif // __WXMPFiles_hpp__ diff --git a/public/include/client-glue/WXMPIterator.hpp b/public/include/client-glue/WXMPIterator.hpp new file mode 100644 index 0000000..c5e9e26 --- /dev/null +++ b/public/include/client-glue/WXMPIterator.hpp @@ -0,0 +1,83 @@ +#if ! __WXMPIterator_hpp__ +#define __WXMPIterator_hpp__ 1 + +// ================================================================================================= +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved. +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "client-glue/WXMP_Common.hpp" + +#if __cplusplus +extern "C" { +#endif + +// ================================================================================================= + +#define zXMPIterator_PropCTor_1(xmpRef,schemaNS,propName,options) \ + WXMPIterator_PropCTor_1 ( xmpRef, schemaNS, propName, options, &wResult ); + +#define zXMPIterator_TableCTor_1(schemaNS,propName,options) \ + WXMPIterator_TableCTor_1 ( schemaNS, propName, options, &wResult ); + + +#define zXMPIterator_Next_1(schemaNS,nsSize,propPath,pathSize,propValue,valueSize,options) \ + WXMPIterator_Next_1 ( this->iterRef, schemaNS, nsSize, propPath, pathSize, propValue, valueSize, options, &wResult ); + +#define zXMPIterator_Skip_1(options) \ + WXMPIterator_Skip_1 ( this->iterRef, options, &wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPIterator_PropCTor_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPIterator_TableCTor_1 ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPIterator_IncrementRefCount_1 ( XMPIteratorRef iterRef ); + +extern void +WXMPIterator_DecrementRefCount_1 ( XMPIteratorRef iterRef ); + +extern void +WXMPIterator_Unlock_1 ( XMP_OptionBits options ); + +extern void +WXMPIterator_Next_1 ( XMPIteratorRef iterRef, + XMP_StringPtr * schemaNS, + XMP_StringLen * nsSize, + XMP_StringPtr * propPath, + XMP_StringLen * pathSize, + XMP_StringPtr * propValue, + XMP_StringLen * valueSize, + XMP_OptionBits * options, + WXMP_Result * wResult ); + +extern void +WXMPIterator_Skip_1 ( XMPIteratorRef iterRef, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPUtils_UnlockIter_1 ( XMPIteratorRef iterRef, + XMP_OptionBits options ); + +// ================================================================================================= + +#if __cplusplus +} /* extern "C" */ +#endif + +#endif // __WXMPIterator_hpp__ diff --git a/public/include/client-glue/WXMPMeta.hpp b/public/include/client-glue/WXMPMeta.hpp new file mode 100644 index 0000000..608da15 --- /dev/null +++ b/public/include/client-glue/WXMPMeta.hpp @@ -0,0 +1,610 @@ +#if ! __WXMPMeta_hpp__ +#define __WXMPMeta_hpp__ 1 + +// ================================================================================================= +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved. +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "client-glue/WXMP_Common.hpp" + +#if __cplusplus +extern "C" { +#endif + +// ================================================================================================= +#define zXMPMeta_GetVersionInfo_1(info) \ + WXMPMeta_GetVersionInfo_1 ( info /* no wResult */ ) + +#define zXMPMeta_Initialize_1() \ + WXMPMeta_Initialize_1 ( &wResult ) +#define zXMPMeta_Terminate_1() \ + WXMPMeta_Terminate_1 ( /* no wResult */ ) + +#define zXMPMeta_CTor_1() \ + WXMPMeta_CTor_1 ( &wResult ) + +#define zXMPMeta_GetGlobalOptions_1() \ + WXMPMeta_GetGlobalOptions_1 ( &wResult ) + +#define zXMPMeta_SetGlobalOptions_1(options) \ + WXMPMeta_SetGlobalOptions_1 ( options, &wResult ) + +#define zXMPMeta_DumpNamespaces_1(outProc,refCon) \ + WXMPMeta_DumpNamespaces_1 ( outProc, refCon, &wResult ) + +#define zXMPMeta_DumpAliases_1(outProc,refCon) \ + WXMPMeta_DumpAliases_1 ( outProc, refCon, &wResult ) + +#define zXMPMeta_RegisterNamespace_1(namespaceURI,suggestedPrefix,registeredPrefix,prefixSize) \ + WXMPMeta_RegisterNamespace_1 ( namespaceURI, suggestedPrefix, registeredPrefix, prefixSize, &wResult ) + +#define zXMPMeta_GetNamespacePrefix_1(namespaceURI,namespacePrefix,prefixSize) \ + WXMPMeta_GetNamespacePrefix_1 ( namespaceURI, namespacePrefix, prefixSize, &wResult ) + +#define zXMPMeta_GetNamespaceURI_1(namespacePrefix,namespaceURI,uriSize) \ + WXMPMeta_GetNamespaceURI_1 ( namespacePrefix, namespaceURI, uriSize, &wResult ) + +#define zXMPMeta_DeleteNamespace_1(namespaceURI) \ + WXMPMeta_DeleteNamespace_1 ( namespaceURI, &wResult ) + +#define zXMPMeta_RegisterAlias_1(aliasNS,aliasProp,actualNS,actualProp,arrayForm) \ + WXMPMeta_RegisterAlias_1 ( aliasNS, aliasProp, actualNS, actualProp, arrayForm, &wResult ) + +#define zXMPMeta_ResolveAlias_1(aliasNS,aliasProp,actualNS,nsSize,actualProp,propSize,arrayForm) \ + WXMPMeta_ResolveAlias_1 ( aliasNS, aliasProp, actualNS, nsSize, actualProp, propSize, arrayForm, &wResult ) + +#define zXMPMeta_DeleteAlias_1(aliasNS,aliasProp) \ + WXMPMeta_DeleteAlias_1 ( aliasNS, aliasProp, &wResult ) + +#define zXMPMeta_RegisterStandardAliases_1(schemaNS) \ + WXMPMeta_RegisterStandardAliases_1 ( schemaNS, &wResult ) + +#define zXMPMeta_GetProperty_1(schemaNS,propName,propValue,valueSize,options) \ + WXMPMeta_GetProperty_1 ( this->xmpRef, schemaNS, propName, propValue, valueSize, options, &wResult ) + +#define zXMPMeta_GetArrayItem_1(schemaNS,arrayName,itemIndex,itemValue,valueSize,options) \ + WXMPMeta_GetArrayItem_1 ( this->xmpRef, schemaNS, arrayName, itemIndex, itemValue, valueSize, options, &wResult ) + +#define zXMPMeta_GetStructField_1(schemaNS,structName,fieldNS,fieldName,fieldValue,valueSize,options) \ + WXMPMeta_GetStructField_1 ( this->xmpRef, schemaNS, structName, fieldNS, fieldName, fieldValue, valueSize, options, &wResult ) + +#define zXMPMeta_GetQualifier_1(schemaNS,propName,qualNS,qualName,qualValue,valueSize,options) \ + WXMPMeta_GetQualifier_1 ( this->xmpRef, schemaNS, propName, qualNS, qualName, qualValue, valueSize, options, &wResult ) + +#define zXMPMeta_SetProperty_1(schemaNS,propName,propValue,options) \ + WXMPMeta_SetProperty_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_SetArrayItem_1(schemaNS,arrayName,itemIndex,itemValue,options) \ + WXMPMeta_SetArrayItem_1 ( this->xmpRef, schemaNS, arrayName, itemIndex, itemValue, options, &wResult ) + +#define zXMPMeta_AppendArrayItem_1(schemaNS,arrayName,arrayOptions,itemValue,options) \ + WXMPMeta_AppendArrayItem_1 ( this->xmpRef, schemaNS, arrayName, arrayOptions, itemValue, options, &wResult ) + +#define zXMPMeta_SetStructField_1(schemaNS,structName,fieldNS,fieldName,fieldValue,options) \ + WXMPMeta_SetStructField_1 ( this->xmpRef, schemaNS, structName, fieldNS, fieldName, fieldValue, options, &wResult ) + +#define zXMPMeta_SetQualifier_1(schemaNS,propName,qualNS,qualName,qualValue,options) \ + WXMPMeta_SetQualifier_1 ( this->xmpRef, schemaNS, propName, qualNS, qualName, qualValue, options, &wResult ) + +#define zXMPMeta_DeleteProperty_1(schemaNS,propName) \ + WXMPMeta_DeleteProperty_1 ( this->xmpRef, schemaNS, propName, &wResult ) + +#define zXMPMeta_DeleteArrayItem_1(schemaNS,arrayName,itemIndex) \ + WXMPMeta_DeleteArrayItem_1 ( this->xmpRef, schemaNS, arrayName, itemIndex, &wResult ) + +#define zXMPMeta_DeleteStructField_1(schemaNS,structName,fieldNS,fieldName) \ + WXMPMeta_DeleteStructField_1 ( this->xmpRef, schemaNS, structName, fieldNS, fieldName, &wResult ) + +#define zXMPMeta_DeleteQualifier_1(schemaNS,propName,qualNS,qualName) \ + WXMPMeta_DeleteQualifier_1 ( this->xmpRef, schemaNS, propName, qualNS, qualName, &wResult ) + +#define zXMPMeta_DoesPropertyExist_1(schemaNS,propName) \ + WXMPMeta_DoesPropertyExist_1 ( this->xmpRef, schemaNS, propName, &wResult ) + +#define zXMPMeta_DoesArrayItemExist_1(schemaNS,arrayName,itemIndex) \ + WXMPMeta_DoesArrayItemExist_1 ( this->xmpRef, schemaNS, arrayName, itemIndex, &wResult ) + +#define zXMPMeta_DoesStructFieldExist_1(schemaNS,structName,fieldNS,fieldName) \ + WXMPMeta_DoesStructFieldExist_1 ( this->xmpRef, schemaNS, structName, fieldNS, fieldName, &wResult ) + +#define zXMPMeta_DoesQualifierExist_1(schemaNS,propName,qualNS,qualName) \ + WXMPMeta_DoesQualifierExist_1 ( this->xmpRef, schemaNS, propName, qualNS, qualName, &wResult ) + +#define zXMPMeta_GetLocalizedText_1(schemaNS,altTextName,genericLang,specificLang,actualLang,langSize,itemValue,valueSize,options) \ + WXMPMeta_GetLocalizedText_1 ( this->xmpRef, schemaNS, altTextName, genericLang, specificLang, actualLang, langSize, itemValue, valueSize, options, &wResult ) + +#define zXMPMeta_SetLocalizedText_1(schemaNS,altTextName,genericLang,specificLang,itemValue,options) \ + WXMPMeta_SetLocalizedText_1 ( this->xmpRef, schemaNS, altTextName, genericLang, specificLang, itemValue, options, &wResult ) + +#define zXMPMeta_GetProperty_Bool_1(schemaNS,propName,propValue,options) \ + WXMPMeta_GetProperty_Bool_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_GetProperty_Int_1(schemaNS,propName,propValue,options) \ + WXMPMeta_GetProperty_Int_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_GetProperty_Int64_1(schemaNS,propName,propValue,options) \ + WXMPMeta_GetProperty_Int64_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_GetProperty_Float_1(schemaNS,propName,propValue,options) \ + WXMPMeta_GetProperty_Float_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_GetProperty_Date_1(schemaNS,propName,propValue,options) \ + WXMPMeta_GetProperty_Date_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_SetProperty_Bool_1(schemaNS,propName,propValue,options) \ + WXMPMeta_SetProperty_Bool_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_SetProperty_Int_1(schemaNS,propName,propValue,options) \ + WXMPMeta_SetProperty_Int_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_SetProperty_Int64_1(schemaNS,propName,propValue,options) \ + WXMPMeta_SetProperty_Int64_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_SetProperty_Float_1(schemaNS,propName,propValue,options) \ + WXMPMeta_SetProperty_Float_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_SetProperty_Date_1(schemaNS,propName,propValue,options) \ + WXMPMeta_SetProperty_Date_1 ( this->xmpRef, schemaNS, propName, propValue, options, &wResult ) + +#define zXMPMeta_GetObjectName_1(namePtr,nameLen) \ + WXMPMeta_GetObjectName_1 ( this->xmpRef, namePtr, nameLen, &wResult ) + +#define zXMPMeta_SetObjectName_1(name) \ + WXMPMeta_SetObjectName_1 ( this->xmpRef, name, &wResult ) + +#define zXMPMeta_GetObjectOptions_1() \ + WXMPMeta_GetObjectOptions_1 ( this->xmpRef, &wResult ) + +#define zXMPMeta_SetObjectOptions_1(options) \ + WXMPMeta_SetObjectOptions_1 ( this->xmpRef, options, &wResult ) + +#define zXMPMeta_Clone_1(options) \ + WXMPMeta_Clone_1 ( this->xmpRef, options, &wResult ) + +#define zXMPMeta_CountArrayItems_1(schemaNS,arrayName) \ + WXMPMeta_CountArrayItems_1 ( this->xmpRef, schemaNS, arrayName, &wResult ) + +#define zXMPMeta_DumpObject_1(outProc,refCon) \ + WXMPMeta_DumpObject_1 ( this->xmpRef, outProc, refCon, &wResult ) + +#define zXMPMeta_ParseFromBuffer_1(buffer,bufferSize,options) \ + WXMPMeta_ParseFromBuffer_1 ( this->xmpRef, buffer, bufferSize, options, &wResult ) + +#define zXMPMeta_SerializeToBuffer_1(pktString,pktSize,options,padding,newline,indent,baseIndent) \ + WXMPMeta_SerializeToBuffer_1 ( this->xmpRef, pktString, pktSize, options, padding, newline, indent, baseIndent, &wResult ) + +// ================================================================================================= + +extern void +WXMPMeta_GetVersionInfo_1 ( XMP_VersionInfo * info ); + +extern void +WXMPMeta_Initialize_1 ( WXMP_Result * wResult ); +extern void +WXMPMeta_Terminate_1(); + +extern void +WXMPMeta_Unlock_1 ( XMP_OptionBits options ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_CTor_1 ( WXMP_Result * wResult ); + +extern void +WXMPMeta_IncrementRefCount_1 ( XMPMetaRef xmpRef ); + +extern void +WXMPMeta_DecrementRefCount_1 ( XMPMetaRef xmpRef ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_GetGlobalOptions_1 ( WXMP_Result * wResult ); + +extern void +WXMPMeta_SetGlobalOptions_1 ( XMP_OptionBits options, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_DumpNamespaces_1 ( XMP_TextOutputProc outProc, + void * refCon, + WXMP_Result * wResult ); + +extern void +WXMPMeta_DumpAliases_1 ( XMP_TextOutputProc outProc, + void * refCon, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_RegisterNamespace_1 ( XMP_StringPtr namespaceURI, + XMP_StringPtr suggestedPrefix, + XMP_StringPtr * registeredPrefix, + XMP_StringLen * prefixSize, + WXMP_Result * wResult ); + +extern void +WXMPMeta_GetNamespacePrefix_1 ( XMP_StringPtr namespaceURI, + XMP_StringPtr * namespacePrefix, + XMP_StringLen * prefixSize, + WXMP_Result * wResult ); + +extern void +WXMPMeta_GetNamespaceURI_1 ( XMP_StringPtr namespacePrefix, + XMP_StringPtr * namespaceURI, + XMP_StringLen * uriSize, + WXMP_Result * wResult ); + +extern void +WXMPMeta_DeleteNamespace_1 ( XMP_StringPtr namespaceURI, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_RegisterAlias_1 ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp, + XMP_StringPtr actualNS, + XMP_StringPtr actualProp, + XMP_OptionBits arrayForm, + WXMP_Result * wResult ); + +extern void +WXMPMeta_ResolveAlias_1 ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp, + XMP_StringPtr * actualNS, + XMP_StringLen * nsSize, + XMP_StringPtr * actualProp, + XMP_StringLen * propSize, + XMP_OptionBits * arrayForm, + WXMP_Result * wResult ); + +extern void +WXMPMeta_DeleteAlias_1 ( XMP_StringPtr aliasNS, + XMP_StringPtr aliasProp, + WXMP_Result * wResult ); + +extern void +WXMPMeta_RegisterStandardAliases_1 ( XMP_StringPtr schemaNS, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_UnlockObject_1 ( XMPMetaRef xmpRef, + XMP_OptionBits options ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_GetProperty_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr * propValue, + XMP_StringLen * valueSize, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_GetArrayItem_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + XMP_StringPtr * itemValue, + XMP_StringLen * valueSize, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_GetStructField_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + XMP_StringPtr * fieldValue, + XMP_StringLen * valueSize, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_GetQualifier_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + XMP_StringPtr * qualValue, + XMP_StringLen * valueSize, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_SetProperty_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr propValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SetArrayItem_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + XMP_StringPtr itemValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_AppendArrayItem_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits arrayOptions, + XMP_StringPtr itemValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SetStructField_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + XMP_StringPtr fieldValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SetQualifier_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + XMP_StringPtr qualValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_DeleteProperty_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + WXMP_Result * wResult ); + +extern void +WXMPMeta_DeleteArrayItem_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + WXMP_Result * wResult ); + +extern void +WXMPMeta_DeleteStructField_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + WXMP_Result * wResult ); + +extern void +WXMPMeta_DeleteQualifier_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_DoesPropertyExist_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_DoesArrayItemExist_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_DoesStructFieldExist_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_DoesQualifierExist_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + WXMP_Result * wResult ) /* const */ ; + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_GetLocalizedText_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr altTextName, + XMP_StringPtr genericLang, + XMP_StringPtr specificLang, + XMP_StringPtr * actualLang, + XMP_StringLen * langSize, + XMP_StringPtr * itemValue, + XMP_StringLen * valueSize, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_SetLocalizedText_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr altTextName, + XMP_StringPtr genericLang, + XMP_StringPtr specificLang, + XMP_StringPtr itemValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_GetProperty_Bool_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_Bool * propValue, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_GetProperty_Int_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_Int32 * propValue, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_GetProperty_Int64_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_Int64 * propValue, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_GetProperty_Float_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + double * propValue, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_GetProperty_Date_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_DateTime * propValue, + XMP_OptionBits * options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_SetProperty_Bool_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_Bool propValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SetProperty_Int_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_Int32 propValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SetProperty_Int64_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_Int64 propValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SetProperty_Float_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + double propValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SetProperty_Date_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + const XMP_DateTime & propValue, + XMP_OptionBits options, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_GetObjectName_1 ( XMPMetaRef xmpRef, + XMP_StringPtr * namePtr, + XMP_StringLen * nameLen, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_SetObjectName_1 ( XMPMetaRef xmpRef, + XMP_StringPtr name, + WXMP_Result * wResult ); + +extern void +WXMPMeta_GetObjectOptions_1 ( XMPMetaRef xmpRef, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_SetObjectOptions_1 ( XMPMetaRef xmpRef, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_Clone_1 ( XMPMetaRef xmpRef, + XMP_OptionBits options, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_CountArrayItems_1 ( XMPMetaRef xmpRef, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + WXMP_Result * wResult ) /* const */ ; + +extern void +WXMPMeta_DumpObject_1 ( XMPMetaRef xmpRef, + XMP_TextOutputProc outProc, + void * refCon, + WXMP_Result * wResult ) /* const */ ; + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPMeta_ParseFromBuffer_1 ( XMPMetaRef xmpRef, + XMP_StringPtr buffer, + XMP_StringLen bufferSize, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPMeta_SerializeToBuffer_1 ( XMPMetaRef xmpRef, + XMP_StringPtr * pktString, + XMP_StringLen * pktSize, + XMP_OptionBits options, + XMP_StringLen padding, + XMP_StringPtr newline, + XMP_StringPtr indent, + XMP_Index baseIndent, + WXMP_Result * wResult ) /* const */ ; + +// ================================================================================================= + +#if __cplusplus +} /* extern "C" */ +#endif + +#endif // __WXMPMeta_hpp__ diff --git a/public/include/client-glue/WXMPUtils.hpp b/public/include/client-glue/WXMPUtils.hpp new file mode 100644 index 0000000..fa82f7d --- /dev/null +++ b/public/include/client-glue/WXMPUtils.hpp @@ -0,0 +1,322 @@ +#if ! __WXMPUtils_hpp__ +#define __WXMPUtils_hpp__ 1 + +// ================================================================================================= +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved. +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "client-glue/WXMP_Common.hpp" + +#if __cplusplus +extern "C" { +#endif + +// ================================================================================================= + +#define zXMPUtils_ComposeArrayItemPath_1(schemaNS,arrayName,itemIndex,fullPath,pathSize) \ + WXMPUtils_ComposeArrayItemPath_1 ( schemaNS, arrayName, itemIndex, fullPath, pathSize, &wResult ); + +#define zXMPUtils_ComposeStructFieldPath_1(schemaNS,structName,fieldNS,fieldName,fullPath,pathSize) \ + WXMPUtils_ComposeStructFieldPath_1 ( schemaNS, structName, fieldNS, fieldName, fullPath, pathSize, &wResult ); + +#define zXMPUtils_ComposeQualifierPath_1(schemaNS,propName,qualNS,qualName,fullPath,pathSize) \ + WXMPUtils_ComposeQualifierPath_1 ( schemaNS, propName, qualNS, qualName, fullPath, pathSize, &wResult ); + +#define zXMPUtils_ComposeLangSelector_1(schemaNS,arrayName,langName,fullPath,pathSize) \ + WXMPUtils_ComposeLangSelector_1 ( schemaNS, arrayName, langName, fullPath, pathSize, &wResult ); + +#define zXMPUtils_ComposeFieldSelector_1(schemaNS,arrayName,fieldNS,fieldName,fieldValue,fullPath,pathSize) \ + WXMPUtils_ComposeFieldSelector_1 ( schemaNS, arrayName, fieldNS, fieldName, fieldValue, fullPath, pathSize, &wResult ); + +#define zXMPUtils_ConvertFromBool_1(binValue,strValue,strSize) \ + WXMPUtils_ConvertFromBool_1 ( binValue, strValue, strSize, &wResult ); + +#define zXMPUtils_ConvertFromInt_1(binValue,format,strValue,strSize) \ + WXMPUtils_ConvertFromInt_1 ( binValue, format, strValue, strSize, &wResult ); + +#define zXMPUtils_ConvertFromInt64_1(binValue,format,strValue,strSize) \ + WXMPUtils_ConvertFromInt64_1 ( binValue, format, strValue, strSize, &wResult ); + +#define zXMPUtils_ConvertFromFloat_1(binValue,format,strValue,strSize) \ + WXMPUtils_ConvertFromFloat_1 ( binValue, format, strValue, strSize, &wResult ); + +#define zXMPUtils_ConvertFromDate_1(binValue,strValue,strSize) \ + WXMPUtils_ConvertFromDate_1 ( binValue, strValue, strSize, &wResult ); + +#define zXMPUtils_ConvertToBool_1(strValue) \ + WXMPUtils_ConvertToBool_1 ( strValue, &wResult ); + +#define zXMPUtils_ConvertToInt_1(strValue) \ + WXMPUtils_ConvertToInt_1 ( strValue, &wResult ); + +#define zXMPUtils_ConvertToInt64_1(strValue) \ + WXMPUtils_ConvertToInt64_1 ( strValue, &wResult ); + +#define zXMPUtils_ConvertToFloat_1(strValue) \ + WXMPUtils_ConvertToFloat_1 ( strValue, &wResult ); + +#define zXMPUtils_ConvertToDate_1(strValue,binValue) \ + WXMPUtils_ConvertToDate_1 ( strValue, binValue, &wResult ); + +#define zXMPUtils_CurrentDateTime_1(time) \ + WXMPUtils_CurrentDateTime_1 ( time, &wResult ); + +#define zXMPUtils_SetTimeZone_1(time) \ + WXMPUtils_SetTimeZone_1 ( time, &wResult ); + +#define zXMPUtils_ConvertToUTCTime_1(time) \ + WXMPUtils_ConvertToUTCTime_1 ( time, &wResult ); + +#define zXMPUtils_ConvertToLocalTime_1(time) \ + WXMPUtils_ConvertToLocalTime_1 ( time, &wResult ); + +#define zXMPUtils_CompareDateTime_1(left,right) \ + WXMPUtils_CompareDateTime_1 ( left, right, &wResult ); + +#define zXMPUtils_EncodeToBase64_1(rawStr,rawLen,encodedStr,encodedLen) \ + WXMPUtils_EncodeToBase64_1 ( rawStr, rawLen, encodedStr, encodedLen, &wResult ); + +#define zXMPUtils_DecodeFromBase64_1(encodedStr,encodedLen,rawStr,rawLen) \ + WXMPUtils_DecodeFromBase64_1 ( encodedStr, encodedLen, rawStr, rawLen, &wResult ); + +#define zXMPUtils_PackageForJPEG_1(xmpObj,stdStr,stdLen,extStr,extLen,digestStr,digestLen) \ + WXMPUtils_PackageForJPEG_1 ( xmpObj, stdStr, stdLen, extStr, extLen, digestStr, digestLen, &wResult ); + +#define zXMPUtils_MergeFromJPEG_1(fullXMP,extendedXMP) \ + WXMPUtils_MergeFromJPEG_1 ( fullXMP, extendedXMP, &wResult ); + +#define zXMPUtils_CatenateArrayItems_1(xmpObj,schemaNS,arrayName,separator,quotes,options,catedPtr,catedLen) \ + WXMPUtils_CatenateArrayItems_1 ( xmpObj, schemaNS, arrayName, separator, quotes, options, catedPtr, catedLen, &wResult ); + +#define zXMPUtils_SeparateArrayItems_1(xmpObj,schemaNS,arrayName,options,catedStr) \ + WXMPUtils_SeparateArrayItems_1 ( xmpObj, schemaNS, arrayName, options, catedStr, &wResult ); + +#define zXMPUtils_RemoveProperties_1(xmpObj,schemaNS,propName,options) \ + WXMPUtils_RemoveProperties_1 ( xmpObj, schemaNS, propName, options, &wResult ); + +#define zXMPUtils_AppendProperties_1(source,dest,options) \ + WXMPUtils_AppendProperties_1 ( source, dest, options, &wResult ); + +#define zXMPUtils_DuplicateSubtree_1(source,dest,sourceNS,sourceRoot,destNS,destRoot,options) \ + WXMPUtils_DuplicateSubtree_1 ( source, dest, sourceNS, sourceRoot, destNS, destRoot, options, &wResult ); + +// ================================================================================================= + +extern void +WXMPUtils_Unlock_1 ( XMP_OptionBits options ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPUtils_ComposeArrayItemPath_1 ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_Index itemIndex, + XMP_StringPtr * fullPath, + XMP_StringLen * pathSize, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ComposeStructFieldPath_1 ( XMP_StringPtr schemaNS, + XMP_StringPtr structName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + XMP_StringPtr * fullPath, + XMP_StringLen * pathSize, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ComposeQualifierPath_1 ( XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_StringPtr qualNS, + XMP_StringPtr qualName, + XMP_StringPtr * fullPath, + XMP_StringLen * pathSize, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ComposeLangSelector_1 ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr langName, + XMP_StringPtr * fullPath, + XMP_StringLen * pathSize, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ComposeFieldSelector_1 ( XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr fieldNS, + XMP_StringPtr fieldName, + XMP_StringPtr fieldValue, + XMP_StringPtr * fullPath, + XMP_StringLen * pathSize, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPUtils_ConvertFromBool_1 ( XMP_Bool binValue, + XMP_StringPtr * strValue, + XMP_StringLen * strSize, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertFromInt_1 ( XMP_Int32 binValue, + XMP_StringPtr format, + XMP_StringPtr * strValue, + XMP_StringLen * strSize, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertFromInt64_1 ( XMP_Int64 binValue, + XMP_StringPtr format, + XMP_StringPtr * strValue, + XMP_StringLen * strSize, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertFromFloat_1 ( double binValue, + XMP_StringPtr format, + XMP_StringPtr * strValue, + XMP_StringLen * strSize, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertFromDate_1 ( const XMP_DateTime & binValue, + XMP_StringPtr * strValue, + XMP_StringLen * strSize, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPUtils_ConvertToBool_1 ( XMP_StringPtr strValue, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertToInt_1 ( XMP_StringPtr strValue, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertToInt64_1 ( XMP_StringPtr strValue, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertToFloat_1 ( XMP_StringPtr strValue, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertToDate_1 ( XMP_StringPtr strValue, + XMP_DateTime * binValue, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPUtils_CurrentDateTime_1 ( XMP_DateTime * time, + WXMP_Result * wResult ); + +extern void +WXMPUtils_SetTimeZone_1 ( XMP_DateTime * time, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertToUTCTime_1 ( XMP_DateTime * time, + WXMP_Result * wResult ); + +extern void +WXMPUtils_ConvertToLocalTime_1 ( XMP_DateTime * time, + WXMP_Result * wResult ); + +extern void +WXMPUtils_CompareDateTime_1 ( const XMP_DateTime & left, + const XMP_DateTime & right, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPUtils_EncodeToBase64_1 ( XMP_StringPtr rawStr, + XMP_StringLen rawLen, + XMP_StringPtr * encodedStr, + XMP_StringLen * encodedLen, + WXMP_Result * wResult ); + +extern void +WXMPUtils_DecodeFromBase64_1 ( XMP_StringPtr encodedStr, + XMP_StringLen encodedLen, + XMP_StringPtr * rawStr, + XMP_StringLen * rawLen, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPUtils_PackageForJPEG_1 ( XMPMetaRef xmpObj, + XMP_StringPtr * stdStr, + XMP_StringLen * stdLen, + XMP_StringPtr * extStr, + XMP_StringLen * extLen, + XMP_StringPtr * digestStr, + XMP_StringLen * digestLen, + WXMP_Result * wResult ); + +extern void +WXMPUtils_MergeFromJPEG_1 ( XMPMetaRef fullXMP, + XMPMetaRef extendedXMP, + WXMP_Result * wResult ); + +// ------------------------------------------------------------------------------------------------- + +extern void +WXMPUtils_CatenateArrayItems_1 ( XMPMetaRef xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_StringPtr separator, + XMP_StringPtr quotes, + XMP_OptionBits options, + XMP_StringPtr * catedStr, + XMP_StringLen * catedLen, + WXMP_Result * wResult ); + +extern void +WXMPUtils_SeparateArrayItems_1 ( XMPMetaRef xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr arrayName, + XMP_OptionBits options, + XMP_StringPtr catedStr, + WXMP_Result * wResult ); + +extern void +WXMPUtils_RemoveProperties_1 ( XMPMetaRef xmpObj, + XMP_StringPtr schemaNS, + XMP_StringPtr propName, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPUtils_AppendProperties_1 ( XMPMetaRef source, + XMPMetaRef dest, + XMP_OptionBits options, + WXMP_Result * wResult ); + +extern void +WXMPUtils_DuplicateSubtree_1 ( XMPMetaRef source, + XMPMetaRef dest, + XMP_StringPtr sourceNS, + XMP_StringPtr sourceRoot, + XMP_StringPtr destNS, + XMP_StringPtr destRoot, + XMP_OptionBits options, + WXMP_Result * wResult ); + +// ================================================================================================= + +#if __cplusplus +} /* extern "C" */ +#endif + +#endif // __WXMPUtils_hpp__ diff --git a/public/include/client-glue/WXMP_Common.hpp b/public/include/client-glue/WXMP_Common.hpp new file mode 100644 index 0000000..b21e67e --- /dev/null +++ b/public/include/client-glue/WXMP_Common.hpp @@ -0,0 +1,110 @@ +#if ! __WXMP_Common_hpp__ +#define __WXMP_Common_hpp__ 1 + +// ================================================================================================= +// Copyright 2002-2007 Adobe Systems Incorporated +// All Rights Reserved. +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#ifndef XMP_Inline + #if TXMP_EXPAND_INLINE + #define XMP_Inline inline + #else + #define XMP_Inline /* not inline */ + #endif +#endif + +#define XMP_CTorDTorIntro(Class) template <class tStringObj> XMP_Inline Class<tStringObj> +#define XMP_MethodIntro(Class,ResultType) template <class tStringObj> XMP_Inline ResultType Class<tStringObj> + +struct WXMP_Result { + XMP_StringPtr errMessage; + void * ptrResult; + double floatResult; + XMP_Uns64 int64Result; + XMP_Uns32 int32Result; + WXMP_Result() : errMessage(0) {}; +}; + +#if __cplusplus +extern "C" { +#endif + +#ifndef TraceXMPCalls + #define TraceXMPCalls 0 +#endif + + #define PropagateException(res) \ + if ( res.errMessage != 0 ) throw XMP_Error ( res.int32Result, res.errMessage ); +#if ! TraceXMPCalls + #define InvokeCheck(WCallProto) \ + WXMP_Result wResult; \ + WCallProto; \ + PropagateException ( wResult ) +#else + #define InvokeCheck(WCallProto) \ + WXMP_Result wResult; \ + fprintf ( stderr, "WXMP calling: %s\n", #WCallProto ); fflush ( stderr ); \ + WCallProto; \ + if ( wResult.errMessage == 0 ) { \ + fprintf ( stderr, "WXMP back, no error\n" ); fflush ( stderr ); \ + } else { \ + fprintf ( stderr, "WXMP back, error: %s\n", wResult.errMessage ); fflush ( stderr ); \ + } \ + PropagateException ( wResult ) +#endif + +// ------------------------------------------------------------------------------------------------- + +#define WrapNoCheckVoid(WCallProto) \ + WCallProto; + +#define WrapCheckVoid(WCallProto) \ + InvokeCheck(WCallProto) + +#define WrapCheckMetaRef(result,WCallProto) \ + InvokeCheck(WCallProto); \ + XMPMetaRef result = XMPMetaRef(wResult.ptrResult) + +#define WrapCheckIterRef(result,WCallProto) \ + InvokeCheck(WCallProto); \ + XMPIteratorRef result = XMPIteratorRef(wResult.ptrResult) + +#define WrapCheckBool(result,WCallProto) \ + InvokeCheck(WCallProto); \ + bool result = bool(wResult.int32Result) + +#define WrapCheckOptions(result,WCallProto) \ + InvokeCheck(WCallProto); \ + XMP_OptionBits result = XMP_OptionBits(wResult.int32Result) + +#define WrapCheckStatus(result,WCallProto) \ + InvokeCheck(WCallProto); \ + XMP_Status result = XMP_Status(wResult.int32Result) + +#define WrapCheckIndex(result,WCallProto) \ + InvokeCheck(WCallProto); \ + XMP_Index result = XMP_Index(wResult.int32Result) + +#define WrapCheckInt32(result,WCallProto) \ + InvokeCheck(WCallProto); \ + XMP_Int32 result = wResult.int32Result + +#define WrapCheckInt64(result,WCallProto) \ + InvokeCheck(WCallProto); \ + XMP_Int64 result = wResult.int64Result + +#define WrapCheckFloat(result,WCallProto) \ + InvokeCheck(WCallProto); \ + double result = wResult.floatResult + +// ================================================================================================= + +#if __cplusplus +} /* extern "C" */ +#endif + +#endif // __WXMP_Common_hpp__ |