LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/cppu - unotype.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 58 100.0 %
Date: 2012-08-25 Functions: 4334 6560 66.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 22 26 84.6 %

           Branch data     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                 :            : 
      20                 :            : #ifndef INCLUDED_CPPU_UNOTYPE_HXX
      21                 :            : #define INCLUDED_CPPU_UNOTYPE_HXX
      22                 :            : 
      23                 :            : #include "sal/config.h"
      24                 :            : #include "com/sun/star/uno/Type.h"
      25                 :            : #include "sal/types.h"
      26                 :            : #include "typelib/typeclass.h"
      27                 :            : #include "typelib/typedescription.h"
      28                 :            : 
      29                 :            : namespace com { namespace sun { namespace star { namespace uno {
      30                 :            :     class Any;
      31                 :            :     class Exception;
      32                 :            :     template< typename > class Reference;
      33                 :            :     template< typename > class Sequence;
      34                 :            :     class XInterface;
      35                 :            : } } } }
      36                 :            : namespace rtl { class OUString; }
      37                 :            : 
      38                 :            : namespace cppu {
      39                 :            : 
      40                 :            : template< typename > class UnoType;
      41                 :            : 
      42                 :            : /**
      43                 :            :    A unique C++ type representing the UNO type VOID in cppu::UnoType.
      44                 :            : 
      45                 :            :    This type is declared but not defined.  Its only use is as a template
      46                 :            :    argument to cppu::UnoType.
      47                 :            : 
      48                 :            :    @since UDK 3.2.2
      49                 :            : */
      50                 :            : struct UnoVoidType;
      51                 :            : 
      52                 :            : /**
      53                 :            :    A unique C++ type representing the UNO type UNSIGNED SHORT in cppu::UnoType.
      54                 :            : 
      55                 :            :    The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
      56                 :            :    type is needed to unambiguously specify UNO types in cppu::UnoType.
      57                 :            : 
      58                 :            :    This type is declared but not defined.  Its only use is as a template
      59                 :            :    argument to cppu::UnoType.
      60                 :            : 
      61                 :            :    @since UDK 3.2.2
      62                 :            : */
      63                 :            : struct UnoUnsignedShortType;
      64                 :            : 
      65                 :            : /**
      66                 :            :    A unique C++ type representing the UNO type UNSIGNED SHORT in cppu::UnoType.
      67                 :            : 
      68                 :            :    The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
      69                 :            :    type is needed to unambiguously specify UNO types in cppu::UnoType.
      70                 :            : 
      71                 :            :    This type is declared but not defined.  Its only use is as a template
      72                 :            :    argument to cppu::UnoType.
      73                 :            : 
      74                 :            :    @since UDK 3.2.2
      75                 :            : */
      76                 :            : struct UnoCharType;
      77                 :            : 
      78                 :            : /**
      79                 :            :    A unique C++ type template representing the UNO sequence types in
      80                 :            :    cppu::UnoType.
      81                 :            : 
      82                 :            :    The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
      83                 :            :    type is needed to unambiguously specify UNO types in cppu::UnoType.
      84                 :            : 
      85                 :            :    This type is declared but not defined.  Its only use is as a template
      86                 :            :    argument to cppu::UnoType.
      87                 :            : 
      88                 :            :    @since UDK 3.2.2
      89                 :            : */
      90                 :            : template< typename > struct UnoSequenceType;
      91                 :            : 
      92                 :            : namespace detail {
      93                 :            : 
      94                 :  129537022 : inline ::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(
      95                 :            :     ::typelib_TypeDescriptionReference * const * tdr)
      96                 :            : {
      97                 :  129537022 :     return *reinterpret_cast< ::com::sun::star::uno::Type const * >(tdr);
      98                 :            : }
      99                 :            : 
     100                 :            : inline ::com::sun::star::uno::Type const &
     101                 :   21000379 : getTypeFromTypeClass(::typelib_TypeClass tc) {
     102                 :            :     return getTypeFromTypeDescriptionReference(
     103                 :   21000379 :         ::typelib_static_type_getByTypeClass(tc));
     104                 :            : }
     105                 :            : 
     106                 :            : }
     107                 :            : 
     108                 :            : }
     109                 :            : 
     110                 :            : // For _MSC_VER 1310, define cppu_detail_getUnoType in the global namespace, to
     111                 :            : // avoid spurious compiler errors in code that calls cppu_detail_getUnoType:
     112                 :            : #if !defined _MSC_VER || _MSC_VER > 1310
     113                 :            : namespace cppu { namespace detail {
     114                 :            : #endif
     115                 :            : 
     116                 :            : inline ::com::sun::star::uno::Type const &
     117                 :      82075 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
     118                 :      82075 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_VOID);
     119                 :            : }
     120                 :            : 
     121                 :            : inline ::com::sun::star::uno::Type const &
     122                 :    1363118 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER bool const *) {
     123                 :    1363118 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
     124                 :            : }
     125                 :            : 
     126                 :            : inline ::com::sun::star::uno::Type const &
     127                 :    1701970 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Bool const *) {
     128                 :    1701970 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
     129                 :            : }
     130                 :            : 
     131                 :            : inline ::com::sun::star::uno::Type const &
     132                 :      31761 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int8 const *) {
     133                 :      31761 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BYTE);
     134                 :            : }
     135                 :            : 
     136                 :            : inline ::com::sun::star::uno::Type const &
     137                 :     457705 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
     138                 :     457705 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_SHORT);
     139                 :            : }
     140                 :            : 
     141                 :            : inline ::com::sun::star::uno::Type const &
     142                 :      57176 : cppu_detail_getUnoType(
     143                 :            :     SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
     144                 :            : {
     145                 :            :     return ::cppu::detail::getTypeFromTypeClass(
     146                 :      57176 :         ::typelib_TypeClass_UNSIGNED_SHORT);
     147                 :            : }
     148                 :            : 
     149                 :            : inline ::com::sun::star::uno::Type const &
     150                 :    1663644 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
     151                 :    1663644 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_LONG);
     152                 :            : }
     153                 :            : 
     154                 :            : inline ::com::sun::star::uno::Type const &
     155                 :      39390 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
     156                 :            :     return ::cppu::detail::getTypeFromTypeClass(
     157                 :      39390 :         ::typelib_TypeClass_UNSIGNED_LONG);
     158                 :            : }
     159                 :            : 
     160                 :            : inline ::com::sun::star::uno::Type const &
     161                 :      91960 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
     162                 :      91960 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_HYPER);
     163                 :            : }
     164                 :            : 
     165                 :            : inline ::com::sun::star::uno::Type const &
     166                 :         76 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
     167                 :            :     return ::cppu::detail::getTypeFromTypeClass(
     168                 :         76 :         ::typelib_TypeClass_UNSIGNED_HYPER);
     169                 :            : }
     170                 :            : 
     171                 :            : inline ::com::sun::star::uno::Type const &
     172                 :      33183 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER float const *) {
     173                 :      33183 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_FLOAT);
     174                 :            : }
     175                 :            : 
     176                 :            : inline ::com::sun::star::uno::Type const &
     177                 :      69532 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER double const *) {
     178                 :      69532 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_DOUBLE);
     179                 :            : }
     180                 :            : 
     181                 :            : inline ::com::sun::star::uno::Type const &
     182                 :        156 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
     183                 :        156 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_CHAR);
     184                 :            : }
     185                 :            : 
     186                 :            : inline ::com::sun::star::uno::Type const &
     187                 :    6344805 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
     188                 :    6344805 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_STRING);
     189                 :            : }
     190                 :            : 
     191                 :            : inline ::com::sun::star::uno::Type const &
     192                 :      13073 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Type const *)
     193                 :            : {
     194                 :      13073 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_TYPE);
     195                 :            : }
     196                 :            : 
     197                 :            : inline ::com::sun::star::uno::Type const &
     198                 :     312643 : cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Any const *)
     199                 :            : {
     200                 :     312643 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_ANY);
     201                 :            : }
     202                 :            : 
     203                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     204                 :     260715 : cppu_detail_getUnoType(
     205                 :            :     SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
     206                 :            : {
     207                 :            :     //TODO: depending on memory model, the following might not work reliably
     208                 :            :     static typelib_TypeDescriptionReference * p = 0;
     209 [ +  + ][ +  + ]:     260715 :     if (p == 0) {
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  - ]
         [ +  + ][ #  # ]
                 [ +  - ]
     210                 :      47515 :         ::typelib_static_sequence_type_init(
     211                 :            :             &p, ::cppu::UnoType< T >::get().getTypeLibType());
     212                 :            :     }
     213                 :     260715 :     return ::cppu::detail::getTypeFromTypeDescriptionReference(&p);
     214                 :            : }
     215                 :            : 
     216                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     217                 :     181991 : cppu_detail_getUnoType(
     218                 :            :     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
     219                 :            : {
     220                 :            :     return cppu_detail_getUnoType(
     221                 :     181991 :         static_cast< ::cppu::UnoSequenceType< T > * >(0));
     222                 :            : }
     223                 :            : 
     224                 :      40225 : inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
     225                 :            :     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Exception const *)
     226                 :            : {
     227                 :      40225 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_EXCEPTION);
     228                 :            : }
     229                 :            : 
     230                 :    8825041 : inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
     231                 :            :     SAL_UNUSED_PARAMETER ::com::sun::star::uno::XInterface const *)
     232                 :            : {
     233                 :    8825041 :     return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_INTERFACE);
     234                 :            : }
     235                 :            : 
     236                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     237                 :   97985864 : cppu_detail_getUnoType(
     238                 :            :     SAL_UNUSED_PARAMETER ::com::sun::star::uno::Reference< T > const *)
     239                 :            : {
     240                 :   97985864 :     return ::cppu::UnoType< T >::get();
     241                 :            : }
     242                 :            : 
     243                 :            : #if !defined _MSC_VER || _MSC_VER > 1310
     244                 :            : } }
     245                 :            : #endif
     246                 :            : 
     247                 :            : namespace cppu {
     248                 :            : 
     249                 :            : /**
     250                 :            :    Get the com::sun::star::uno::Type instance representing a certain UNO type.
     251                 :            : 
     252                 :            :    For each C++ type representing a UNO type, the corresponding instantiation of
     253                 :            :    this template has a public static member function get().  (The template is
     254                 :            :    specialized for C++ templates representing polymorphic struct type templates
     255                 :            :    of UNO.  In those cases, it does not work to instantiate UnoType with a C++
     256                 :            :    type that is derived from a C++ type that represents a UNO type, but does not
     257                 :            :    itself represent a UNO type.  In all other cases, UnoType even works for such
     258                 :            :    C++ types that are unambiguously derived from one C++ type that represents a
     259                 :            :    UNO type.)  In addition to those C++ types that are mappings of UNO types
     260                 :            :    (except for sal_uInt16 and sal_Unicode, see below), the following C++ types
     261                 :            :    are appropriate as template arguments: cppu::UnoVoidType, bool,
     262                 :            :    cppu::UnoUnsignedShortType, cppu::UnoCharType, cppu::UnoSequenceType with any
     263                 :            :    appropriate template argument (the latter three to unambiguously specify UNO
     264                 :            :    types, as the UNO types UNSIGNED SHORT and CHAR map to the same C++ type),
     265                 :            :    and com::sun::star::uno::Reference with any appropriate template argument.
     266                 :            : 
     267                 :            :    @since UDK 3.2.2
     268                 :            : */
     269                 :            : template< typename T > class UnoType {
     270                 :            : public:
     271                 :  219487867 :     static inline ::com::sun::star::uno::Type const & get() {
     272                 :            :         using namespace ::cppu::detail;
     273                 :  219487867 :         return cppu_detail_getUnoType(static_cast< T * >(0));
     274                 :            :     }
     275                 :            : 
     276                 :            : private:
     277                 :            :     UnoType(UnoType &); // not defined
     278                 :            :     ~UnoType(); // not defined
     279                 :            :     void operator =(UnoType &); // not defined
     280                 :            : };
     281                 :            : 
     282                 :            : /**
     283                 :            :    A working replacement for getCppuType (see there).
     284                 :            : 
     285                 :            :    There are three overloads of this function that together form the replacement
     286                 :            :    of getCppuType.  The replacement has exactly the same semantics as
     287                 :            :    getCppuType, in that it returns correct results for the UNO type UNSIGNED
     288                 :            :    SHORT but not for the UNO type CHAR.
     289                 :            : 
     290                 :            :    @since UDK 3.2.2
     291                 :            : */
     292                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     293                 :   17278921 : getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *) {
     294                 :   17278921 :     return ::cppu::UnoType< T >::get();
     295                 :            : }
     296                 :            : 
     297                 :            : /**
     298                 :            :    A working replacement for getCppuType (see there).
     299                 :            : 
     300                 :            :    There are three overloads of this function that together form the replacement
     301                 :            :    of getCppuType.  The replacement has exactly the same semantics as
     302                 :            :    getCppuType, in that it returns correct results for the UNO type UNSIGNED
     303                 :            :    SHORT but not for the UNO type CHAR.
     304                 :            : 
     305                 :            :    @since UDK 3.2.2
     306                 :            : */
     307                 :            : inline ::com::sun::star::uno::Type const &
     308                 :      22186 : getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
     309                 :      22186 :     return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
     310                 :            : }
     311                 :            : 
     312                 :            : /**
     313                 :            :    A working replacement for getCppuType (see there).
     314                 :            : 
     315                 :            :    There are three overloads of this function that together form the replacement
     316                 :            :    of getCppuType.  The replacement has exactly the same semantics as
     317                 :            :    getCppuType, in that it returns correct results for the UNO type UNSIGNED
     318                 :            :    SHORT but not for the UNO type CHAR.
     319                 :            : 
     320                 :            :    @since UDK 3.2.2
     321                 :            : */
     322                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     323                 :            : getTypeFavourUnsigned(::com::sun::star::uno::Sequence< T > const *);
     324                 :            :     // defined in com/sun/star/uno/Sequence.hxx
     325                 :            : 
     326                 :            : /// @cond INTERNAL
     327                 :            : 
     328                 :            : /**
     329                 :            :    A working replacement for getCppuType (see there).
     330                 :            : 
     331                 :            :    There are three overloads of this function that together form the replacement
     332                 :            :    of the getCppuType template.  The replacement has exactly the same semantics
     333                 :            :    as the getCppuType template, in that it returns correct results for the UNO
     334                 :            :    type CHAR but not for the UNO type UNSIGNED SHORT.  Additionally, it also
     335                 :            :    returns the intended results for sequence types.
     336                 :            : 
     337                 :            :    @since UDK 3.2.3
     338                 :            : */
     339                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     340                 :       1098 : getTypeFavourChar(SAL_UNUSED_PARAMETER T const *) {
     341                 :       1098 :     return ::cppu::UnoType< T >::get();
     342                 :            : }
     343                 :            : 
     344                 :            : /**
     345                 :            :    A working replacement for getCppuType (see there).
     346                 :            : 
     347                 :            :    There are three overloads of this function that together form the replacement
     348                 :            :    of the getCppuType template.  The replacement has exactly the same semantics
     349                 :            :    as the getCppuType template, in that it returns correct results for the UNO
     350                 :            :    type CHAR but not for the UNO type UNSIGNED SHORT.  Additionally, it also
     351                 :            :    returns the intended results for sequence types.
     352                 :            : 
     353                 :            :    @since UDK 3.2.3
     354                 :            : */
     355                 :            : inline ::com::sun::star::uno::Type const &
     356                 :         65 : getTypeFavourChar(SAL_UNUSED_PARAMETER ::sal_Unicode const *) {
     357                 :         65 :     return ::cppu::UnoType< ::cppu::UnoCharType >::get();
     358                 :            : }
     359                 :            : 
     360                 :            : /**
     361                 :            :    A working replacement for getCppuType (see there).
     362                 :            : 
     363                 :            :    There are three overloads of this function that together form the replacement
     364                 :            :    of the getCppuType template.  The replacement has exactly the same semantics
     365                 :            :    as the getCppuType template, in that it returns correct results for the UNO
     366                 :            :    type CHAR but not for the UNO type UNSIGNED SHORT.  Additionally, it also
     367                 :            :    returns the intended results for sequence types.
     368                 :            : 
     369                 :            :    @since UDK 3.2.3
     370                 :            : */
     371                 :            : template< typename T > inline ::com::sun::star::uno::Type const &
     372                 :            : getTypeFavourChar(::com::sun::star::uno::Sequence< T > const *);
     373                 :            :     // defined in com/sun/star/uno/Sequence.hxx
     374                 :            : 
     375                 :            : /// @endcond
     376                 :            : 
     377                 :            : }
     378                 :            : 
     379                 :            : #endif
     380                 :            : 
     381                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10