xref: /trunk/main/cppu/inc/uno/data.h (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _UNO_DATA_H_
28 #define _UNO_DATA_H_
29 
30 #include <sal/types.h>
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
37 struct _typelib_TypeDescriptionReference;
38 struct _typelib_TypeDescription;
39 struct _typelib_InterfaceTypeDescription;
40 struct _uno_Mapping;
41 
42 /** Generic function pointer declaration to query for an interface.
43 
44 	@param pInterface interface
45 	@param pTypedemanded interface type
46 	@return interface pointer
47 */
48 typedef void * (SAL_CALL * uno_QueryInterfaceFunc)(
49 	void * pInterface, struct _typelib_TypeDescriptionReference * pType );
50 /** Generic function pointer declaration to acquire an interface.
51 
52 	@param pInterface interface to be acquired
53 */
54 typedef void (SAL_CALL * uno_AcquireFunc)(
55 	void * pInterface );
56 /** Generic function pointer declaration to release an interface.
57 
58 	@param pInterface interface to be release
59 */
60 typedef void (SAL_CALL * uno_ReleaseFunc)(
61 	void * pInterface );
62 
63 /** Tests if two values are equal. May compare different types (e.g., short to long).
64 
65 	@param pVal1			pointer to a value
66 	@param pVal1TypeDescr	type description of pVal1
67 	@param pVal2			pointer to another value
68 	@param pVal2TypeDescr	type description of pVal2
69 	@param queryInterface	function called each time two interfaces are tested whether they belong
70 							to the same object; defaults (0) to uno
71 	@param release			function to release queried interfaces; defaults (0) to uno
72 	@return true if values are equal
73 */
74 sal_Bool SAL_CALL uno_equalData(
75 	void * pVal1, struct _typelib_TypeDescription * pVal1TypeDescr,
76 	void * pVal2, struct _typelib_TypeDescription * pVal2TypeDescr,
77 	uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
78 	SAL_THROW_EXTERN_C();
79 /** Tests if two values are equal. May compare different types (e.g., short to long).
80 
81 	@param pVal1			pointer to a value
82 	@param pVal1Type		type of pVal1
83 	@param pVal2			pointer to another value
84 	@param pVal2Type		type of pVal2
85 	@param queryInterface	function called each time two interfaces are tested whether they belong
86 							to the same object; defaults (0) to uno
87 	@param release			function to release queried interfaces; defaults (0) to uno
88 	@return true if values are equal
89 */
90 sal_Bool SAL_CALL uno_type_equalData(
91 	void * pVal1, struct _typelib_TypeDescriptionReference * pVal1Type,
92 	void * pVal2, struct _typelib_TypeDescriptionReference * pVal2Type,
93 	uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
94 	SAL_THROW_EXTERN_C();
95 
96 /** Copy construct memory with given value. The size of the destination value must be larger
97     or equal to the size of the source value.
98 
99 	@param pDest			pointer to destination value memory
100 	@param pSource			pointer to source value
101 	@param pTypeDescr		type description of source
102 	@param acquire			function called each time an interface needs to be acquired;
103                             defaults (0) to uno
104 */
105 void SAL_CALL uno_copyData(
106 	void * pDest, void * pSource,
107 	struct _typelib_TypeDescription * pTypeDescr, uno_AcquireFunc acquire )
108 	SAL_THROW_EXTERN_C();
109 /** Copy construct memory with given value. The size of the destination value must be larger
110     or equal to the size of the source value.
111 
112 	@param pDest			pointer to destination value memory
113 	@param pSource			pointer to source value
114 	@param pType			type of source
115 	@param acquire			function called each time an interface needs to be acquired;
116                             defaults (0) to uno
117 */
118 void SAL_CALL uno_type_copyData(
119 	void * pDest, void * pSource,
120 	struct _typelib_TypeDescriptionReference * pType, uno_AcquireFunc acquire )
121 	SAL_THROW_EXTERN_C();
122 
123 /** Copy construct memory with given value. The size of the destination value must be larger
124     or equal to the size of the source value. Interfaces are converted/ mapped by mapping parameter.
125 
126 	@param pDest			pointer to destination value memory
127 	@param pSource			pointer to source value
128 	@param pTypeDescr		type description of source
129 	@param mapping			mapping to convert/ map interfaces
130 */
131 void SAL_CALL uno_copyAndConvertData(
132 	void * pDest, void * pSource,
133 	struct _typelib_TypeDescription * pTypeDescr, struct _uno_Mapping * mapping )
134 	SAL_THROW_EXTERN_C();
135 /** Copy construct memory with given value. The size of the destination value must be larger
136     or equal to the size of the source value. Interfaces are converted/ mapped by mapping parameter.
137 
138 	@param pDest			pointer to destination value memory
139 	@param pSource			pointer to source value
140 	@param pType			type of source
141 	@param mapping			mapping to convert/ map interfaces
142 */
143 void SAL_CALL uno_type_copyAndConvertData(
144 	void * pDest, void * pSource,
145 	struct _typelib_TypeDescriptionReference * pType, struct _uno_Mapping * mapping )
146 	SAL_THROW_EXTERN_C();
147 
148 /** Destructs a given value; does NOT free its memory!
149 
150 	@param pValue			value to be destructed
151 	@param pTypeDescr		type description of value
152 	@param release			function called each time an interface pointer needs to be released;
153                             defaults (0) to uno
154 */
155 void SAL_CALL uno_destructData(
156 	void * pValue, struct _typelib_TypeDescription * pTypeDescr, uno_ReleaseFunc release )
157 	SAL_THROW_EXTERN_C();
158 /** Destructs a given value; does NOT free its memory!
159 
160 	@param pValue			value to be destructed
161 	@param pType			type of value
162 	@param release			function called each time an interface pointer needs to be released;
163                             defaults (0) to uno
164 */
165 void SAL_CALL uno_type_destructData(
166 	void * pValue, struct _typelib_TypeDescriptionReference * pType, uno_ReleaseFunc release )
167 	SAL_THROW_EXTERN_C();
168 
169 /** Default constructs a value. All simple types are set to 0, enums are set to their default value.
170 
171 	@param pMem				pointer to memory of value to be constructed
172 	@param pTypeDescr		type description of value to be constructed
173 */
174 void SAL_CALL uno_constructData(
175 	void * pMem, struct _typelib_TypeDescription * pTypeDescr )
176 	SAL_THROW_EXTERN_C();
177 /** Default constructs a value. All simple types are set to 0, enums are set to their default value.
178 
179 	@param pMem				pointer to memory of value to be constructed
180 	@param pType			type of value to be constructed
181 */
182 void SAL_CALL uno_type_constructData(
183 	void * pMem, struct _typelib_TypeDescriptionReference * pType )
184 	SAL_THROW_EXTERN_C();
185 
186 /** Assigns a destination value with a source value.
187     Widening conversion WITHOUT data loss is allowed (e.g., assigning a long with a short).
188     Querying for demanded interface type is allowed.
189     Assignment from any value to a value of type Any and vice versa is allowed.
190 
191 	@param pDest			pointer to destination value
192 	@param pDestTypeDescr	type description of destination value
193 	@param pSource			pointer to source value; if 0, then destination value will be assigned
194                             to default value
195 	@param pSourceTypeDescr	type destination of source value
196 	@param queryInterface	function called each time an interface needs to be queried;
197                             defaults (0) to uno
198 	@param acquire			function called each time an interface needs to be acquired;
199                             defaults (0) to uno
200 	@param release			function called each time an interface needs to be released;
201                             defaults (0) to uno
202 	@return true if destination has been successfully assigned
203 */
204 sal_Bool SAL_CALL uno_assignData(
205 	void * pDest, struct _typelib_TypeDescription * pDestTypeDescr,
206 	void * pSource, struct _typelib_TypeDescription * pSourceTypeDescr,
207 	uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
208 	SAL_THROW_EXTERN_C();
209 /** Assigns a destination value with a source value.
210     Widening conversion WITHOUT data loss is allowed (e.g., assigning a long with a short).
211     Querying for demanded interface type is allowed.
212     Assignment from any value to a value of type Any and vice versa is allowed.
213 
214 	@param pDest			pointer to destination value
215 	@param pDestType		type of destination value
216 	@param pSource			pointer to source value; if 0, then destination value will be assigned
217                             to default value
218 	@param pSourceType		type of source value
219 	@param queryInterface	function called each time an interface needs to be queried;
220                             defaults (0) to uno
221 	@param acquire			function called each time an interface needs to be acquired;
222                             defaults (0) to uno
223 	@param release			function called each time an interface needs to be released;
224                             defaults (0) to uno
225 	@return true if destination has been successfully assigned
226 */
227 sal_Bool SAL_CALL uno_type_assignData(
228 	void * pDest, struct _typelib_TypeDescriptionReference * pDestType,
229 	void * pSource, struct _typelib_TypeDescriptionReference * pSourceType,
230 	uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
231 	SAL_THROW_EXTERN_C();
232 
233 /** Tests whether a value of given type is assignable from given value.
234     Widening conversion WITHOUT data loss is allowed (e.g., assigning a long with a short).
235     Querying for demanded interface type is allowed.
236     Assignment from any value to a value of type Any and vice versa is allowed.
237 
238 	@param pAssignable      type
239 	@param pFrom			pointer to value
240 	@param pFromType		type of value
241 	@param queryInterface	function called each time an interface needs to be queried;
242                             defaults (0) to uno
243 	@param release			function called each time an interface needs to be released;
244                             defaults (0) to uno
245 	@return true if value is destination has been successfully assigned
246 */
247 sal_Bool SAL_CALL uno_type_isAssignableFromData(
248     struct _typelib_TypeDescriptionReference * pAssignable,
249 	void * pFrom, struct _typelib_TypeDescriptionReference * pFromType,
250 	uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
251 	SAL_THROW_EXTERN_C();
252 
253 #ifdef __cplusplus
254 }
255 #endif
256 
257 #endif
258