summaryrefslogtreecommitdiff
path: root/XMPFilesPlugins/api/source/PluginUtils.cpp
blob: cbf7aca6d0deaa78409b6dbf7462a7168dc3a459 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// =================================================================================================
// Copyright Adobe
// Copyright 2014 Adobe
// 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_Const.h"
#include "source/XMP_LibUtils.hpp"
#include "PluginUtils.h"

namespace XMP_PLUGIN
{
	// =================================================================================================
	// ErrorCallbackInfo::CanNotify()
	// ====================================
	bool ErrorCallbackInfo::CanNotify() const
	{
		XMP_Assert ( (this->clientProc == 0) || (this->wrapperProc != 0) );
		return ( this->clientProc != 0 );
	}	// ErrorCallbackInfo::CanNotify()

	// =================================================================================================
	// ErrorCallbackInfo::ClientCallbackWrapper()
	// ====================================
	bool ErrorCallbackInfo::ClientCallbackWrapper ( XMP_StringPtr _filePath,
															 XMP_ErrorSeverity severity,
															 XMP_Int32 cause,
															 XMP_StringPtr messsage ) const
	{
	
		XMP_StringPtr filePathPtr = _filePath;
		if ( filePathPtr == 0 ) {
			filePathPtr = this->filePath.c_str();
		}

		XMP_Bool retValue = (*this->wrapperProc) ( this->clientProc, this->context, filePathPtr, severity, cause, messsage );
		return ConvertXMP_BoolToBool(retValue);
	}	// ErrorCallbackInfo::ClientCallbackWrapper()

	// =================================================================================================
	// ErrorNotifyClient
	// ===================================
	// Plugin method to throw exception
	void ErrorNotifyClient( GenericErrorCallback * errCBptr, XMP_ErrorSeverity severity, XMP_Error & error )
	{	
		if (errCBptr)
			errCBptr->NotifyClient( severity, error );
		else {
			if ( severity != kXMPErrSev_Recoverable )
				throw error;
		}
	}	// ErrorNotifyClient()
	
}	//  namespace XMP_PLUGIN