My Project
UDK 3.2.7 C/C++ API Reference
 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  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
29 #define _COM_SUN_STAR_UNO_TYPE_HXX_
30 
31 #include <osl/mutex.hxx>
32 #include <com/sun/star/uno/Type.h>
33 #include "cppu/unotype.hxx"
34 
35 namespace com
36 {
37 namespace sun
38 {
39 namespace star
40 {
41 namespace uno
42 {
43 
44 //__________________________________________________________________________________________________
45 inline Type::Type() SAL_THROW(())
46 {
47  _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
50 }
51 //__________________________________________________________________________________________________
52 inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ) SAL_THROW(())
53  : _pType( 0 )
54 {
55  ::typelib_typedescriptionreference_new( &_pType, (typelib_TypeClass)eTypeClass, rTypeName.pData );
56 }
57 //__________________________________________________________________________________________________
58 inline Type::Type( TypeClass eTypeClass, const sal_Char * pTypeName ) SAL_THROW(())
59  : _pType( 0 )
60 {
62 }
63 //__________________________________________________________________________________________________
65  : _pType( pType )
66 {
68 }
69 //__________________________________________________________________________________________________
71  : _pType( pType )
72 {
73 }
74 //__________________________________________________________________________________________________
76  : _pType( pType )
77 {
78 }
79 //__________________________________________________________________________________________________
80 inline Type::Type( const Type & rType ) SAL_THROW(())
81  : _pType( rType._pType )
82 {
84 }
85 //__________________________________________________________________________________________________
86 inline ::rtl::OUString Type::getTypeName() const SAL_THROW(())
87 {
88  return ::rtl::OUString( _pType->pTypeName );
89 }
90 //__________________________________________________________________________________________________
91 inline Type & Type::operator = ( const Type & rType ) SAL_THROW(())
92 {
93  ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
94  return *this;
95 }
96 
97 //__________________________________________________________________________________________________
98 template< class T >
100 
101 }
102 }
103 }
104 }
105 
106 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type * ) SAL_THROW(())
107 {
108  return ::cppu::UnoType< ::com::sun::star::uno::Type >::get();
109 }
110 
111 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType() SAL_THROW(())
112 {
113  return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
114 }
115 inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType() SAL_THROW(())
116 {
117  return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
118 }
119 
120 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType() SAL_THROW(())
121 {
122  return ::cppu::UnoType< bool >::get();
123 }
124 inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType() SAL_THROW(())
125 {
126  return ::cppu::UnoType< bool >::get();
127 }
128 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * ) SAL_THROW(())
129 {
130  return ::cppu::UnoType< bool >::get();
131 }
132 
133 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
134  SAL_UNUSED_PARAMETER bool const * ) SAL_THROW(())
135 {
136  return ::cppu::UnoType< bool >::get();
137 }
138 
139 inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType() SAL_THROW(())
140 {
141  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
142 }
143 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType() SAL_THROW(())
144 {
145  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
146 }
147 
148 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int8 * ) SAL_THROW(())
149 {
150  return ::cppu::UnoType< ::sal_Int8 >::get();
151 }
152 
153 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::rtl::OUString * ) SAL_THROW(())
154 {
155  return ::cppu::UnoType< ::rtl::OUString >::get();
156 }
157 
158 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int16 * ) SAL_THROW(())
159 {
160  return ::cppu::UnoType< ::sal_Int16 >::get();
161 }
162 
163 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt16 * ) SAL_THROW(())
164 {
165  return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
166 }
167 
168 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int32 * ) SAL_THROW(())
169 {
170  return ::cppu::UnoType< ::sal_Int32 >::get();
171 }
172 
173 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt32 * ) SAL_THROW(())
174 {
175  return ::cppu::UnoType< ::sal_uInt32 >::get();
176 }
177 
178 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int64 * ) SAL_THROW(())
179 {
180  return ::cppu::UnoType< ::sal_Int64 >::get();
181 }
182 
183 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt64 * ) SAL_THROW(())
184 {
185  return ::cppu::UnoType< ::sal_uInt64 >::get();
186 }
187 
188 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * ) SAL_THROW(())
189 {
190  return ::cppu::UnoType< float >::get();
191 }
192 
193 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * ) SAL_THROW(())
194 {
195  return ::cppu::UnoType< double >::get();
196 }
197 
198 template< class T >
199 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType1( T * pT ) SAL_THROW(())
200 {
202  {
203  const ::com::sun::star::uno::Type & rElementType =
205  sal_Int32 size = sizeof( **pT );
206  sal_Int32 dim1 = sizeof( *pT ) / size;
208  & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
209  1, dim1 );
210  }
211  return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
213 }
214 
215 template< class T >
216 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType2( T * pT ) SAL_THROW(())
217 {
219  {
220  const ::com::sun::star::uno::Type & rElementType =
222  sal_Int32 size = sizeof( ***pT );
223  sal_Int32 dim2 = sizeof( **pT ) / size;
224  sal_Int32 dim1 = sizeof( *pT ) / dim2 / size;
226  & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
227  2, dim1, dim2 );
228  }
229  return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
231 }
232 
233 template< class T >
234 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType3( T * pT ) SAL_THROW(())
235 {
237  {
238  const ::com::sun::star::uno::Type & rElementType =
240  sal_Int32 size = sizeof( ****pT );
241  sal_Int32 dim3 = sizeof( ***pT ) / size;
242  sal_Int32 dim2 = sizeof( **pT ) / dim3 / size;
243  sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3)/ size;
245  & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
246  3, dim1, dim2, dim3 );
247  }
248  return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
250 }
251 
252 template< class T >
253 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType4( T * pT ) SAL_THROW(())
254 {
256  {
257  const ::com::sun::star::uno::Type & rElementType =
259  sal_Int32 size = sizeof( *****pT );
260  sal_Int32 dim4 = sizeof( ****pT ) / size;
261  sal_Int32 dim3 = sizeof( ***pT ) / dim4 / size;
262  sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4) / size;
263  sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4) / size;
265  & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
266  4, dim1, dim2, dim3, dim4 );
267  }
268  return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
270 }
271 
272 template< class T >
273 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType5( T * pT ) SAL_THROW(())
274 {
276  {
277  const ::com::sun::star::uno::Type & rElementType =
279  sal_Int32 size = sizeof( ******pT );
280  sal_Int32 dim5 = sizeof( *****pT ) / size;
281  sal_Int32 dim4 = sizeof( ****pT ) / dim5 / size;
282  sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5) / size;
283  sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5) / size;
284  sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5) / size;
286  & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
287  5, dim1, dim2, dim3, dim4, dim5 );
288  }
289  return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
291 }
292 
293 template< class T >
294 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType6( T * pT ) SAL_THROW(())
295 {
297  {
298  const ::com::sun::star::uno::Type & rElementType =
299  ::cppu::getTypeFavourUnsigned( ******pT );
300  sal_Int32 size = sizeof( *******pT );
301  sal_Int32 dim6 = sizeof( ******pT ) / size;
302  sal_Int32 dim5 = sizeof( *****pT ) / dim6 / size;
303  sal_Int32 dim4 = sizeof( ****pT ) / (dim5 * dim6) / size;
304  sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5 * dim6) / size;
305  sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5 * dim6) / size;
306  sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5 * dim6) / size;
308  & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
309  6, dim1, dim2, dim3, dim4, dim5, dim6 );
310  }
311  return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
313 }
314 
315 template< typename T >
316 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType() SAL_THROW(())
317 {
318  return ::cppu::UnoType< T >::get();
319 }
320 
321 template<>
322 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType< sal_Unicode >()
323  SAL_THROW(())
324 {
325  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
326 }
327 
328 #endif
329 
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */