UDK 3.2.7 C/C++ API Reference
cppu/unotype.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 
00029 #ifndef INCLUDED_CPPU_UNOTYPE_HXX
00030 #define INCLUDED_CPPU_UNOTYPE_HXX
00031 
00032 #include "sal/config.h"
00033 #include "com/sun/star/uno/Type.h"
00034 #include "sal/types.h"
00035 #include "typelib/typeclass.h"
00036 #include "typelib/typedescription.h"
00037 
00038 namespace com { namespace sun { namespace star { namespace uno {
00039     class Any;
00040     class Exception;
00041     template< typename > class Reference;
00042     template< typename > class Sequence;
00043     class XInterface;
00044 } } } }
00045 namespace rtl { class OUString; }
00046 
00047 namespace cppu {
00048 
00049 template< typename > class UnoType;
00050 
00059 struct UnoVoidType;
00060 
00072 struct UnoUnsignedShortType;
00073 
00085 struct UnoCharType;
00086 
00099 template< typename > struct UnoSequenceType;
00100 
00101 namespace detail {
00102 
00103 inline ::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(
00104     ::typelib_TypeDescriptionReference * const * tdr)
00105 {
00106     return *reinterpret_cast< ::com::sun::star::uno::Type const * >(tdr);
00107 }
00108 
00109 inline ::com::sun::star::uno::Type const &
00110 getTypeFromTypeClass(::typelib_TypeClass tc) {
00111     return getTypeFromTypeDescriptionReference(
00112         ::typelib_static_type_getByTypeClass(tc));
00113 }
00114 
00115 }
00116 
00117 }
00118 
00119 // For _MSC_VER 1310, define cppu_detail_getUnoType in the global namespace, to
00120 // avoid spurious compiler errors in code that calls cppu_detail_getUnoType:
00121 #if !defined _MSC_VER || _MSC_VER > 1310
00122 namespace cppu { namespace detail {
00123 #endif
00124 
00125 inline ::com::sun::star::uno::Type const &
00126 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
00127     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_VOID);
00128 }
00129 
00130 inline ::com::sun::star::uno::Type const &
00131 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER bool const *) {
00132     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
00133 }
00134 
00135 inline ::com::sun::star::uno::Type const &
00136 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Bool const *) {
00137     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
00138 }
00139 
00140 inline ::com::sun::star::uno::Type const &
00141 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int8 const *) {
00142     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BYTE);
00143 }
00144 
00145 inline ::com::sun::star::uno::Type const &
00146 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
00147     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_SHORT);
00148 }
00149 
00150 inline ::com::sun::star::uno::Type const &
00151 cppu_detail_getUnoType(
00152     SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
00153 {
00154     return ::cppu::detail::getTypeFromTypeClass(
00155         ::typelib_TypeClass_UNSIGNED_SHORT);
00156 }
00157 
00158 inline ::com::sun::star::uno::Type const &
00159 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
00160     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_LONG);
00161 }
00162 
00163 inline ::com::sun::star::uno::Type const &
00164 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
00165     return ::cppu::detail::getTypeFromTypeClass(
00166         ::typelib_TypeClass_UNSIGNED_LONG);
00167 }
00168 
00169 inline ::com::sun::star::uno::Type const &
00170 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
00171     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_HYPER);
00172 }
00173 
00174 inline ::com::sun::star::uno::Type const &
00175 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
00176     return ::cppu::detail::getTypeFromTypeClass(
00177         ::typelib_TypeClass_UNSIGNED_HYPER);
00178 }
00179 
00180 inline ::com::sun::star::uno::Type const &
00181 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER float const *) {
00182     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_FLOAT);
00183 }
00184 
00185 inline ::com::sun::star::uno::Type const &
00186 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER double const *) {
00187     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_DOUBLE);
00188 }
00189 
00190 inline ::com::sun::star::uno::Type const &
00191 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
00192     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_CHAR);
00193 }
00194 
00195 inline ::com::sun::star::uno::Type const &
00196 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
00197     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_STRING);
00198 }
00199 
00200 inline ::com::sun::star::uno::Type const &
00201 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Type const *)
00202 {
00203     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_TYPE);
00204 }
00205 
00206 inline ::com::sun::star::uno::Type const &
00207 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Any const *)
00208 {
00209     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_ANY);
00210 }
00211 
00212 template< typename T > inline ::com::sun::star::uno::Type const &
00213 cppu_detail_getUnoType(
00214     SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
00215 {
00216     //TODO: depending on memory model, the following might not work reliably
00217     static typelib_TypeDescriptionReference * p = 0;
00218     if (p == 0) {
00219         ::typelib_static_sequence_type_init(
00220             &p, ::cppu::UnoType< T >::get().getTypeLibType());
00221     }
00222     return ::cppu::detail::getTypeFromTypeDescriptionReference(&p);
00223 }
00224 
00225 template< typename T > inline ::com::sun::star::uno::Type const &
00226 cppu_detail_getUnoType(
00227     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
00228 {
00229     return cppu_detail_getUnoType(
00230         static_cast< ::cppu::UnoSequenceType< T > * >(0));
00231 }
00232 
00233 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
00234     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Exception const *)
00235 {
00236     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_EXCEPTION);
00237 }
00238 
00239 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
00240     SAL_UNUSED_PARAMETER ::com::sun::star::uno::XInterface const *)
00241 {
00242     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_INTERFACE);
00243 }
00244 
00245 template< typename T > inline ::com::sun::star::uno::Type const &
00246 cppu_detail_getUnoType(
00247     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Reference< T > const *)
00248 {
00249     return ::cppu::UnoType< T >::get();
00250 }
00251 
00252 #if !defined _MSC_VER || _MSC_VER > 1310
00253 } }
00254 #endif
00255 
00256 namespace cppu {
00257 
00278 template< typename T > class UnoType {
00279 public:
00280     static inline ::com::sun::star::uno::Type const & get() {
00281         using namespace ::cppu::detail;
00282         return cppu_detail_getUnoType(static_cast< T * >(0));
00283     }
00284 
00285 private:
00286     UnoType(UnoType &); // not defined
00287     ~UnoType(); // not defined
00288     void operator =(UnoType &); // not defined
00289 };
00290 
00301 template< typename T > inline ::com::sun::star::uno::Type const &
00302 getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *) {
00303     return ::cppu::UnoType< T >::get();
00304 }
00305 
00316 inline ::com::sun::star::uno::Type const &
00317 getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
00318     return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
00319 }
00320 
00331 template< typename T > inline ::com::sun::star::uno::Type const &
00332 getTypeFavourUnsigned(::com::sun::star::uno::Sequence< T > const *);
00333     // defined in com/sun/star/uno/Sequence.hxx
00334 
00336 
00348 template< typename T > inline ::com::sun::star::uno::Type const &
00349 getTypeFavourChar(SAL_UNUSED_PARAMETER T const *) {
00350     return ::cppu::UnoType< T >::get();
00351 }
00352 
00364 inline ::com::sun::star::uno::Type const &
00365 getTypeFavourChar(SAL_UNUSED_PARAMETER ::sal_Unicode const *) {
00366     return ::cppu::UnoType< ::cppu::UnoCharType >::get();
00367 }
00368 
00380 template< typename T > inline ::com::sun::star::uno::Type const &
00381 getTypeFavourChar(::com::sun::star::uno::Sequence< T > const *);
00382     // defined in com/sun/star/uno/Sequence.hxx
00383 
00385 
00386 }
00387 
00388 #endif
00389 
00390 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines