LCOV - code coverage report
Current view: top level - include/com/sun/star/uno - Type.h (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 18 18 100.0 %
Date: 2014-11-03 Functions: 9 9 100.0 %
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 INCLUDED_COM_SUN_STAR_UNO_TYPE_H
      20             : #define INCLUDED_COM_SUN_STAR_UNO_TYPE_H
      21             : 
      22             : #include <typelib/typedescription.h>
      23             : #include <com/sun/star/uno/TypeClass.hdl>
      24             : #include <cppu/macros.hxx>
      25             : #include <rtl/ustring.hxx>
      26             : #include <rtl/alloc.h>
      27             : 
      28             : 
      29             : namespace com
      30             : {
      31             : namespace sun
      32             : {
      33             : namespace star
      34             : {
      35             : namespace uno
      36             : {
      37             : 
      38             : /** Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
      39             : */
      40             : enum UnoType_NoAcquire
      41             : {
      42             :     /** This enum value can be used for creating a Type object granting a given type description
      43             :         reference, i.e. transferring ownership to it.
      44             :     */
      45             :     UNO_TYPE_NO_ACQUIRE
      46             : };
      47             : 
      48             : /** C++ class representing an IDL meta type. This class is used to represent a a type,
      49             :     i.e. a type name and its type class.
      50             :     Internally the type holds a C type description reference of the runtime.
      51             :     You can obtain a full type description of a type by calling member function getDescription().
      52             : 
      53             :     @see typelib_TypeDescriptionReference
      54             : */
      55             : class SAL_WARN_UNUSED Type
      56             : {
      57             :     /** the C typelib reference pointer
      58             :     */
      59             :     typelib_TypeDescriptionReference * _pType;
      60             : 
      61             : public:
      62             :     /// @cond INTERNAL
      63             :     // these are here to force memory de/allocation to sal lib.
      64      129797 :     inline static void * SAL_CALL operator new ( size_t nSize )
      65      129797 :         { return ::rtl_allocateMemory( nSize ); }
      66             :     inline static void SAL_CALL operator delete ( void * pMem )
      67             :         { ::rtl_freeMemory( pMem ); }
      68             :     inline static void * SAL_CALL operator new ( size_t, void * pMem )
      69             :         { return pMem; }
      70             :     inline static void SAL_CALL operator delete ( void *, void * )
      71             :         {}
      72             :     /// @endcond
      73             : 
      74             :     /** Default Constructor: Type is set to void.
      75             :     */
      76             :     inline Type();
      77             : 
      78             :     /** Constructor: Type is constructed by given name and type class.
      79             : 
      80             :         @param eTypeClass type class of type
      81             :         @param rTypeName name of type
      82             :     */
      83             :     inline Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName );
      84             : 
      85             :     /** Constructor: Type is constructed by given name and type class.
      86             : 
      87             :         @param eTypeClass type class of type
      88             :         @param pTypeName name of type
      89             :     */
      90             :     inline Type( TypeClass eTypeClass, const sal_Char * pTypeName );
      91             : 
      92             :     /** Constructor: Type is (copy) constructed by given C type description reference.
      93             : 
      94             :         @param pType C type description reference
      95             :     */
      96             :     inline Type( typelib_TypeDescriptionReference * pType );
      97             : 
      98             :     /** Constructor: Type is (copy) constructed by given C type description reference
      99             :         without acquiring it.
     100             : 
     101             :         @param pType C type description reference
     102             :         @param dummy UNO_TYPE_NO_ACQUIRE to force obvious distinction to other constructors
     103             :     */
     104             :     inline Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire dummy );
     105             :     /** Constructor: Type is (copy) constructed by given C type description reference
     106             :         without acquiring it.
     107             : 
     108             :         @param pType C type description reference
     109             :         @param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors
     110             :     */
     111             :     inline Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire dummy );
     112             : 
     113             :     /** Copy constructor: Type is copy constructed by given type.
     114             : 
     115             :         @param rType another type
     116             :     */
     117             :     inline Type( const Type & rType );
     118             : 
     119             :     /** Destructor: Releases acquired C type description reference.
     120             :     */
     121    59827997 :     inline ~Type()
     122    59827997 :         { ::typelib_typedescriptionreference_release( _pType ); }
     123             : 
     124             :     /** Assignment operator: Acquires right side type and releases previously set type.
     125             : 
     126             :         @param rType another type (right side)
     127             :         @return this type
     128             :     */
     129             :     inline Type & SAL_CALL operator = ( const Type & rType );
     130             : 
     131             :     /** Gets the type class of set type.
     132             : 
     133             :         @return type class of set type
     134             :     */
     135    79403886 :     inline TypeClass SAL_CALL getTypeClass() const
     136    79403886 :         { return (TypeClass)_pType->eTypeClass; }
     137             : 
     138             :     /** Gets the name of the set type.
     139             : 
     140             :         @return name of the set type
     141             :     */
     142             :     inline ::rtl::OUString SAL_CALL getTypeName() const;
     143             : 
     144             :     /** Obtains a full type description of set type.
     145             : 
     146             :         @param ppDescr [inout] type description
     147             :     */
     148       22434 :     inline void SAL_CALL getDescription( typelib_TypeDescription ** ppDescr ) const
     149       22434 :         { ::typelib_typedescriptionreference_getDescription( ppDescr, _pType ); }
     150             : 
     151             :     /** Gets the C typelib type description reference pointer. Does not acquire the reference!
     152             : 
     153             :         @return UNacquired type description reference
     154             :     */
     155   475140535 :     inline typelib_TypeDescriptionReference * SAL_CALL getTypeLibType() const
     156   475140535 :         { return _pType; }
     157             : 
     158             :     /** Tests if values of this reflected type can be assigned by values of given type.
     159             :         This includes widening conversion (e.g., long assignable from short), as long as there
     160             :         is no data loss.
     161             : 
     162             :         @param rType another type
     163             :         @return true if values of this type can be assigned from values of given type,
     164             :                 false otherwise
     165             :     */
     166        2260 :     inline bool SAL_CALL isAssignableFrom( const Type & rType ) const
     167        2260 :         { return ::typelib_typedescriptionreference_isAssignableFrom( _pType, rType._pType ); }
     168             : 
     169             :     /** Compares two types.
     170             : 
     171             :         @param rType another type
     172             :         @return true if both types refer the same type, false otherwise
     173             :     */
     174     4141677 :     inline bool SAL_CALL equals( const Type & rType ) const
     175     4141677 :         { return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); }
     176             :     /** Equality operator: Compares two types.
     177             : 
     178             :         @param rType another type
     179             :         @return true if both types refer the same type, false otherwise
     180             :     */
     181   260924118 :     inline bool SAL_CALL operator == ( const Type & rType ) const
     182   260924118 :         { return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); }
     183             :     /** Unequality operator: Compares two types.
     184             : 
     185             :         @param rType another type
     186             :         @return false if both types refer the same type, true otherwise
     187             :     */
     188     1266926 :     inline bool SAL_CALL operator != ( const Type & rType ) const
     189     1266926 :         { return (! ::typelib_typedescriptionreference_equals( _pType, rType._pType )); }
     190             : };
     191             : 
     192             : /** Helper class to specify a type pointer for idl arrays.
     193             : */
     194             : template< class T >
     195             : class Array
     196             : {
     197             : public:
     198             :     static typelib_TypeDescriptionReference * s_pType;
     199             : };
     200             : 
     201             : }
     202             : }
     203             : }
     204             : }
     205             : 
     206             : /** Gets the meta type of IDL type "type".
     207             : 
     208             :     There are cases (involving templates) where uses of getCppuType are known to
     209             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     210             : 
     211             :     The dummy parameter is just a typed pointer for function signature.
     212             : 
     213             :     @return type of IDL type "type"
     214             : */
     215             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * );
     216             : 
     217             : /** Gets the meta type of IDL type void.
     218             :     @return type of IDL type void
     219             : */
     220             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType();
     221             : /** Gets the meta type of IDL type void.
     222             : 
     223             :     @return type of IDL type void
     224             : */
     225             : inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType();
     226             : 
     227             : /** Gets the meta type of IDL type boolean.
     228             : 
     229             :     @return type of IDL type boolean
     230             : */
     231             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType();
     232             : /** Gets the meta type of IDL type boolean.
     233             : 
     234             :     @return type of IDL type boolean
     235             : */
     236             : inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType();
     237             : /** Gets the meta type of IDL type boolean.
     238             : 
     239             :     There are cases (involving templates) where uses of getCppuType are known to
     240             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     241             : 
     242             :     The dummy parameter is just a typed pointer for function signature.
     243             : 
     244             :     @return type of IDL type boolean
     245             : */
     246             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * );
     247             : /** Gets the meta type of IDL type boolean.
     248             : 
     249             :     There are cases (involving templates) where uses of getCppuType are known to
     250             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     251             : 
     252             :     The dummy parameter is just a typed pointer for function signature.
     253             : 
     254             :     @return type of IDL type boolean
     255             : */
     256             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
     257             :     bool const * );
     258             : 
     259             : /** Gets the meta type of IDL type char.
     260             : 
     261             :     @return type of IDL type char
     262             : */
     263             : inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType();
     264             : /** Gets the meta type of IDL type char.
     265             : 
     266             :     @return type of IDL type char
     267             : */
     268             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType();
     269             : 
     270             : /** Gets the meta type of IDL type byte.
     271             : 
     272             :     There are cases (involving templates) where uses of getCppuType are known to
     273             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     274             : 
     275             :     The dummy parameter is just a typed pointer for function signature.
     276             : 
     277             :     @return type of IDL type byte
     278             : */
     279             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * );
     280             : 
     281             : /** Gets the meta type of IDL type string.
     282             : 
     283             :     There are cases (involving templates) where uses of getCppuType are known to
     284             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     285             : 
     286             :     The dummy parameter is just a typed pointer for function signature.
     287             : 
     288             :     @return type of IDL type string
     289             : */
     290             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * );
     291             : 
     292             : /** Gets the meta type of IDL type short.
     293             : 
     294             :     There are cases (involving templates) where uses of getCppuType are known to
     295             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     296             : 
     297             :     The dummy parameter is just a typed pointer for function signature.
     298             : 
     299             :     @return type of IDL type short
     300             : */
     301             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * );
     302             : 
     303             : /** Gets the meta type of IDL type unsigned short.
     304             : 
     305             :     There are cases (involving templates) where uses of getCppuType are known to
     306             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     307             : 
     308             :     The dummy parameter is just a typed pointer for function signature.
     309             : 
     310             :     @return type of IDL type unsigned short
     311             : */
     312             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * );
     313             : 
     314             : /** Gets the meta type of IDL type long.
     315             : 
     316             :     There are cases (involving templates) where uses of getCppuType are known to
     317             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     318             : 
     319             :     The dummy parameter is just a typed pointer for function signature.
     320             : 
     321             :     @return type of IDL type long
     322             : */
     323             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * );
     324             : 
     325             : /** Gets the meta type of IDL type unsigned long.
     326             : 
     327             :     There are cases (involving templates) where uses of getCppuType are known to
     328             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     329             : 
     330             :     The dummy parameter is just a typed pointer for function signature.
     331             : 
     332             :     @return type of IDL type unsigned long
     333             : */
     334             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * );
     335             : 
     336             : /** Gets the meta type of IDL type hyper.
     337             : 
     338             :     There are cases (involving templates) where uses of getCppuType are known to
     339             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     340             : 
     341             :     The dummy parameter is just a typed pointer for function signature.
     342             : 
     343             :     @return type of IDL type hyper
     344             : */
     345             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * );
     346             : 
     347             : /** Gets the meta type of IDL type unsigned hyper.
     348             : 
     349             :     There are cases (involving templates) where uses of getCppuType are known to
     350             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     351             : 
     352             :     The dummy parameter is just a typed pointer for function signature.
     353             : 
     354             :     @return type of IDL type unsigned hyper
     355             : */
     356             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * );
     357             : 
     358             : /** Gets the meta type of IDL type float.
     359             : 
     360             :     There are cases (involving templates) where uses of getCppuType are known to
     361             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     362             : 
     363             :     The dummy parameter is just a typed pointer for function signature.
     364             : 
     365             :     @return type of IDL type float
     366             : */
     367             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * );
     368             : 
     369             : /** Gets the meta type of IDL type double.
     370             : 
     371             :     There are cases (involving templates) where uses of getCppuType are known to
     372             :     not compile.  Use cppu::UnoType or cppu::getTypeFavourUnsigned instead.
     373             : 
     374             :     The dummy parameter is just a typed pointer for function signature.
     375             : 
     376             :     @return type of IDL type double
     377             : */
     378             : inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * );
     379             : 
     380             : /** Gets the meta type of an IDL type.
     381             : 
     382             :     The difference between this function template (with a type parameter) and
     383             :     the overloaded getCppuType function with a single (dummy) parameter of a
     384             :     specific type is that this function template may not work for the UNO type
     385             :     "unsigned short" (sal_uInt16 in C++), while the overloaded one-parameter
     386             :     function may not work for the UNO type "char" (sal_Unicode in C++, which may
     387             :     have the same underlying C++ type as sal_uInt16 on certain platforms).
     388             : 
     389             :     @return type of the given IDL type
     390             : 
     391             :     @deprecated
     392             :     Use cppu::UnoType instead (or the internal-only cppu::getTypeFavourChar).
     393             :     Also note that getCppuType< com::sun::star::uno::Sequence< sal_Unicode > >()
     394             :     does not work as expected.
     395             : 
     396             :     @since UDK 3.2.0
     397             : */
     398             : template< typename T > inline const ::com::sun::star::uno::Type & SAL_CALL
     399             : getCppuType();
     400             : 
     401             : /** Gets the meta type of IDL type char.
     402             : 
     403             :     @return type of IDL type char
     404             : 
     405             :     @deprecated
     406             :     Use cppu::UnoType instead (or the internal-only cppu::getTypeFavourChar).
     407             :     Also note that getCppuType< com::sun::star::uno::Sequence< sal_Unicode > >()
     408             :     does not work as expected.
     409             : 
     410             :     @since UDK 3.2.0
     411             : */
     412             : template<> inline const ::com::sun::star::uno::Type & SAL_CALL
     413             : getCppuType< sal_Unicode >();
     414             : 
     415             : #endif
     416             : 
     417             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10