UDK 3.2.7 C/C++ API Reference
com/sun/star/uno/Type.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*************************************************************************
00003  *
00004  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
00005  *
00006  * Copyright 2000, 2010 Oracle and/or its affiliates.
00007  *
00008  * OpenOffice.org - a multi-platform office productivity suite
00009  *
00010  * This file is part of OpenOffice.org.
00011  *
00012  * OpenOffice.org is free software: you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 3
00014  * only, as published by the Free Software Foundation.
00015  *
00016  * OpenOffice.org is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License version 3 for more details
00020  * (a copy is included in the LICENSE file that accompanied this code).
00021  *
00022  * You should have received a copy of the GNU Lesser General Public License
00023  * version 3 along with OpenOffice.org.  If not, see
00024  * <http://www.openoffice.org/license.html>
00025  * for a copy of the LGPLv3 License.
00026  *
00027  ************************************************************************/
00028 #ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
00029 #define _COM_SUN_STAR_UNO_TYPE_HXX_
00030 
00031 #include <osl/mutex.hxx>
00032 #include <com/sun/star/uno/Type.h>
00033 #include "cppu/unotype.hxx"
00034 
00035 namespace com
00036 {
00037 namespace sun
00038 {
00039 namespace star
00040 {
00041 namespace uno
00042 {
00043 
00044 //__________________________________________________________________________________________________
00045 inline Type::Type() SAL_THROW(())
00046 {
00047     _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
00048         ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) )->getTypeLibType();
00049     ::typelib_typedescriptionreference_acquire( _pType );
00050 }
00051 //__________________________________________________________________________________________________
00052 inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ) SAL_THROW(())
00053     : _pType( 0 )
00054 {
00055     ::typelib_typedescriptionreference_new( &_pType, (typelib_TypeClass)eTypeClass, rTypeName.pData );
00056 }
00057 //__________________________________________________________________________________________________
00058 inline Type::Type( TypeClass eTypeClass, const sal_Char * pTypeName ) SAL_THROW(())
00059     : _pType( 0 )
00060 {
00061     ::typelib_typedescriptionreference_newByAsciiName( &_pType, (typelib_TypeClass)eTypeClass, pTypeName );
00062 }
00063 //__________________________________________________________________________________________________
00064 inline Type::Type( typelib_TypeDescriptionReference * pType ) SAL_THROW(())
00065     : _pType( pType )
00066 {
00067     ::typelib_typedescriptionreference_acquire( _pType );
00068 }
00069 //__________________________________________________________________________________________________
00070 inline Type::Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire ) SAL_THROW(())
00071     : _pType( pType )
00072 {
00073 }
00074 //__________________________________________________________________________________________________
00075 inline Type::Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire ) SAL_THROW(())
00076     : _pType( pType )
00077 {
00078 }
00079 //__________________________________________________________________________________________________
00080 inline Type::Type( const Type & rType ) SAL_THROW(())
00081     : _pType( rType._pType )
00082 {
00083     ::typelib_typedescriptionreference_acquire( _pType );
00084 }
00085 //__________________________________________________________________________________________________
00086 inline ::rtl::OUString Type::getTypeName() const SAL_THROW(())
00087 {
00088     return ::rtl::OUString( _pType->pTypeName );
00089 }
00090 //__________________________________________________________________________________________________
00091 inline Type & Type::operator = ( const Type & rType ) SAL_THROW(())
00092 {
00093     ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
00094     return *this;
00095 }
00096 
00097 //__________________________________________________________________________________________________
00098 template< class T >
00099 typelib_TypeDescriptionReference * Array< T >::s_pType = 0;
00100 
00101 }
00102 }
00103 }
00104 }
00105 
00106 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type * ) SAL_THROW(())
00107 {
00108     return ::cppu::UnoType< ::com::sun::star::uno::Type >::get();
00109 }
00110 
00111 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType() SAL_THROW(())
00112 {
00113     return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
00114 }
00115 inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType() SAL_THROW(())
00116 {
00117     return ::cppu::UnoType< ::cppu::UnoVoidType >::get();
00118 }
00119 
00120 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType() SAL_THROW(())
00121 {
00122     return ::cppu::UnoType< bool >::get();
00123 }
00124 inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType() SAL_THROW(())
00125 {
00126     return ::cppu::UnoType< bool >::get();
00127 }
00128 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * ) SAL_THROW(())
00129 {
00130     return ::cppu::UnoType< bool >::get();
00131 }
00132 
00133 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
00134     SAL_UNUSED_PARAMETER bool const * ) SAL_THROW(())
00135 {
00136     return ::cppu::UnoType< bool >::get();
00137 }
00138 
00139 inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType() SAL_THROW(())
00140 {
00141     return ::cppu::UnoType< ::cppu::UnoCharType >::get();
00142 }
00143 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType() SAL_THROW(())
00144 {
00145     return ::cppu::UnoType< ::cppu::UnoCharType >::get();
00146 }
00147 
00148 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int8 * ) SAL_THROW(())
00149 {
00150     return ::cppu::UnoType< ::sal_Int8 >::get();
00151 }
00152 
00153 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::rtl::OUString * ) SAL_THROW(())
00154 {
00155     return ::cppu::UnoType< ::rtl::OUString >::get();
00156 }
00157 
00158 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int16 * ) SAL_THROW(())
00159 {
00160     return ::cppu::UnoType< ::sal_Int16 >::get();
00161 }
00162 
00163 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt16 * ) SAL_THROW(())
00164 {
00165     return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
00166 }
00167 
00168 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int32 * ) SAL_THROW(())
00169 {
00170     return ::cppu::UnoType< ::sal_Int32 >::get();
00171 }
00172 
00173 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt32 * ) SAL_THROW(())
00174 {
00175     return ::cppu::UnoType< ::sal_uInt32 >::get();
00176 }
00177 
00178 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int64 * ) SAL_THROW(())
00179 {
00180     return ::cppu::UnoType< ::sal_Int64 >::get();
00181 }
00182 
00183 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt64 * ) SAL_THROW(())
00184 {
00185     return ::cppu::UnoType< ::sal_uInt64 >::get();
00186 }
00187 
00188 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * ) SAL_THROW(())
00189 {
00190     return ::cppu::UnoType< float >::get();
00191 }
00192 
00193 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * ) SAL_THROW(())
00194 {
00195     return ::cppu::UnoType< double >::get();
00196 }
00197 
00198 template< class T >
00199 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType1( T * pT ) SAL_THROW(())
00200 {
00201     if (! ::com::sun::star::uno::Array< T >::s_pType)
00202     {
00203         const ::com::sun::star::uno::Type & rElementType =
00204             ::cppu::getTypeFavourUnsigned( *pT );
00205         sal_Int32 size = sizeof( **pT );
00206         sal_Int32 dim1 = sizeof( *pT ) / size;
00207         ::typelib_static_array_type_init(
00208             & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
00209             1, dim1 );
00210     }
00211     return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
00212         & ::com::sun::star::uno::Array< T >::s_pType );
00213 }
00214 
00215 template< class T >
00216 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType2( T * pT ) SAL_THROW(())
00217 {
00218     if (! ::com::sun::star::uno::Array< T >::s_pType)
00219     {
00220         const ::com::sun::star::uno::Type & rElementType =
00221             ::cppu::getTypeFavourUnsigned( **pT );
00222         sal_Int32 size = sizeof( ***pT );
00223         sal_Int32 dim2 = sizeof( **pT ) / size;
00224         sal_Int32 dim1 = sizeof( *pT ) / dim2 / size;
00225         ::typelib_static_array_type_init(
00226             & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
00227             2, dim1, dim2 );
00228     }
00229     return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
00230         & ::com::sun::star::uno::Array< T >::s_pType );
00231 }
00232 
00233 template< class T >
00234 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType3( T * pT ) SAL_THROW(())
00235 {
00236     if (! ::com::sun::star::uno::Array< T >::s_pType)
00237     {
00238         const ::com::sun::star::uno::Type & rElementType =
00239             ::cppu::getTypeFavourUnsigned( ***pT );
00240         sal_Int32 size = sizeof( ****pT );
00241         sal_Int32 dim3 = sizeof( ***pT ) / size;
00242         sal_Int32 dim2 = sizeof( **pT ) / dim3 / size;
00243         sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3)/ size;
00244         ::typelib_static_array_type_init(
00245             & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
00246             3, dim1, dim2, dim3 );
00247     }
00248     return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
00249         & ::com::sun::star::uno::Array< T >::s_pType );
00250 }
00251 
00252 template< class T >
00253 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType4( T * pT ) SAL_THROW(())
00254 {
00255     if (! ::com::sun::star::uno::Array< T >::s_pType)
00256     {
00257         const ::com::sun::star::uno::Type & rElementType =
00258             ::cppu::getTypeFavourUnsigned( ****pT );
00259         sal_Int32 size = sizeof( *****pT );
00260         sal_Int32 dim4 = sizeof( ****pT ) / size;
00261         sal_Int32 dim3 = sizeof( ***pT ) / dim4 / size;
00262         sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4) / size;
00263         sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4) / size;
00264         ::typelib_static_array_type_init(
00265             & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
00266             4, dim1, dim2, dim3, dim4 );
00267     }
00268     return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
00269         & ::com::sun::star::uno::Array< T >::s_pType );
00270 }
00271 
00272 template< class T >
00273 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType5( T * pT ) SAL_THROW(())
00274 {
00275     if (! ::com::sun::star::uno::Array< T >::s_pType)
00276     {
00277         const ::com::sun::star::uno::Type & rElementType =
00278             ::cppu::getTypeFavourUnsigned( *****pT );
00279         sal_Int32 size = sizeof( ******pT );
00280         sal_Int32 dim5 = sizeof( *****pT ) / size;
00281         sal_Int32 dim4 = sizeof( ****pT ) / dim5 / size;
00282         sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5) / size;
00283         sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5) / size;
00284         sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5) / size;
00285         ::typelib_static_array_type_init(
00286             & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
00287             5, dim1, dim2, dim3, dim4, dim5 );
00288     }
00289     return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
00290         & ::com::sun::star::uno::Array< T >::s_pType );
00291 }
00292 
00293 template< class T >
00294 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuArrayType6( T * pT ) SAL_THROW(())
00295 {
00296     if (! ::com::sun::star::uno::Array< T >::s_pType)
00297     {
00298         const ::com::sun::star::uno::Type & rElementType =
00299             ::cppu::getTypeFavourUnsigned( ******pT );
00300         sal_Int32 size = sizeof( *******pT );
00301         sal_Int32 dim6 = sizeof( ******pT ) / size;
00302         sal_Int32 dim5 = sizeof( *****pT ) / dim6 / size;
00303         sal_Int32 dim4 = sizeof( ****pT ) / (dim5 * dim6) / size;
00304         sal_Int32 dim3 = sizeof( ***pT ) / (dim4 * dim5 * dim6) / size;
00305         sal_Int32 dim2 = sizeof( **pT ) / (dim3 * dim4 * dim5 * dim6) / size;
00306         sal_Int32 dim1 = sizeof( *pT ) / (dim2 * dim3 * dim4 * dim5 * dim6) / size;
00307         ::typelib_static_array_type_init(
00308             & ::com::sun::star::uno::Array< T >::s_pType, rElementType.getTypeLibType(),
00309             6, dim1, dim2, dim3, dim4, dim5, dim6 );
00310     }
00311     return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
00312         & ::com::sun::star::uno::Array< T >::s_pType );
00313 }
00314 
00315 template< typename T >
00316 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType() SAL_THROW(())
00317 {
00318     return ::cppu::UnoType< T >::get();
00319 }
00320 
00321 template<>
00322 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType< sal_Unicode >()
00323     SAL_THROW(())
00324 {
00325     return ::cppu::UnoType< ::cppu::UnoCharType >::get();
00326 }
00327 
00328 #endif
00329 
00330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines