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

Generated by: LCOV version 1.11