📄 txmpmeta.incl_cpp
字号:
// =================================================================================================// 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 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -