LibreOffice LibreOffice 4.1 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Type.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19 #ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
20 #define _COM_SUN_STAR_UNO_TYPE_HXX_
21
22 #include <osl/mutex.hxx>
23 #include <com/sun/star/uno/Type.h>
24 #include "cppu/unotype.hxx"
25
26 namespace com
27 {
28 namespace sun
29 {
30 namespace star
31 {
32 namespace uno
33 {
34
35 //__________________________________________________________________________________________________
36 inline Type::Type() SAL_THROW(())
37 {
38 _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
39 ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) )->getTypeLibType();
40 ::typelib_typedescriptionreference_acquire( _pType );
41 }
42 //__________________________________________________________________________________________________
43 inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ) SAL_THROW(())
44 : _pType( 0 )
45 {
46 ::typelib_typedescriptionreference_new( &_pType, (typelib_TypeClass)eTypeClass, rTypeName.pData );
47 }
48 //__________________________________________________________________________________________________
49 inline Type::Type( TypeClass eTypeClass, const sal_Char * pTypeName ) SAL_THROW(())
50 : _pType( 0 )
51 {
52 ::typelib_typedescriptionreference_newByAsciiName( &_pType, (typelib_TypeClass)eTypeClass, pTypeName );
53 }
54 //__________________________________________________________________________________________________
55 inline Type::Type( typelib_TypeDescriptionReference * pType ) SAL_THROW(())
56 : _pType( pType )
57 {
58 ::typelib_typedescriptionreference_acquire( _pType );
59 }
60 //__________________________________________________________________________________________________
61 inline Type::Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire ) SAL_THROW(())
62 : _pType( pType )
63 {
64 }
65 //__________________________________________________________________________________________________
66 inline Type::Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire ) SAL_THROW(())
67 : _pType( pType )
68 {
69 }
70 //__________________________________________________________________________________________________
71 inline Type::Type( const Type & rType ) SAL_THROW(())
72 : _pType( rType._pType )
73 {
74 ::typelib_typedescriptionreference_acquire( _pType );
75 }
76 //__________________________________________________________________________________________________
77 inline ::rtl::OUString Type::getTypeName() const SAL_THROW(())
78 {
79 return ::rtl::OUString( _pType->pTypeName );
80 }
81 //__________________________________________________________________________________________________
82 inline Type & Type::operator = ( const Type & rType ) SAL_THROW(())
83 {
84 ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
85 return *this;
86 }
87
88 //__________________________________________________________________________________________________
89 template< class T >
90 typelib_TypeDescriptionReference * Array< T >::s_pType = 0;
91
92 }
93 }
94 }
95 }
96
97 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type * ) SAL_THROW(())
98 {
99 return ::cppu::UnoType< ::com::sun::star::uno::Type >::get();
100 }
101
102 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType() SAL_THROW(())
103 {
104 return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
105 }
106 inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType() SAL_THROW(())
107 {
108 return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
109 }
110
111 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType() SAL_THROW(())
112 {
113 return ::cppu::UnoType< bool >::get();
114 }
115 inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType() SAL_THROW(())
116 {
117 return ::cppu::UnoType< bool >::get();
118 }
119 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * ) SAL_THROW(())
120 {
121 return ::cppu::UnoType< bool >::get();
122 }
123
124 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
125 SAL_UNUSED_PARAMETER bool const * ) SAL_THROW(())
126 {
127 return ::cppu::UnoType< bool >::get();
128 }
129
130 inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType() SAL_THROW(())
131 {
132 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
133 }
134 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType() SAL_THROW(())
135 {
136 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
137 }
138
139 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int8 * ) SAL_THROW(())
140 {
141 return ::cppu::UnoType< ::sal_Int8 >::get();
142 }
143
144 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::rtl::OUString * ) SAL_THROW(())
145 {
146 return ::cppu::UnoType< ::rtl::OUString >::get();
147 }
148
149 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int16 * ) SAL_THROW(())
150 {
151 return ::cppu::UnoType< ::sal_Int16 >::get();
152 }
153
154 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt16 * ) SAL_THROW(())
155 {
156 return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
157 }
158
159 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int32 * ) SAL_THROW(())
160 {
161 return ::cppu::UnoType< ::sal_Int32 >::get();
162 }
163
164 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt32 * ) SAL_THROW(())
165 {
166 return ::cppu::UnoType< ::sal_uInt32 >::get();
167 }
168
169 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int64 * ) SAL_THROW(())
170 {
171 return ::cppu::UnoType< ::sal_Int64 >::get();
172 }
173
174 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt64 * ) SAL_THROW(())
175 {
176 return ::cppu::UnoType< ::sal_uInt64 >::get();
177 }
178
179 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * ) SAL_THROW(())
180 {
181 return ::cppu::UnoType< float >::get();
182 }
183
184 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * ) SAL_THROW(())
185 {
186 return ::cppu::UnoType< double >::get();
187 }
188
189 template< class T >
190 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType1( T * pT ) SAL_THROW(())
191 {
192 if (! ::com::sun::star::uno::Array< T >::s_pType)
193 {
194 const ::com::sun::star::uno::Type & rElementType =
195 ::cppu::getTypeFavourUnsigned( *pT );
196 sal_Int32 size = sizeof( **pT );
197 sal_Int32 dim1 = sizeof( *pT ) / size;
198 ::typelib_static_array_type_init(
199 & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
200 1, dim1 );
201 }
202 return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
203 & ::com::sun::star::uno::Array< T >::s_pType );
204 }
205
206 template< class T >
207 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType2( T * pT ) SAL_THROW(())
208 {
209 if (! ::com::sun::star::uno::Array< T >::s_pType)
210 {
211 const ::com::sun::star::uno::Type & rElementType =
212 ::cppu::getTypeFavourUnsigned( **pT );
213 sal_Int32 size = sizeof( ***pT );
214 sal_Int32 dim2 = sizeof( **pT ) / size;
215 sal_Int32 dim1 = sizeof( *pT ) / dim2 / size;
216 ::typelib_static_array_type_init(
217 & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
218 2, dim1, dim2 );
219 }
220 return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
221 & ::com::sun::star::uno::Array< T >::s_pType );
222 }
223
224 template< class T >
225 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType3( T * pT ) SAL_THROW(())
226 {
227 if (! ::com::sun::star::uno::Array< T >::s_pType)
228 {
229 const ::com::sun::star::uno::Type & rElementType =
230 ::cppu::getTypeFavourUnsigned( ***pT );
231 sal_Int32 size = sizeof( ****pT );
232 sal_Int32 dim3 = sizeof( ***pT ) / size;
233 sal_Int32 dim2 = sizeof( **pT ) / dim3 / size;
234 sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3)/ size;
235 ::typelib_static_array_type_init(
236 & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
237 3, dim1, dim2, dim3 );
238 }
239 return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
240 & ::com::sun::star::uno::Array< T >::s_pType );
241 }
242
243 template< class T >
244 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType4( T * pT ) SAL_THROW(())
245 {
246 if (! ::com::sun::star::uno::Array< T >::s_pType)
247 {
248 const ::com::sun::star::uno::Type & rElementType =
249 ::cppu::getTypeFavourUnsigned( ****pT );
250 sal_Int32 size = sizeof( *****pT );
251 sal_Int32 dim4 = sizeof( ****pT ) / size;
252 sal_Int32 dim3 = sizeof( ***pT ) / dim4 / size;
253 sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4) / size;
254 sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4) / size;
255 ::typelib_static_array_type_init(
256 & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
257 4, dim1, dim2, dim3, dim4 );
258 }
259 return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
260 & ::com::sun::star::uno::Array< T >::s_pType );
261 }
262
263 template< class T >
264 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType5( T * pT ) SAL_THROW(())
265 {
266 if (! ::com::sun::star::uno::Array< T >::s_pType)
267 {
268 const ::com::sun::star::uno::Type & rElementType =
269 ::cppu::getTypeFavourUnsigned( *****pT );
270 sal_Int32 size = sizeof( ******pT );
271 sal_Int32 dim5 = sizeof( *****pT ) / size;
272 sal_Int32 dim4 = sizeof( ****pT ) / dim5 / size;
273 sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5) / size;
274 sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5) / size;
275 sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5) / size;
276 ::typelib_static_array_type_init(
277 & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
278 5, dim1, dim2, dim3, dim4, dim5 );
279 }
280 return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
281 & ::com::sun::star::uno::Array< T >::s_pType );
282 }
283
284 template< class T >
285 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType6( T * pT ) SAL_THROW(())
286 {
287 if (! ::com::sun::star::uno::Array< T >::s_pType)
288 {
289 const ::com::sun::star::uno::Type & rElementType =
290 ::cppu::getTypeFavourUnsigned( ******pT );
291 sal_Int32 size = sizeof( *******pT );
292 sal_Int32 dim6 = sizeof( ******pT ) / size;
293 sal_Int32 dim5 = sizeof( *****pT ) / dim6 / size;
294 sal_Int32 dim4 = sizeof( ****pT ) / (dim5 * dim6) / size;
295 sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5 * dim6) / size;
296 sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5 * dim6) / size;
297 sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5 * dim6) / size;
298 ::typelib_static_array_type_init(
299 & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
300 6, dim1, dim2, dim3, dim4, dim5, dim6 );
301 }
302 return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
303 & ::com::sun::star::uno::Array< T >::s_pType );
304 }
305
306 template< typename T >
307 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType() SAL_THROW(())
308 {
309 return ::cppu::UnoType< T >::get();
310 }
311
312 template<>
313 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType< sal_Unicode >()
314 SAL_THROW(())
315 {
316 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
317 }
318
319 #endif
320
321 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
getCppuCharType
const ::com::sun::star::uno::Type & getCppuCharType()
Gets the meta type of IDL type char.
Definition: Type.hxx:134
_typelib_TypeDescriptionReference
Holds a weak reference to a type description.
Definition: typedescription.h:40
SAL_UNUSED_PARAMETER
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:540
com::sun::star::uno::Type::operator=
Type & operator=(const Type &rType)
Assignment operator: Acquires right side type and releases previously set type.
Definition: Type.hxx:82
sal_Char
char sal_Char
Definition: types.h:122
com::sun::star::uno::Type
C++ class representing an IDL meta type.
Definition: Type.h:55
com::sun::star::uno::UnoType_NoAcquire
UnoType_NoAcquire
Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
Definition: Type.h:40
typelib_TypeClass
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
getCppuBooleanType
const ::com::sun::star::uno::Type & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:111
SAL_THROW
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:356
com::sun::star::uno::Type::Type
Type()
Default Constructor: Type is set to void.
Definition: Type.hxx:36
getCppuArrayType5
const ::com::sun::star::uno::Type & getCppuArrayType5(T *pT)
Array template function to get meta type for five-dimensional arrays.
Definition: Type.hxx:264
typelib_static_type_getByTypeClass
CPPU_DLLPUBLIC typelib_TypeDescriptionReference ** typelib_static_type_getByTypeClass(typelib_TypeClass eTypeClass) SAL_THROW_EXTERN_C()
Gets static type reference of standard types by type class.
typelib_typedescriptionreference_newByAsciiName
CPPU_DLLPUBLIC void typelib_typedescriptionreference_newByAsciiName(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, const sal_Char *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
typelib_static_array_type_init
CPPU_DLLPUBLIC void typelib_static_array_type_init(typelib_TypeDescriptionReference **ppRef, typelib_TypeDescriptionReference *pElementType, sal_Int32 nDimensions,...) SAL_THROW_EXTERN_C()
Inits static array type reference.
cppu::getTypeFavourUnsigned
::com::sun::star::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:287
_typelib_TypeDescriptionReference::pTypeName
rtl_uString * pTypeName
fully qualified name of type
Definition: typedescription.h:55
getCppuArrayType1
const ::com::sun::star::uno::Type & getCppuArrayType1(T *pT)
Array template function to get meta type for one-dimensional arrays.
Definition: Type.hxx:190
getCppuArrayType3
const ::com::sun::star::uno::Type & getCppuArrayType3(T *pT)
Array template function to get meta type for three-dimensional arrays.
Definition: Type.hxx:225
Type.h
getCppuArrayType6
const ::com::sun::star::uno::Type & getCppuArrayType6(T *pT)
Array template function to get meta type for six-dimensional arrays.
Definition: Type.hxx:285
typelib_typedescriptionreference_assign
CPPU_DLLPUBLIC void typelib_typedescriptionreference_assign(typelib_TypeDescriptionReference **ppDest, typelib_TypeDescriptionReference *pSource) SAL_THROW_EXTERN_C()
Assigns a type.
com::sun::star::uno::Type::getTypeName
inline::rtl::OUString getTypeName() const
Gets the name of the set type.
Definition: Type.hxx:77
typelib_TypeClass_VOID
type class of void
Definition: typeclass.h:29
getVoidCppuType
const ::com::sun::star::uno::Type & getVoidCppuType()
Gets the meta type of IDL type void.
Definition: Type.hxx:106
getCppuType
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type *)
Definition: Type.hxx:97
getBooleanCppuType
const ::com::sun::star::uno::Type & getBooleanCppuType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:115
mutex.hxx
typelib_typedescriptionreference_new
CPPU_DLLPUBLIC void typelib_typedescriptionreference_new(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, rtl_uString *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
getCppuArrayType2
const ::com::sun::star::uno::Type & getCppuArrayType2(T *pT)
Array template function to get meta type for two-dimensional arrays.
Definition: Type.hxx:207
typelib_typedescriptionreference_acquire
CPPU_DLLPUBLIC void typelib_typedescriptionreference_acquire(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
Increments reference count of type description reference.
getCppuType< sal_Unicode >
const ::com::sun::star::uno::Type & getCppuType< sal_Unicode >()
Gets the meta type of IDL type char.
Definition: Type.hxx:313
sal_Bool
unsigned char sal_Bool
Definition: types.h:37
getCharCppuType
const ::com::sun::star::uno::Type & getCharCppuType()
Gets the meta type of IDL type char.
Definition: Type.hxx:130
getCppuArrayType4
const ::com::sun::star::uno::Type & getCppuArrayType4(T *pT)
Array template function to get meta type for four-dimensional arrays.
Definition: Type.hxx:244
getCppuVoidType
const ::com::sun::star::uno::Type & getCppuVoidType()
Gets the meta type of IDL type void.
Definition: Type.hxx:102
sal_Int8
signed char sal_Int8
Definition: types.h:42
com::sun::star::uno::Array
Helper class to specify a type pointer for idl arrays.
Definition: Type.h:195
com::sun::star::uno::Type::getTypeLibType
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:155
unotype.hxx
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:370