summaryrefslogtreecommitdiff
path: root/public/include/XMPCore/source/IPath.cpp
blob: bd190b174fd312094b20a035593ab0e225b61d5e (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// =================================================================================================
// Copyright Adobe
// Copyright 2020 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. 
// =================================================================================================

namespace AdobeXMPCore {
	class IPathProxy;
}

#define FRIEND_CLASS_DECLARATION() friend class AdobeXMPCore::IPathProxy;

#include "XMPCore/Interfaces/IPath.h"

#if !BUILDING_XMPCORE_LIB && !SOURCE_COMPILING_XMPCORE_LIB

#include "XMPCommon/Utilities/TWrapperFunctions.h"
#include "XMPCore/Interfaces/INameSpacePrefixMap.h"
#include "XMPCommon/Interfaces/IUTF8String.h"
#include "XMPCore/Interfaces/IPathSegment.h"
#include "XMPCore/Interfaces/ICoreObjectFactory.h"

#include <assert.h>

namespace AdobeXMPCore {

	class IPathProxy
		: public virtual IPath
	{
	private:
		pIPath mRawPtr;

	public:
		IPathProxy( pIPath ptr )
			: mRawPtr( ptr )
		{
			mRawPtr->Acquire();
		}

		~IPathProxy() __NOTHROW__ { mRawPtr->Release(); }

		pIPath APICALL GetActualIPath() __NOTHROW__ { return mRawPtr; }

		void APICALL Acquire() const __NOTHROW__ { assert( false ); }

		void APICALL Release() const __NOTHROW__ { assert( false ); }

		AdobeXMPCommon_Int::pISharedObject_I APICALL GetISharedObject_I() __NOTHROW__ {
			return mRawPtr->GetISharedObject_I();
		}

		AdobeXMPCore_Int::pIPath_I APICALL GetIPath_I() __NOTHROW__ {
			return mRawPtr->GetIPath_I();
		}

		pvoid APICALL GetInterfacePointer( uint64 interfaceID, uint32 interfaceVersion ) {
			return CallSafeFunction< IVersionable, pvoid, pvoid, uint64, uint32 >(
				mRawPtr, &IVersionable::getInterfacePointer, interfaceID, interfaceVersion );
		}

		pvoid APICALL getInterfacePointer( uint64 interfaceID, uint32 interfaceVersion, pcIError_base & error ) __NOTHROW__ {
			assert( false );
			return mRawPtr->getInterfacePointer( interfaceID, interfaceVersion, error );
		}

		virtual spcINameSpacePrefixMap APICALL RegisterNameSpacePrefixMap( const spcINameSpacePrefixMap & map ) {
			return CallSafeFunctionReturningPointer< IPath_v1, pcINameSpacePrefixMap_base, const INameSpacePrefixMap, pcINameSpacePrefixMap_base >(
				mRawPtr, &IPath_v1::registerNameSpacePrefixMap, map ? map->GetActualINameSpacePrefixMap() : NULL );
		}

		virtual pcINameSpacePrefixMap_base APICALL registerNameSpacePrefixMap( pcINameSpacePrefixMap_base map, pcIError_base & error ) __NOTHROW__ {
			assert( false );
			return mRawPtr->registerNameSpacePrefixMap( map, error );
		}

		virtual spIUTF8String APICALL Serialize( const spcINameSpacePrefixMap & map ) const {
			return CallConstSafeFunctionReturningPointer< IPath_v1, pIUTF8String_base, IUTF8String, pcINameSpacePrefixMap_base >(
				mRawPtr, &IPath_v1::serialize, map ? map->GetActualINameSpacePrefixMap() : NULL );
		}

		virtual pIUTF8String_base APICALL serialize( pcINameSpacePrefixMap_base map, pcIError_base & error ) const __NOTHROW__ {
			assert( false );
			return mRawPtr->serialize( map, error );
		}

		virtual void APICALL AppendPathSegment( const spcIPathSegment & segment ) {
			return CallSafeFunctionReturningVoid< IPath_v1, pcIPathSegment_base >(
				mRawPtr, &IPath_v1::appendPathSegment, segment ? segment->GetActualIPathSegment() : NULL );
		}

		virtual void APICALL appendPathSegment( pcIPathSegment_base segment, pcIError_base & error ) __NOTHROW__ {
			assert( false );
			return mRawPtr->appendPathSegment( segment, error );
		}

		virtual spcIPathSegment APICALL RemovePathSegment( sizet index ) {
			return CallSafeFunctionReturningPointer< IPath_v1, pcIPathSegment_base, const IPathSegment, sizet >(
				mRawPtr, &IPath_v1::removePathSegment, index );
		}

		virtual pcIPathSegment_base APICALL removePathSegment( sizet index, pcIError_base & error ) __NOTHROW__ {
			assert( false );
			return mRawPtr->removePathSegment( index, error );
		}

		virtual spcIPathSegment APICALL GetPathSegment( sizet index ) const {
			return CallConstSafeFunctionReturningPointer< IPath_v1, pcIPathSegment_base, const IPathSegment, sizet >(
				mRawPtr, &IPath_v1::getPathSegment, index );
		}

		virtual pcIPathSegment_base APICALL getPathSegment( sizet index, pcIError_base & error ) const __NOTHROW__ {
			assert( false );
			return mRawPtr->getPathSegment( index, error );
		}

		virtual sizet APICALL Size() const __NOTHROW__ {
			return mRawPtr->Size(  );
		}

		virtual void APICALL Clear() __NOTHROW__ {
			return mRawPtr->Clear(  );
		}

		virtual spIPath APICALL Clone( sizet startingIndex, sizet countOfSegments ) const {
			return CallConstSafeFunctionReturningPointer< IPath_v1, pIPath_base, IPath, sizet, sizet >(
				mRawPtr, &IPath_v1::clone, startingIndex, countOfSegments );
		}

		virtual pIPath_base APICALL clone( sizet startingIndex, sizet countOfSegemetns, pcIError_base & error ) const __NOTHROW__ {
			assert( false );
			return mRawPtr->clone( startingIndex, countOfSegemetns, error );
		}

	};

	spIPath IPath_v1::MakeShared( pIPath_base ptr ) {
		if ( !ptr ) return spIPath();
		pIPath p = IPath::GetInterfaceVersion() > 1 ? ptr->GetInterfacePointer< IPath >() : ptr;
		return shared_ptr< IPath >( new IPathProxy( p ) );
	}

	spIPath IPath_v1::CreatePath() {
		return CallSafeFunctionReturningPointer< ICoreObjectFactory, pIPath_base, IPath >(
			ICoreObjectFactory::GetCoreObjectFactory(), &ICoreObjectFactory::CreatePath );
	}

	spIPath IPath_v1::ParsePath( const char * path, sizet pathLength, const spcINameSpacePrefixMap & map ) {
		return CallSafeFunctionReturningPointer< ICoreObjectFactory, pIPath_base, IPath, const char *, sizet, pcINameSpacePrefixMap_base >(
			ICoreObjectFactory::GetCoreObjectFactory(), &ICoreObjectFactory::ParsePath, path, pathLength, map ? map->GetActualINameSpacePrefixMap() : NULL );
	}

}

#endif  // BUILDING_XMPCORE_LIB && !SOURCE_COMPILING_XMPCORE_LIB