UDK 3.2.7 C/C++ API Reference
com/sun/star/uno/Any.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_ANY_HXX_
00029 #define _COM_SUN_STAR_UNO_ANY_HXX_
00030 
00031 #include <com/sun/star/uno/Any.h>
00032 #include <uno/data.h>
00033 #include <com/sun/star/uno/Type.hxx>
00034 #include <com/sun/star/uno/XInterface.hpp>
00035 #include <com/sun/star/uno/genfunc.hxx>
00036 #include "cppu/unotype.hxx"
00037 
00038 namespace com
00039 {
00040 namespace sun
00041 {
00042 namespace star
00043 {
00044 namespace uno
00045 {
00046 
00047 //__________________________________________________________________________________________________
00048 inline Any::Any() SAL_THROW(())
00049 {
00050     ::uno_any_construct( this, 0, 0, (uno_AcquireFunc)cpp_acquire );
00051 }
00052 
00053 //______________________________________________________________________________
00054 template <typename T>
00055 inline Any::Any( T const & value )
00056 {
00057     ::uno_type_any_construct(
00058         this, const_cast<T *>(&value),
00059         ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(),
00060         (uno_AcquireFunc) cpp_acquire );
00061 }
00062 //______________________________________________________________________________
00063 inline Any::Any( bool value )
00064 {
00065     sal_Bool b = value;
00066     ::uno_type_any_construct(
00067         this, &b, ::getCppuBooleanType().getTypeLibType(),
00068         (uno_AcquireFunc) cpp_acquire );
00069 }
00070 
00071 //__________________________________________________________________________________________________
00072 inline Any::Any( const Any & rAny ) SAL_THROW(())
00073 {
00074     ::uno_type_any_construct( this, rAny.pData, rAny.pType, (uno_AcquireFunc)cpp_acquire );
00075 }
00076 //__________________________________________________________________________________________________
00077 inline Any::Any( const void * pData_, const Type & rType ) SAL_THROW(())
00078 {
00079     ::uno_type_any_construct(
00080         this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
00081         (uno_AcquireFunc)cpp_acquire );
00082 }
00083 //__________________________________________________________________________________________________
00084 inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
00085 {
00086     ::uno_any_construct(
00087         this, const_cast< void * >( pData_ ), pTypeDescr, (uno_AcquireFunc)cpp_acquire );
00088 }
00089 //__________________________________________________________________________________________________
00090 inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW(())
00091 {
00092     ::uno_type_any_construct(
00093         this, const_cast< void * >( pData_ ), pType_, (uno_AcquireFunc)cpp_acquire );
00094 }
00095 //__________________________________________________________________________________________________
00096 inline Any::~Any() SAL_THROW(())
00097 {
00098     ::uno_any_destruct(
00099         this, (uno_ReleaseFunc)cpp_release );
00100 }
00101 //__________________________________________________________________________________________________
00102 inline Any & Any::operator = ( const Any & rAny ) SAL_THROW(())
00103 {
00104     if (this != &rAny)
00105     {
00106         ::uno_type_any_assign(
00107             this, rAny.pData, rAny.pType,
00108             (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
00109     }
00110     return *this;
00111 }
00112 //__________________________________________________________________________________________________
00113 inline ::rtl::OUString Any::getValueTypeName() const SAL_THROW(())
00114 {
00115     return ::rtl::OUString( pType->pTypeName );
00116 }
00117 //__________________________________________________________________________________________________
00118 inline void Any::setValue( const void * pData_, const Type & rType ) SAL_THROW(())
00119 {
00120     ::uno_type_any_assign(
00121         this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
00122         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
00123 }
00124 //__________________________________________________________________________________________________
00125 inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW(())
00126 {
00127     ::uno_type_any_assign(
00128         this, const_cast< void * >( pData_ ), pType_,
00129         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
00130 }
00131 //__________________________________________________________________________________________________
00132 inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
00133 {
00134     ::uno_any_assign(
00135         this, const_cast< void * >( pData_ ), pTypeDescr,
00136         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
00137 }
00138 //__________________________________________________________________________________________________
00139 inline void Any::clear() SAL_THROW(())
00140 {
00141     ::uno_any_clear(
00142         this, (uno_ReleaseFunc)cpp_release );
00143 }
00144 //__________________________________________________________________________________________________
00145 inline sal_Bool Any::isExtractableTo( const Type & rType ) const SAL_THROW(())
00146 {
00147     return ::uno_type_isAssignableFromData(
00148         rType.getTypeLibType(), pData, pType,
00149         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
00150 }
00151 
00152 //______________________________________________________________________________
00153 template <typename T>
00154 inline bool Any::has() const
00155 {
00156     Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0));
00157     return ::uno_type_isAssignableFromData(
00158         rType.getTypeLibType(), pData, pType,
00159         (uno_QueryInterfaceFunc) cpp_queryInterface,
00160         (uno_ReleaseFunc) cpp_release );
00161 }
00162 #if ! defined(__SUNPRO_CC)
00163 // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
00164 template <>
00165 bool Any::has<sal_uInt16>() const;
00166 #endif // ! defined(__SUNPRO_CC)
00167 
00168 //__________________________________________________________________________________________________
00169 inline sal_Bool Any::operator == ( const Any & rAny ) const SAL_THROW(())
00170 {
00171     return ::uno_type_equalData(
00172         pData, pType, rAny.pData, rAny.pType,
00173         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
00174 }
00175 //__________________________________________________________________________________________________
00176 inline sal_Bool Any::operator != ( const Any & rAny ) const SAL_THROW(())
00177 {
00178     return (! ::uno_type_equalData(
00179         pData, pType, rAny.pData, rAny.pType,
00180         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release ));
00181 }
00182 
00183 //__________________________________________________________________________________________________
00184 template< class C >
00185 inline Any SAL_CALL makeAny( const C & value ) SAL_THROW(())
00186 {
00187     return Any( &value, ::cppu::getTypeFavourUnsigned(&value) );
00188 }
00189 
00190 // additionally specialized for C++ bool
00191 //______________________________________________________________________________
00192 template<>
00193 inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW(())
00194 {
00195     const sal_Bool b = value;
00196     return Any( &b, ::getCppuBooleanType() );
00197 }
00198 
00199 //__________________________________________________________________________________________________
00200 template< class C >
00201 inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW(())
00202 {
00203     const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
00204     ::uno_type_any_assign(
00205         &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
00206         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
00207 }
00208 
00209 // additionally for C++ bool:
00210 //______________________________________________________________________________
00211 inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
00212     SAL_THROW(())
00213 {
00214     sal_Bool b = value;
00215     ::uno_type_any_assign(
00216         &rAny, &b, ::getCppuBooleanType().getTypeLibType(),
00217         (uno_AcquireFunc) cpp_acquire, (uno_ReleaseFunc) cpp_release );
00218 }
00219 
00220 //__________________________________________________________________________________________________
00221 template< class C >
00222 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW(())
00223 {
00224     const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
00225     return ::uno_type_assignData(
00226         &value, rType.getTypeLibType(),
00227         rAny.pData, rAny.pType,
00228         (uno_QueryInterfaceFunc)cpp_queryInterface,
00229         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
00230 }
00231 
00232 // bool
00233 //__________________________________________________________________________________________________
00234 inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ) SAL_THROW(())
00235 {
00236     if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
00237     {
00238         value = (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False);
00239         return sal_True;
00240     }
00241     return sal_False;
00242 }
00243 //__________________________________________________________________________________________________
00244 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW(())
00245 {
00246     return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
00247             (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False));
00248 }
00249 
00250 //______________________________________________________________________________
00251 template<>
00252 inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
00253     SAL_THROW(())
00254 {
00255     if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
00256     {
00257         value = *reinterpret_cast< sal_Bool const * >(
00258             rAny.pData ) != sal_False;
00259         return true;
00260     }
00261     return false;
00262 }
00263 
00264 //______________________________________________________________________________
00265 template<>
00266 inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
00267     SAL_THROW(())
00268 {
00269     return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
00270             (value ==
00271              (*reinterpret_cast< sal_Bool const * >( rAny.pData )
00272               != sal_False)));
00273 }
00274 
00275 // byte
00276 //__________________________________________________________________________________________________
00277 inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ) SAL_THROW(())
00278 {
00279     if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
00280     {
00281         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
00282         return sal_True;
00283     }
00284     return sal_False;
00285 }
00286 // short
00287 //__________________________________________________________________________________________________
00288 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW(())
00289 {
00290     switch (rAny.pType->eTypeClass)
00291     {
00292     case typelib_TypeClass_BYTE:
00293         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
00294         return sal_True;
00295     case typelib_TypeClass_SHORT:
00296     case typelib_TypeClass_UNSIGNED_SHORT:
00297         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
00298         return sal_True;
00299     default:
00300         return sal_False;
00301     }
00302 }
00303 //__________________________________________________________________________________________________
00304 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW(())
00305 {
00306     switch (rAny.pType->eTypeClass)
00307     {
00308     case typelib_TypeClass_BYTE:
00309         value = (sal_uInt16)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
00310         return sal_True;
00311     case typelib_TypeClass_SHORT:
00312     case typelib_TypeClass_UNSIGNED_SHORT:
00313         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
00314         return sal_True;
00315     default:
00316         return sal_False;
00317     }
00318 }
00319 // long
00320 //__________________________________________________________________________________________________
00321 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW(())
00322 {
00323     switch (rAny.pType->eTypeClass)
00324     {
00325     case typelib_TypeClass_BYTE:
00326         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
00327         return sal_True;
00328     case typelib_TypeClass_SHORT:
00329         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
00330         return sal_True;
00331     case typelib_TypeClass_UNSIGNED_SHORT:
00332         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
00333         return sal_True;
00334     case typelib_TypeClass_LONG:
00335     case typelib_TypeClass_UNSIGNED_LONG:
00336         value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
00337         return sal_True;
00338     default:
00339         return sal_False;
00340     }
00341 }
00342 //__________________________________________________________________________________________________
00343 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW(())
00344 {
00345     switch (rAny.pType->eTypeClass)
00346     {
00347     case typelib_TypeClass_BYTE:
00348         value = (sal_uInt32)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
00349         return sal_True;
00350     case typelib_TypeClass_SHORT:
00351         value = (sal_uInt32)( * reinterpret_cast< const sal_Int16 * >( rAny.pData ) );
00352         return sal_True;
00353     case typelib_TypeClass_UNSIGNED_SHORT:
00354         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
00355         return sal_True;
00356     case typelib_TypeClass_LONG:
00357     case typelib_TypeClass_UNSIGNED_LONG:
00358         value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
00359         return sal_True;
00360     default:
00361         return sal_False;
00362     }
00363 }
00364 // hyper
00365 //__________________________________________________________________________________________________
00366 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW(())
00367 {
00368     switch (rAny.pType->eTypeClass)
00369     {
00370     case typelib_TypeClass_BYTE:
00371         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
00372         return sal_True;
00373     case typelib_TypeClass_SHORT:
00374         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
00375         return sal_True;
00376     case typelib_TypeClass_UNSIGNED_SHORT:
00377         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
00378         return sal_True;
00379     case typelib_TypeClass_LONG:
00380         value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
00381         return sal_True;
00382     case typelib_TypeClass_UNSIGNED_LONG:
00383         value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
00384         return sal_True;
00385     case typelib_TypeClass_HYPER:
00386     case typelib_TypeClass_UNSIGNED_HYPER:
00387         value = * reinterpret_cast< const sal_Int64 * >( rAny.pData );
00388         return sal_True;
00389     default:
00390         return sal_False;
00391     }
00392 }
00393 //__________________________________________________________________________________________________
00394 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW(())
00395 {
00396     switch (rAny.pType->eTypeClass)
00397     {
00398     case typelib_TypeClass_BYTE:
00399         value = (sal_uInt64)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
00400         return sal_True;
00401     case typelib_TypeClass_SHORT:
00402         value = (sal_uInt64)( * reinterpret_cast< const sal_Int16 * >( rAny.pData ) );
00403         return sal_True;
00404     case typelib_TypeClass_UNSIGNED_SHORT:
00405         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
00406         return sal_True;
00407     case typelib_TypeClass_LONG:
00408         value = (sal_uInt64)( * reinterpret_cast< const sal_Int32 * >( rAny.pData ) );
00409         return sal_True;
00410     case typelib_TypeClass_UNSIGNED_LONG:
00411         value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
00412         return sal_True;
00413     case typelib_TypeClass_HYPER:
00414     case typelib_TypeClass_UNSIGNED_HYPER:
00415         value = * reinterpret_cast< const sal_uInt64 * >( rAny.pData );
00416         return sal_True;
00417     default:
00418         return sal_False;
00419     }
00420 }
00421 // float
00422 //__________________________________________________________________________________________________
00423 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW(())
00424 {
00425     switch (rAny.pType->eTypeClass)
00426     {
00427     case typelib_TypeClass_BYTE:
00428         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
00429         return sal_True;
00430     case typelib_TypeClass_SHORT:
00431         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
00432         return sal_True;
00433     case typelib_TypeClass_UNSIGNED_SHORT:
00434         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
00435         return sal_True;
00436     case typelib_TypeClass_FLOAT:
00437         value = * reinterpret_cast< const float * >( rAny.pData );
00438         return sal_True;
00439     default:
00440         return sal_False;
00441     }
00442 }
00443 // double
00444 //__________________________________________________________________________________________________
00445 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW(())
00446 {
00447     switch (rAny.pType->eTypeClass)
00448     {
00449     case typelib_TypeClass_BYTE:
00450         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
00451         return sal_True;
00452     case typelib_TypeClass_SHORT:
00453         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
00454         return sal_True;
00455     case typelib_TypeClass_UNSIGNED_SHORT:
00456         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
00457         return sal_True;
00458     case typelib_TypeClass_LONG:
00459         value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
00460         return sal_True;
00461     case typelib_TypeClass_UNSIGNED_LONG:
00462         value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
00463         return sal_True;
00464     case typelib_TypeClass_FLOAT:
00465         value = * reinterpret_cast< const float * >( rAny.pData );
00466         return sal_True;
00467     case typelib_TypeClass_DOUBLE:
00468         value = * reinterpret_cast< const double * >( rAny.pData );
00469         return sal_True;
00470     default:
00471         return sal_False;
00472     }
00473 }
00474 // string
00475 //__________________________________________________________________________________________________
00476 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW(())
00477 {
00478     if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
00479     {
00480         value = * reinterpret_cast< const ::rtl::OUString * >( rAny.pData );
00481         return sal_True;
00482     }
00483     return sal_False;
00484 }
00485 //__________________________________________________________________________________________________
00486 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW(())
00487 {
00488     return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
00489             value.equals( * reinterpret_cast< const ::rtl::OUString * >( rAny.pData ) ));
00490 }
00491 // type
00492 //__________________________________________________________________________________________________
00493 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW(())
00494 {
00495     if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
00496     {
00497         value = * reinterpret_cast< const Type * >( rAny.pData );
00498         return sal_True;
00499     }
00500     return sal_False;
00501 }
00502 //__________________________________________________________________________________________________
00503 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW(())
00504 {
00505     return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
00506             value.equals( * reinterpret_cast< const Type * >( rAny.pData ) ));
00507 }
00508 // any
00509 //__________________________________________________________________________________________________
00510 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW(())
00511 {
00512     if (&rAny != &value)
00513     {
00514         ::uno_type_any_assign(
00515             &value, rAny.pData, rAny.pType,
00516             (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
00517     }
00518     return sal_True;
00519 }
00520 // interface
00521 //__________________________________________________________________________________________________
00522 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW(())
00523 {
00524     if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
00525     {
00526         return reinterpret_cast< const BaseReference * >( rAny.pData )->operator == ( value );
00527     }
00528     return sal_False;
00529 }
00530 
00531 // operator to compare to an any.
00532 //__________________________________________________________________________________________________
00533 template< class C >
00534 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW(())
00535 {
00536     const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
00537     return ::uno_type_equalData(
00538         rAny.pData, rAny.pType,
00539         const_cast< C * >( &value ), rType.getTypeLibType(),
00540         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
00541 }
00542 // operator to compare to an any.  may use specialized operators ==.
00543 //__________________________________________________________________________________________________
00544 template< class C >
00545 inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW(())
00546 {
00547     return (! operator == ( rAny, value ));
00548 }
00549 
00550 #if ! defined(EXCEPTIONS_OFF)
00551 extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
00552     uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
00553     SAL_THROW_EXTERN_C();
00554 
00555 //______________________________________________________________________________
00556 template <typename T>
00557 T Any::get() const
00558 {
00559     T value = T();
00560     if (! (*this >>= value)) {
00561         throw RuntimeException(
00562             ::rtl::OUString(
00563                 cppu_Any_extraction_failure_msg(
00564                     this,
00565                     ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
00566                 SAL_NO_ACQUIRE ),
00567             Reference<XInterface>() );
00568     }
00569     return value;
00570 }
00571 // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
00572 template <>
00573 sal_uInt16 Any::get<sal_uInt16>() const;
00574 #endif // ! defined(EXCEPTIONS_OFF)
00575 
00576 }
00577 }
00578 }
00579 }
00580 
00581 #endif
00582 
00583 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines