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