LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/com/sun/star/uno - Any.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 211 217 97.2 %
Date: 2013-07-09 Functions: 1157 1963 58.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef _COM_SUN_STAR_UNO_ANY_HXX_
      20             : #define _COM_SUN_STAR_UNO_ANY_HXX_
      21             : 
      22             : #include <com/sun/star/uno/Any.h>
      23             : #include <uno/data.h>
      24             : #include <com/sun/star/uno/Type.hxx>
      25             : #include <com/sun/star/uno/XInterface.hpp>
      26             : #include <com/sun/star/uno/genfunc.hxx>
      27             : #include "cppu/unotype.hxx"
      28             : 
      29             : namespace com
      30             : {
      31             : namespace sun
      32             : {
      33             : namespace star
      34             : {
      35             : namespace uno
      36             : {
      37             : 
      38             : //__________________________________________________________________________________________________
      39    18354923 : inline Any::Any() SAL_THROW(())
      40             : {
      41    18354923 :     ::uno_any_construct( this, 0, 0, (uno_AcquireFunc)cpp_acquire );
      42    18354923 : }
      43             : 
      44             : //______________________________________________________________________________
      45             : template <typename T>
      46      157449 : inline Any::Any( T const & value )
      47             : {
      48      157449 :     ::uno_type_any_construct(
      49             :         this, const_cast<T *>(&value),
      50      157449 :         ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(),
      51      157449 :         (uno_AcquireFunc) cpp_acquire );
      52      157449 : }
      53             : //______________________________________________________________________________
      54        1494 : inline Any::Any( bool value )
      55             : {
      56        1494 :     sal_Bool b = value;
      57             :     ::uno_type_any_construct(
      58        1494 :         this, &b, ::getCppuBooleanType().getTypeLibType(),
      59        1494 :         (uno_AcquireFunc) cpp_acquire );
      60        1494 : }
      61             : 
      62             : //__________________________________________________________________________________________________
      63    24369466 : inline Any::Any( const Any & rAny ) SAL_THROW(())
      64             : {
      65    24369466 :     ::uno_type_any_construct( this, rAny.pData, rAny.pType, (uno_AcquireFunc)cpp_acquire );
      66    24369466 : }
      67             : //__________________________________________________________________________________________________
      68    12008581 : inline Any::Any( const void * pData_, const Type & rType ) SAL_THROW(())
      69             : {
      70             :     ::uno_type_any_construct(
      71             :         this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
      72    12008581 :         (uno_AcquireFunc)cpp_acquire );
      73    12008581 : }
      74             : //__________________________________________________________________________________________________
      75          82 : inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
      76             : {
      77             :     ::uno_any_construct(
      78          82 :         this, const_cast< void * >( pData_ ), pTypeDescr, (uno_AcquireFunc)cpp_acquire );
      79          82 : }
      80             : //__________________________________________________________________________________________________
      81     6852371 : inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW(())
      82             : {
      83             :     ::uno_type_any_construct(
      84     6852371 :         this, const_cast< void * >( pData_ ), pType_, (uno_AcquireFunc)cpp_acquire );
      85     6852370 : }
      86             : //__________________________________________________________________________________________________
      87    61639458 : inline Any::~Any() SAL_THROW(())
      88             : {
      89             :     ::uno_any_destruct(
      90    61639458 :         this, (uno_ReleaseFunc)cpp_release );
      91    61639460 : }
      92             : //__________________________________________________________________________________________________
      93    14867050 : inline Any & Any::operator = ( const Any & rAny ) SAL_THROW(())
      94             : {
      95    14867050 :     if (this != &rAny)
      96             :     {
      97             :         ::uno_type_any_assign(
      98             :             this, rAny.pData, rAny.pType,
      99    14863325 :             (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     100             :     }
     101    14867050 :     return *this;
     102             : }
     103             : //__________________________________________________________________________________________________
     104         214 : inline ::rtl::OUString Any::getValueTypeName() const SAL_THROW(())
     105             : {
     106         214 :     return ::rtl::OUString( pType->pTypeName );
     107             : }
     108             : //__________________________________________________________________________________________________
     109      186907 : inline void Any::setValue( const void * pData_, const Type & rType ) SAL_THROW(())
     110             : {
     111             :     ::uno_type_any_assign(
     112             :         this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
     113      186907 :         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     114      186907 : }
     115             : //__________________________________________________________________________________________________
     116             : inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW(())
     117             : {
     118             :     ::uno_type_any_assign(
     119             :         this, const_cast< void * >( pData_ ), pType_,
     120             :         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     121             : }
     122             : //__________________________________________________________________________________________________
     123       10191 : inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
     124             : {
     125             :     ::uno_any_assign(
     126             :         this, const_cast< void * >( pData_ ), pTypeDescr,
     127       10191 :         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     128       10191 : }
     129             : //__________________________________________________________________________________________________
     130        3859 : inline void Any::clear() SAL_THROW(())
     131             : {
     132             :     ::uno_any_clear(
     133        3859 :         this, (uno_ReleaseFunc)cpp_release );
     134        3859 : }
     135             : //__________________________________________________________________________________________________
     136       44155 : inline sal_Bool Any::isExtractableTo( const Type & rType ) const SAL_THROW(())
     137             : {
     138             :     return ::uno_type_isAssignableFromData(
     139             :         rType.getTypeLibType(), pData, pType,
     140       44155 :         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
     141             : }
     142             : 
     143             : //______________________________________________________________________________
     144             : template <typename T>
     145        4810 : inline bool Any::has() const
     146             : {
     147        4810 :     Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0));
     148             :     return ::uno_type_isAssignableFromData(
     149             :         rType.getTypeLibType(), pData, pType,
     150             :         (uno_QueryInterfaceFunc) cpp_queryInterface,
     151        4810 :         (uno_ReleaseFunc) cpp_release );
     152             : }
     153             : #if ! defined(__SUNPRO_CC)
     154             : // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
     155             : template <>
     156             : bool Any::has<sal_uInt16>() const;
     157             : #endif // ! defined(__SUNPRO_CC)
     158             : 
     159             : //__________________________________________________________________________________________________
     160      179294 : inline sal_Bool Any::operator == ( const Any & rAny ) const SAL_THROW(())
     161             : {
     162             :     return ::uno_type_equalData(
     163             :         pData, pType, rAny.pData, rAny.pType,
     164      179294 :         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
     165             : }
     166             : //__________________________________________________________________________________________________
     167        6805 : inline sal_Bool Any::operator != ( const Any & rAny ) const SAL_THROW(())
     168             : {
     169             :     return (! ::uno_type_equalData(
     170             :         pData, pType, rAny.pData, rAny.pType,
     171        6805 :         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release ));
     172             : }
     173             : 
     174             : //__________________________________________________________________________________________________
     175             : template< class C >
     176     6636164 : inline Any SAL_CALL makeAny( const C & value ) SAL_THROW(())
     177             : {
     178     6636164 :     return Any( &value, ::cppu::getTypeFavourUnsigned(&value) );
     179             : }
     180             : 
     181             : // additionally specialized for C++ bool
     182             : //______________________________________________________________________________
     183             : template<>
     184      452082 : inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW(())
     185             : {
     186      452082 :     const sal_Bool b = value;
     187      452082 :     return Any( &b, ::getCppuBooleanType() );
     188             : }
     189             : 
     190             : //__________________________________________________________________________________________________
     191             : #ifdef RTL_FAST_STRING
     192             : template< class C1, class C2 >
     193       10943 : inline Any SAL_CALL makeAny( const rtl::OUStringConcat< C1, C2 >& value ) SAL_THROW(())
     194             : {
     195       10943 :     const rtl::OUString str( value );
     196       10943 :     return Any( &str, ::cppu::getTypeFavourUnsigned(&str) );
     197             : }
     198             : #endif
     199             : //__________________________________________________________________________________________________
     200             : template< class C >
     201     2606939 : inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW(())
     202             : {
     203     2606939 :     const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
     204     2606939 :     ::uno_type_any_assign(
     205             :         &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
     206     2606939 :         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     207     2606939 : }
     208             : 
     209             : // additionally for C++ bool:
     210             : //______________________________________________________________________________
     211      184778 : inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
     212             :     SAL_THROW(())
     213             : {
     214      184778 :     sal_Bool b = value;
     215             :     ::uno_type_any_assign(
     216      184778 :         &rAny, &b, ::getCppuBooleanType().getTypeLibType(),
     217      184778 :         (uno_AcquireFunc) cpp_acquire, (uno_ReleaseFunc) cpp_release );
     218      184778 : }
     219             : 
     220             : //______________________________________________________________________________
     221             : #ifdef RTL_FAST_STRING
     222             : template< class C1, class C2 >
     223          79 : inline void SAL_CALL operator <<= ( Any & rAny, const rtl::OUStringConcat< C1, C2 >& value )
     224             :     SAL_THROW(())
     225             : {
     226          79 :     const rtl::OUString str( value );
     227          79 :     const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
     228          79 :     ::uno_type_any_assign(
     229             :         &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
     230         158 :         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     231          79 : }
     232             : #endif
     233             : //__________________________________________________________________________________________________
     234             : template< class C >
     235     2909174 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW(())
     236             : {
     237     2909174 :     const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
     238             :     return ::uno_type_assignData(
     239             :         &value, rType.getTypeLibType(),
     240             :         rAny.pData, rAny.pType,
     241             :         (uno_QueryInterfaceFunc)cpp_queryInterface,
     242     2909174 :         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     243             : }
     244             : 
     245             : // bool
     246             : //__________________________________________________________________________________________________
     247     1082931 : inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ) SAL_THROW(())
     248             : {
     249     1082931 :     if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
     250             :     {
     251     1047426 :         value = (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False);
     252     1047426 :         return sal_True;
     253             :     }
     254       35505 :     return sal_False;
     255             : }
     256             : //__________________________________________________________________________________________________
     257           0 : inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW(())
     258             : {
     259           0 :     return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
     260           0 :             (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False));
     261             : }
     262             : 
     263             : //______________________________________________________________________________
     264             : template<>
     265       63340 : inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
     266             :     SAL_THROW(())
     267             : {
     268       63340 :     if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
     269             :     {
     270             :         value = *reinterpret_cast< sal_Bool const * >(
     271       57450 :             rAny.pData ) != sal_False;
     272       57450 :         return true;
     273             :     }
     274        5890 :     return false;
     275             : }
     276             : 
     277             : //______________________________________________________________________________
     278             : template<>
     279             : inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
     280             :     SAL_THROW(())
     281             : {
     282             :     return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
     283             :             (value ==
     284             :              (*reinterpret_cast< sal_Bool const * >( rAny.pData )
     285             :               != sal_False)));
     286             : }
     287             : 
     288             : // byte
     289             : //__________________________________________________________________________________________________
     290        1498 : inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ) SAL_THROW(())
     291             : {
     292        1498 :     if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
     293             :     {
     294        1398 :         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
     295        1398 :         return sal_True;
     296             :     }
     297         100 :     return sal_False;
     298             : }
     299             : // short
     300             : //__________________________________________________________________________________________________
     301      581417 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW(())
     302             : {
     303      581417 :     switch (rAny.pType->eTypeClass)
     304             :     {
     305             :     case typelib_TypeClass_BYTE:
     306         116 :         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
     307         116 :         return sal_True;
     308             :     case typelib_TypeClass_SHORT:
     309             :     case typelib_TypeClass_UNSIGNED_SHORT:
     310      514193 :         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
     311      514193 :         return sal_True;
     312             :     default:
     313       67108 :         return sal_False;
     314             :     }
     315             : }
     316             : //__________________________________________________________________________________________________
     317      327779 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW(())
     318             : {
     319      327779 :     switch (rAny.pType->eTypeClass)
     320             :     {
     321             :     case typelib_TypeClass_BYTE:
     322           5 :         value = (sal_uInt16)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
     323           5 :         return sal_True;
     324             :     case typelib_TypeClass_SHORT:
     325             :     case typelib_TypeClass_UNSIGNED_SHORT:
     326      327740 :         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
     327      327740 :         return sal_True;
     328             :     default:
     329          34 :         return sal_False;
     330             :     }
     331             : }
     332             : // long
     333             : //__________________________________________________________________________________________________
     334      605026 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW(())
     335             : {
     336      605026 :     switch (rAny.pType->eTypeClass)
     337             :     {
     338             :     case typelib_TypeClass_BYTE:
     339         415 :         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
     340         415 :         return sal_True;
     341             :     case typelib_TypeClass_SHORT:
     342      178637 :         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
     343      178637 :         return sal_True;
     344             :     case typelib_TypeClass_UNSIGNED_SHORT:
     345        1920 :         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
     346        1920 :         return sal_True;
     347             :     case typelib_TypeClass_LONG:
     348             :     case typelib_TypeClass_UNSIGNED_LONG:
     349      408157 :         value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
     350      408157 :         return sal_True;
     351             :     default:
     352       15897 :         return sal_False;
     353             :     }
     354             : }
     355             : //__________________________________________________________________________________________________
     356       54373 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW(())
     357             : {
     358       54373 :     switch (rAny.pType->eTypeClass)
     359             :     {
     360             :     case typelib_TypeClass_BYTE:
     361           1 :         value = (sal_uInt32)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
     362           1 :         return sal_True;
     363             :     case typelib_TypeClass_SHORT:
     364           1 :         value = (sal_uInt32)( * reinterpret_cast< const sal_Int16 * >( rAny.pData ) );
     365           1 :         return sal_True;
     366             :     case typelib_TypeClass_UNSIGNED_SHORT:
     367       39534 :         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
     368       39534 :         return sal_True;
     369             :     case typelib_TypeClass_LONG:
     370             :     case typelib_TypeClass_UNSIGNED_LONG:
     371       12154 :         value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
     372       12154 :         return sal_True;
     373             :     default:
     374        2683 :         return sal_False;
     375             :     }
     376             : }
     377             : // hyper
     378             : //__________________________________________________________________________________________________
     379        1124 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW(())
     380             : {
     381        1124 :     switch (rAny.pType->eTypeClass)
     382             :     {
     383             :     case typelib_TypeClass_BYTE:
     384           1 :         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
     385           1 :         return sal_True;
     386             :     case typelib_TypeClass_SHORT:
     387           1 :         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
     388           1 :         return sal_True;
     389             :     case typelib_TypeClass_UNSIGNED_SHORT:
     390           1 :         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
     391           1 :         return sal_True;
     392             :     case typelib_TypeClass_LONG:
     393         125 :         value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
     394         125 :         return sal_True;
     395             :     case typelib_TypeClass_UNSIGNED_LONG:
     396           1 :         value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
     397           1 :         return sal_True;
     398             :     case typelib_TypeClass_HYPER:
     399             :     case typelib_TypeClass_UNSIGNED_HYPER:
     400         977 :         value = * reinterpret_cast< const sal_Int64 * >( rAny.pData );
     401         977 :         return sal_True;
     402             :     default:
     403          18 :         return sal_False;
     404             :     }
     405             : }
     406             : //__________________________________________________________________________________________________
     407          40 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW(())
     408             : {
     409          40 :     switch (rAny.pType->eTypeClass)
     410             :     {
     411             :     case typelib_TypeClass_BYTE:
     412           1 :         value = (sal_uInt64)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
     413           1 :         return sal_True;
     414             :     case typelib_TypeClass_SHORT:
     415           1 :         value = (sal_uInt64)( * reinterpret_cast< const sal_Int16 * >( rAny.pData ) );
     416           1 :         return sal_True;
     417             :     case typelib_TypeClass_UNSIGNED_SHORT:
     418           1 :         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
     419           1 :         return sal_True;
     420             :     case typelib_TypeClass_LONG:
     421           1 :         value = (sal_uInt64)( * reinterpret_cast< const sal_Int32 * >( rAny.pData ) );
     422           1 :         return sal_True;
     423             :     case typelib_TypeClass_UNSIGNED_LONG:
     424           1 :         value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
     425           1 :         return sal_True;
     426             :     case typelib_TypeClass_HYPER:
     427             :     case typelib_TypeClass_UNSIGNED_HYPER:
     428          22 :         value = * reinterpret_cast< const sal_uInt64 * >( rAny.pData );
     429          22 :         return sal_True;
     430             :     default:
     431          13 :         return sal_False;
     432             :     }
     433             : }
     434             : // float
     435             : //__________________________________________________________________________________________________
     436        9642 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW(())
     437             : {
     438        9642 :     switch (rAny.pType->eTypeClass)
     439             :     {
     440             :     case typelib_TypeClass_BYTE:
     441           1 :         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
     442           1 :         return sal_True;
     443             :     case typelib_TypeClass_SHORT:
     444          42 :         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
     445          42 :         return sal_True;
     446             :     case typelib_TypeClass_UNSIGNED_SHORT:
     447           1 :         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
     448           1 :         return sal_True;
     449             :     case typelib_TypeClass_FLOAT:
     450        8404 :         value = * reinterpret_cast< const float * >( rAny.pData );
     451        8404 :         return sal_True;
     452             :     default:
     453        1194 :         return sal_False;
     454             :     }
     455             : }
     456             : // double
     457             : //__________________________________________________________________________________________________
     458      141177 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW(())
     459             : {
     460      141177 :     switch (rAny.pType->eTypeClass)
     461             :     {
     462             :     case typelib_TypeClass_BYTE:
     463        2187 :         value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
     464        2187 :         return sal_True;
     465             :     case typelib_TypeClass_SHORT:
     466          33 :         value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
     467          33 :         return sal_True;
     468             :     case typelib_TypeClass_UNSIGNED_SHORT:
     469           1 :         value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
     470           1 :         return sal_True;
     471             :     case typelib_TypeClass_LONG:
     472          56 :         value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
     473          56 :         return sal_True;
     474             :     case typelib_TypeClass_UNSIGNED_LONG:
     475           1 :         value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
     476           1 :         return sal_True;
     477             :     case typelib_TypeClass_FLOAT:
     478       77508 :         value = * reinterpret_cast< const float * >( rAny.pData );
     479       77508 :         return sal_True;
     480             :     case typelib_TypeClass_DOUBLE:
     481       32583 :         value = * reinterpret_cast< const double * >( rAny.pData );
     482       32583 :         return sal_True;
     483             :     default:
     484       28808 :         return sal_False;
     485             :     }
     486             : }
     487             : // string
     488             : //__________________________________________________________________________________________________
     489     3939076 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW(())
     490             : {
     491     3939076 :     if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
     492             :     {
     493     3811313 :         value = * reinterpret_cast< const ::rtl::OUString * >( rAny.pData );
     494     3811313 :         return sal_True;
     495             :     }
     496      127763 :     return sal_False;
     497             : }
     498             : //__________________________________________________________________________________________________
     499             : inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW(())
     500             : {
     501             :     return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
     502             :             value.equals( * reinterpret_cast< const ::rtl::OUString * >( rAny.pData ) ));
     503             : }
     504             : // type
     505             : //__________________________________________________________________________________________________
     506         240 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW(())
     507             : {
     508         240 :     if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
     509             :     {
     510         221 :         value = * reinterpret_cast< const Type * >( rAny.pData );
     511         221 :         return sal_True;
     512             :     }
     513          19 :     return sal_False;
     514             : }
     515             : //__________________________________________________________________________________________________
     516             : inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW(())
     517             : {
     518             :     return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
     519             :             value.equals( * reinterpret_cast< const Type * >( rAny.pData ) ));
     520             : }
     521             : // any
     522             : //__________________________________________________________________________________________________
     523       18616 : inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW(())
     524             : {
     525       18616 :     if (&rAny != &value)
     526             :     {
     527             :         ::uno_type_any_assign(
     528             :             &value, rAny.pData, rAny.pType,
     529       18616 :             (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
     530             :     }
     531       18616 :     return sal_True;
     532             : }
     533             : // interface
     534             : //__________________________________________________________________________________________________
     535             : inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW(())
     536             : {
     537             :     if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
     538             :     {
     539             :         return reinterpret_cast< const BaseReference * >( rAny.pData )->operator == ( value );
     540             :     }
     541             :     return sal_False;
     542             : }
     543             : 
     544             : // operator to compare to an any.
     545             : //__________________________________________________________________________________________________
     546             : template< class C >
     547          69 : inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW(())
     548             : {
     549          69 :     const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
     550             :     return ::uno_type_equalData(
     551             :         rAny.pData, rAny.pType,
     552             :         const_cast< C * >( &value ), rType.getTypeLibType(),
     553          69 :         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
     554             : }
     555             : // operator to compare to an any.  may use specialized operators ==.
     556             : //__________________________________________________________________________________________________
     557             : template< class C >
     558           1 : inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW(())
     559             : {
     560           1 :     return (! operator == ( rAny, value ));
     561             : }
     562             : 
     563             : #if ! defined(EXCEPTIONS_OFF)
     564             : extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
     565             :     uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
     566             :     SAL_THROW_EXTERN_C();
     567             : 
     568             : //______________________________________________________________________________
     569             : template <typename T>
     570      251411 : T Any::get() const
     571             : {
     572      251411 :     T value = T();
     573      251411 :     if (! (*this >>= value)) {
     574           0 :         throw RuntimeException(
     575             :             ::rtl::OUString(
     576             :                 cppu_Any_extraction_failure_msg(
     577             :                     this,
     578           0 :                     ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
     579             :                 SAL_NO_ACQUIRE ),
     580           0 :             Reference<XInterface>() );
     581             :     }
     582      251411 :     return value;
     583             : }
     584             : // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
     585             : template <>
     586             : sal_uInt16 Any::get<sal_uInt16>() const;
     587             : #endif // ! defined(EXCEPTIONS_OFF)
     588             : 
     589             : }
     590             : }
     591             : }
     592             : }
     593             : 
     594             : #endif
     595             : 
     596             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10