| XMP Toolkit SDK 6.0.0

IError.h
Go to the documentation of this file.
1 #ifndef __IError_h__
3 #define __IError_h__ 1
4
5 // =================================================================================================
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/BaseInterfaces/ISharedObject.h"
16 #include "XMPCommon/Interfaces/BaseInterfaces/IVersionable.h"
17
18 #include "XMPCommon/XMPCommonFwdDeclarations.h"
19
20 namespace AdobeXMPCommon {
21
28 class XMP_PUBLIC IError_v1
29 : public virtual ISharedObject
30 , public virtual IVersionable
31 {
32 public:
36 typedef enum {
38 kESNone = 0,
39
41 kESWarning = 1 << 0,
42
44 kESOperationFatal = 1 << 1,
45
47 kESProcessFatal = 1 << 2,
48
49 // Add new severities here
50
52 kESMaxValue = 1 << 31,
53
55 kESAll = kAllBits,
56 } eErrorSeverity;
57
58
62 typedef enum {
64 kEDNone = 0,
65
67 kEDGeneral = 1,
68
70 kEDMemoryManagement = 2,
71
73 kEDConfigurable = 3,
74
76 kEDMultiThreading = 4,
77
79 kEDDataModel = 100,
80
82 kEDParser = 101,
83
85 kEDSerializer = 102,
86
87
89 kEDXMPFiles = 200,
90
91
93 kEDConflictIdentification = 400,
94
96 kEDConflictResolution = 500,
97
99 kEDThreeWayMerge = 600,
100
102 kEDGenericStrategyDatabase = 601,
103
105 kEDAssetManagement = 10000,
106
108 kEDMaxValue = kMaxEnumValue
109 } eErrorDomain;
110
111 typedef uint32 eErrorCode;
112
117 virtual eErrorCode APICALL GetCode() const = 0;
118
123 virtual eErrorDomain APICALL GetDomain() const = 0;
124
129 virtual eErrorSeverity APICALL GetSeverity() const = 0;
130
137 virtual spcIUTF8String APICALL GetMessage() const = 0;
138
145 virtual spcIUTF8String APICALL GetLocation() const = 0;
146
157 virtual spcIUTF8String APICALL GetParameter( sizet index ) const = 0;
158
163 virtual sizet APICALL GetParametersCount() const __NOTHROW__ = 0;
164
171 virtual spIError APICALL GetNextError() = 0;
172
173 XMP_PRIVATE spcIError GetNextError() const {
174 return const_cast< IError_v1 * >( this )->GetNextError();
175 }
177
184 virtual spIError APICALL SetNextError( const spIError & error ) = 0;
185
193 virtual void APICALL SetMessage( const char * message, sizet len = npos ) __NOTHROW__ = 0;
194
202 virtual void APICALL SetLocation( const char * fileName, sizet lineNumber ) __NOTHROW__ = 0;
203
211 virtual void APICALL AppendParameter( const char * parameter, sizet len = npos ) __NOTHROW__ = 0;
212
217 virtual void APICALL AppendParameter( void * addressParameter ) __NOTHROW__ = 0;
218
223 virtual void APICALL AppendParameter( const uint32 & integerValue ) __NOTHROW__ = 0;
224
229 virtual void APICALL AppendParameter( const uint64 & integerValue ) __NOTHROW__ = 0;
230
235 virtual void APICALL AppendParameter( const int32 & integerValue ) __NOTHROW__ = 0;
236
241 virtual void APICALL AppendParameter( const int64 & integerValue ) __NOTHROW__ = 0;
242
247 virtual void APICALL AppendParameter( const float & floatValue ) __NOTHROW__ = 0;
248
253 virtual void APICALL AppendParameter( const double & doubleValue ) __NOTHROW__ = 0;
254
259 virtual void APICALL AppendParameter( bool booleanValue ) __NOTHROW__ = 0;
260
269 static spIError CreateError( pIObjectFactory objFactory, eErrorDomain errDomain,
270 eErrorCode errCode, eErrorSeverity errSeverity );
271
278 virtual pIError APICALL GetActualIError() __NOTHROW__ = 0;
279 XMP_PRIVATE pcIError GetActualIError() const __NOTHROW__ {
280 return const_cast< IError_v1 * >( this )->GetActualIError();
281 }
284
292 XMP_PRIVATE static spIError MakeShared( pIError_base ptr );
293 XMP_PRIVATE static spcIError MakeShared( pcIError_base ptr ) {
294 return MakeShared( const_cast< pIError_base >( ptr ) );
295 }
298
303 XMP_PRIVATE static uint64 GetInterfaceID() { return kIErrorID; }
304
309 XMP_PRIVATE static uint32 GetInterfaceVersion() { return 1; }
311
312 protected:
316 virtual ~IError_v1() __NOTHROW__ {}
317
319 virtual uint32 APICALL getCode( pcIError_base & error ) const __NOTHROW__ = 0;
320 virtual uint32 APICALL getDomain( pcIError_base & error ) const __NOTHROW__ = 0;
321 virtual uint32 APICALL getSeverity( pcIError_base & error ) const __NOTHROW__ = 0;
322 virtual pcIUTF8String_base APICALL getMessage( pcIError_base & error ) const __NOTHROW__ = 0;
323 virtual pcIUTF8String_base APICALL getLocation( pcIError_base & error ) const __NOTHROW__ = 0;
324 virtual pcIUTF8String_base APICALL getParameter( sizet index, pcIError_base & error ) const __NOTHROW__ = 0;
325 virtual pIError_base APICALL getNextError( pcIError_base & error ) __NOTHROW__ = 0;
326 virtual pIError_base APICALL setNextError( pIError_base nextError, pcIError_base & error ) __NOTHROW__ = 0;
327
328 #ifdef FRIEND_CLASS_DECLARATION
329 FRIEND_CLASS_DECLARATION();
330 #endif
331 REQ_FRIEND_CLASS_DECLARATION();
333 };
334
345 typedef uint32( *ReportErrorAndContinueABISafeProc )( uint32 errorDomain, uint32 errorCode, uint32 errorSeverity, const char * message, pcIError_base & error );
346
352 class ReportErrorAndContinueFunctor {
353 public:
354 ReportErrorAndContinueFunctor( ReportErrorAndContinueABISafeProc safeProc )
355 : mSafeProc( safeProc ) {}
356
364 bool operator()( IError_v1::eErrorDomain errorDomain, IError_v1::eErrorCode errorCode, IError_v1::eErrorSeverity errorSeverity, const char * message ) {
365 pcIError_base error( NULL );
366 auto retValue = mSafeProc( static_cast< uint32 >( errorDomain ), static_cast< uint32 >( errorCode ), static_cast< uint32 >( errorSeverity ), message, error );
367 if ( error )
368 throw IError_v1::MakeShared( error );
369 return retValue != 0 ? true : false;
370 }
371
372 protected:
373 ReportErrorAndContinueABISafeProc mSafeProc;
374 };
375
376
377 }
378
379 #endif // __IError_h__
AdobeXMPCommon::spIError
shared_ptr< IError > spIError
Definition: XMPCommonFwdDeclarations.h:68
AdobeXMPCommon::IError_v1::eErrorSeverity
eErrorSeverity
Indicates various types of errors.
Definition: IError.h:36
AdobeXMPCommon::ReportErrorAndContinueFunctor::mSafeProc
ReportErrorAndContinueABISafeProc mSafeProc
Definition: IError.h:373
XMP_PRIVATE
#define XMP_PRIVATE
Definition: XMP_Environment.h:222
AdobeXMPCommon::IError_v1::~IError_v1
virtual ~IError_v1() __NOTHROW__
Definition: IError.h:316
__NOTHROW__
#define __NOTHROW__
Definition: XMPCommonDefines.h:147
AdobeXMPCommon::IError_v1
Version1 of the interface that represents an error/warning encountered during processing.
Definition: IError.h:28
XMP_PUBLIC
#define XMP_PUBLIC
Definition: XMP_Environment.h:221
AdobeXMPCommon::pcIUTF8String_base
const typedef IUTF8String_v1 * pcIUTF8String_base
Definition: XMPCommonFwdDeclarations.h:75
AdobeXMPCommon::pIObjectFactory
IObjectFactory * pIObjectFactory
Definition: XMPCommonFwdDeclarations.h:57
ISharedObject.h
AdobeXMPCommon
Definition: IConfigurable.h:21
AdobeXMPCommon::spcIUTF8String
shared_ptr< const IUTF8String > spcIUTF8String
Definition: XMPCommonFwdDeclarations.h:80
AdobeXMPCommon::kMaxEnumValue
static const uint32 kMaxEnumValue(Max_XMP_Uns32)
AdobeXMPCommon::npos
const sizet npos(kMaxSize)
AdobeXMPCommon::ReportErrorAndContinueFunctor::operator()
bool operator()(IError_v1::eErrorDomain errorDomain, IError_v1::eErrorCode errorCode, IError_v1::eErrorSeverity errorSeverity, const char *message)
Definition: IError.h:364
XMPCommonFwdDeclarations.h
AdobeXMPCommon::IError_v1::eErrorDomain
eErrorDomain
Indicates various types of error domains.
Definition: IError.h:62
AdobeXMPCommon::uint32
XMP_Uns32 uint32
Definition: XMPCommonDefines.h:174
AdobeXMPCommon::kIErrorID
static const uint64 kIErrorID(0x6e4572726f722020)
AdobeXMPCommon::spcIError
shared_ptr< const IError > spcIError
Definition: XMPCommonFwdDeclarations.h:69
AdobeXMPCommon::sizet
uint32 sizet
Definition: XMPCommonDefines.h:176
AdobeXMPCommon::IVersionable
Interface that serves as the base interface for all the externally exposed interfaces which needs to ...
Definition: IVersionable.h:30
AdobeXMPCommon::pIError_base
IError_v1 * pIError_base
Definition: XMPCommonFwdDeclarations.h:63
AdobeXMPCommon::int32
XMP_Int32 int32
Definition: XMPCommonDefines.h:173
AdobeXMPCommon::pcIError
const typedef IError * pcIError
Definition: XMPCommonFwdDeclarations.h:67
REQ_FRIEND_CLASS_DECLARATION
#define REQ_FRIEND_CLASS_DECLARATION()
Definition: XMPCommonDefines.h:137
AdobeXMPCommon::pIError
IError * pIError
Definition: XMPCommonFwdDeclarations.h:66
IVersionable.h
AdobeXMPCommon::ReportErrorAndContinueABISafeProc
uint32(* ReportErrorAndContinueABISafeProc)(uint32 errorDomain, uint32 errorCode, uint32 errorSeverity, const char *message, pcIError_base &error)
A function pointer to report back errors and warnings to the library encountered during the serializa...
Definition: IError.h:345
AdobeXMPCommon::IError_v1::eErrorCode
uint32 eErrorCode
Definition: IError.h:111
AdobeXMPCommon::ReportErrorAndContinueFunctor::ReportErrorAndContinueFunctor
ReportErrorAndContinueFunctor(ReportErrorAndContinueABISafeProc safeProc)
Definition: IError.h:354
AdobeXMPCommon::int64
XMP_Int64 int64
Definition: XMPCommonDefines.h:171
AdobeXMPCommon::ReportErrorAndContinueFunctor
A Function object used by the client to report back and warnings to the library encountered during th...
Definition: IError.h:352
AdobeXMPCommon::pcIError_base
const typedef IError_v1 * pcIError_base
Definition: XMPCommonFwdDeclarations.h:64
AdobeXMPCommon::uint64
XMP_Uns64 uint64
Definition: XMPCommonDefines.h:172
AdobeXMPCommon::kAllBits
static const uint32 kAllBits(0xFFFFFFFF)
AdobeXMPCommon::ISharedObject
Interface that serves as the base interface of all the externally exposed interfaces.
Definition: ISharedObject.h:29