| XMP Toolkit SDK 6.0.0

TWrapperFunctions.h
Go to the documentation of this file.
1 #ifndef TWrapperFunctions_h__
2 #define TWrapperFunctions_h__ 1
3
4 // =================================================================================================
5 // Copyright Adobe
6 // Copyright 2014 Adobe
7 // All Rights Reserved
8 //
9 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
10 // of the Adobe license agreement accompanying it. If you have received this file from a source other
11 // than Adobe, then your use, modification, or distribution of it requires the prior written permission
12 // of Adobe.
13 // =================================================================================================
14
15 #include "XMPCommon/Interfaces/IError.h"
16
17 #if SUPPORT_VARIADIC_TEMPLATES
18 namespace AdobeXMPCommon {
20
33 template < typename className >
34 void CallSafeFunctionReturningVoid( className * ptr,
35 void ( APICALL className::*Func )( pcIError_base & ) )
36 {
37 pcIError_base error( NULL );
38 ( ptr->*Func )( error );
39 if ( error ) throw IError::MakeShared( error );
40 }
41
42 template< typename className, typename ... Ts >
43 void CallSafeFunctionReturningVoid( className * ptr,
44 void ( APICALL className::*Func )( Ts ..., pcIError_base & ), Ts ... Vs )
45 {
46 pcIError_base error( NULL );
47 ( ptr->*Func )( Vs ..., error );
48 if ( error ) throw IError::MakeShared( error );
49 }
52
65 template < typename className >
66 void CallConstSafeFunctionReturningVoid( const className * const ptr,
67 void ( APICALL className::*Func )( pcIError_base & ) const )
68 {
69 pcIError_base error( NULL );
70 ( ptr->*Func )( error );
71 if ( error ) throw IError::MakeShared( error );
72 }
73
74 template < typename className, typename ... Ts >
75 void CallConstSafeFunctionReturningVoid( const className * const ptr,
76 void ( APICALL className::*Func )( Ts ..., pcIError_base & ) const, Ts ... Vs )
77 {
78 pcIError_base error( NULL );
79 ( ptr->*Func )( Vs ..., error );
80 if ( error ) throw IError::MakeShared( error );
81 }
84
97 template < typename className, typename returnType, typename internalReturnType >
98 returnType CallSafeFunction( className * ptr,
99 internalReturnType ( APICALL className::*Func )( pcIError_base & ) )
100 {
101 pcIError_base error( NULL );
102 internalReturnType returnValue = (ptr->*Func)( error );
103 if ( error ) throw IError::MakeShared( error );
104 #if XMP_WinBuild
105 #pragma warning( push )
106 #pragma warning( disable : 4800 )
107 #endif
108 return static_cast< returnType >( returnValue );
109 #if XMP_WinBuild
110 #pragma warning( pop )
111 #endif
112 }
113
114 template < typename className, typename returnType, typename internalReturnType, typename ... Ts >
115 returnType CallSafeFunction( className * ptr,
116 internalReturnType ( APICALL className::*Func )( Ts ..., pcIError_base & ), Ts ... Vs )
117 {
118 pcIError_base error( NULL );
119 internalReturnType returnValue = (ptr->*Func)( Vs ..., error );
120 if ( error ) throw IError::MakeShared( error );
121 #if XMP_WinBuild
122 #pragma warning( push )
123 #pragma warning( disable : 4800 )
124 #endif
125 return static_cast< returnType >( returnValue );
126 #if XMP_WinBuild
127 #pragma warning( pop )
128 #endif
129 }
132
145 template < typename className, typename returnType, typename internalReturnType >
146 returnType CallConstSafeFunction( const className * const ptr,
147 internalReturnType ( APICALL className::*Func )( pcIError_base & ) const )
148 {
149 pcIError_base error( NULL );
150 internalReturnType returnValue = (ptr->*Func)( error );
151 if ( error ) throw IError::MakeShared( error );
152 #if XMP_WinBuild
153 #pragma warning( push )
154 #pragma warning( disable : 4800 )
155 #endif
156 return static_cast< returnType >( returnValue );
157 #if XMP_WinBuild
158 #pragma warning( pop )
159 #endif
160 }
161
162 template < typename className, typename returnType, typename internalReturnType, typename ... Ts >
163 returnType CallConstSafeFunction( const className * const ptr,
164 internalReturnType ( APICALL className::*Func )( Ts ..., pcIError_base & ) const, Ts ... Vs )
165 {
166 pcIError_base error( NULL );
167 internalReturnType returnValue = (ptr->*Func)( Vs ..., error );
168 if ( error ) throw IError::MakeShared( error );
169 #if XMP_WinBuild
170 #pragma warning( push )
171 #pragma warning( disable : 4800 )
172 #endif
173 return static_cast< returnType >( returnValue );
174 #if XMP_WinBuild
175 #pragma warning( pop )
176 #endif
177 }
180
193 template < typename className, typename internalReturnType, typename sharedPointerType >
194 shared_ptr< sharedPointerType > CallSafeFunctionReturningPointer( className * ptr,
195 internalReturnType ( APICALL className::*Func )( pcIError_base & ) )
196 {
197 pcIError_base error( NULL );
198 internalReturnType returnValue = (ptr->*Func)( error );
199 if ( error ) throw IError::MakeShared( error );
200 return sharedPointerType::MakeShared( returnValue );
201 }
202
203 template < typename className, typename internalReturnType, typename sharedPointerType, typename ... Ts >
204 shared_ptr< sharedPointerType > CallSafeFunctionReturningPointer( className * ptr,
205 internalReturnType ( APICALL className::*Func )( Ts ..., pcIError_base & ), Ts ... Vs )
206 {
207 pcIError_base error( NULL );
208 internalReturnType returnValue = ( ptr->*Func )( Vs ..., error );
209 if ( error ) throw IError::MakeShared( error );
210 return sharedPointerType::MakeShared( returnValue );
211 }
214
227 template < typename className, typename internalReturnType, typename sharedPointerType >
228 shared_ptr< sharedPointerType > CallConstSafeFunctionReturningPointer( const className * const ptr,
229 internalReturnType ( APICALL className::*Func )( pcIError_base & ) const )
230 {
231 pcIError_base error( NULL );
232 internalReturnType returnValue = (ptr->*Func)( error );
233 if ( error ) throw IError::MakeShared( error );
234 return sharedPointerType::MakeShared( returnValue );
235 }
236
237 template < typename className, typename internalReturnType, typename sharedPointerType, typename ... Ts >
238 shared_ptr< sharedPointerType > CallConstSafeFunctionReturningPointer( const className * const ptr,
239 internalReturnType ( APICALL className::*Func )( Ts ..., pcIError_base & ) const, Ts ... Vs )
240 {
241 pcIError_base error( NULL );
242 internalReturnType returnValue = ( ptr->*Func )( Vs ..., error );
243 if ( error ) throw IError::MakeShared( error );
244 return sharedPointerType::MakeShared( returnValue );
245 }
248 }
249
251 #else
252 #include "XMPCommon/Utilities/TWrapperFunctions2.h"
253 #endif
254 #endif // TWrapperFunctions_h__
IError.h
AdobeXMPCommon
Definition: IConfigurable.h:21
TWrapperFunctions2.h
AdobeXMPCommon::pcIError_base
const typedef IError_v1 * pcIError_base
Definition: XMPCommonFwdDeclarations.h:64