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