LCOV - code coverage report
Current view: top level - include/typelib - typedescription.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 50 54 92.6 %
Date: 2015-06-13 12:38:46 Functions: 13 14 92.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 INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
      20             : #define INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
      21             : 
      22             : #include <rtl/alloc.h>
      23             : #include <rtl/ustring.hxx>
      24             : #include <com/sun/star/uno/Type.h>
      25             : #include <typelib/typedescription.h>
      26             : 
      27             : 
      28             : namespace com
      29             : {
      30             : namespace sun
      31             : {
      32             : namespace star
      33             : {
      34             : namespace uno
      35             : {
      36             : 
      37             : /** C++ wrapper for typelib_TypeDescription.
      38             :     Constructors by name, type, type description reference will get the full type description.
      39             : 
      40             :     @see typelib_TypeDescription
      41             : */
      42             : class TypeDescription
      43             : {
      44             :     /** C typelib type description
      45             :     */
      46             :     mutable typelib_TypeDescription * _pTypeDescr;
      47             : 
      48             : public:
      49             :     /// @cond INTERNAL
      50             :     // these are here to force memory de/allocation to sal lib.
      51             :     inline static void * SAL_CALL operator new ( size_t nSize )
      52             :         { return ::rtl_allocateMemory( nSize ); }
      53             :     inline static void SAL_CALL operator delete ( void * pMem )
      54             :         { ::rtl_freeMemory( pMem ); }
      55             :     inline static void * SAL_CALL operator new ( size_t, void * pMem )
      56             :         { return pMem; }
      57             :     inline static void SAL_CALL operator delete ( void *, void * )
      58             :         {}
      59             :     /// @endcond
      60             : 
      61             :     /** Constructor:
      62             : 
      63             :         @param pTypeDescr a type description
      64             :     */
      65             :     inline TypeDescription( typelib_TypeDescription * pTypeDescr = 0 );
      66             :     /** Constructor:
      67             : 
      68             :         @param pTypeDescrRef a type description reference
      69             :     */
      70             :     inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef );
      71             :     /** Constructor:
      72             : 
      73             :         @param rType a type
      74             :     */
      75             :     inline TypeDescription( const ::com::sun::star::uno::Type & rType );
      76             :     /** Copy constructor:
      77             : 
      78             :         @param rDescr another TypeDescription
      79             :     */
      80             :     inline TypeDescription( const TypeDescription & rDescr );
      81             :     /** Constructor:
      82             : 
      83             :         @param pTypeName a type name
      84             :     */
      85             :     inline TypeDescription( rtl_uString * pTypeName );
      86             :     /** Constructor:
      87             : 
      88             :         @param rTypeName a type name
      89             :     */
      90             :     inline TypeDescription( const ::rtl::OUString & rTypeName );
      91             :     /** Destructor: releases type description
      92             :     */
      93             :     inline ~TypeDescription();
      94             : 
      95             :     /** Assignment operator: acquires given type description and releases a set one.
      96             : 
      97             :         @param pTypeDescr another type description
      98             :         @return this TypeDescription
      99             :     */
     100             :     inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr );
     101             :     /** Assignment operator: acquires given type description and releases a set one.
     102             : 
     103             :         @param rTypeDescr another type description
     104             :         @return this TypeDescription
     105             :     */
     106     1059554 :     inline TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr )
     107     1059554 :         { return this->operator =( rTypeDescr.get() ); }
     108             : 
     109             :     /** Tests whether two type descriptions are equal.
     110             : 
     111             :         @param pTypeDescr another type description
     112             :         @return true, if both type descriptions are equal, false otherwise
     113             :     */
     114             :     inline bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const;
     115             :     /** Tests whether two type descriptions are equal.
     116             : 
     117             :         @param rTypeDescr another type description
     118             :         @return true, if both type descriptions are equal, false otherwise
     119             :     */
     120       24079 :     inline bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const
     121       24079 :         { return equals( rTypeDescr._pTypeDescr ); }
     122             : 
     123             :     /** Makes stored type description complete.
     124             :     */
     125             :     inline void SAL_CALL makeComplete() const;
     126             : 
     127             :     /** Gets the UNacquired type description pointer.
     128             : 
     129             :         @return stored pointer of type description
     130             :     */
     131    14805584 :     inline typelib_TypeDescription * SAL_CALL get() const
     132    14805584 :         { return _pTypeDescr; }
     133             :     /** Tests if a type description is set.
     134             : 
     135             :         @return true, if a type description is set, false otherwise
     136             :     */
     137      517918 :     inline bool SAL_CALL is() const
     138      517918 :         { return (_pTypeDescr != 0); }
     139             : };
     140             : 
     141     1163711 : inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr )
     142     1163711 :     : _pTypeDescr( pTypeDescr )
     143             : {
     144     1163711 :     if (_pTypeDescr)
     145       26091 :         typelib_typedescription_acquire( _pTypeDescr );
     146     1163711 : }
     147             : 
     148     2540215 : inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef )
     149     2540215 :     : _pTypeDescr( 0 )
     150             : {
     151     2540215 :     if (pTypeDescrRef)
     152     2540216 :         typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
     153     2540214 : }
     154             : 
     155      343678 : inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType )
     156      343678 :     : _pTypeDescr( 0 )
     157             : {
     158      343678 :     if (rType.getTypeLibType())
     159      343678 :         typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
     160      343678 : }
     161             : 
     162     1541655 : inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr )
     163     1541655 :     : _pTypeDescr( rTypeDescr._pTypeDescr )
     164             : {
     165     1541655 :     if (_pTypeDescr)
     166     1312898 :         typelib_typedescription_acquire( _pTypeDescr );
     167     1541667 : }
     168             : 
     169           0 : inline TypeDescription::TypeDescription( rtl_uString * pTypeName )
     170           0 :     : _pTypeDescr( 0 )
     171             : {
     172           0 :     typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
     173           0 : }
     174             : 
     175       19944 : inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName )
     176       19944 :     : _pTypeDescr( 0 )
     177             : {
     178       19944 :     typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
     179       19944 : }
     180             : 
     181     5608364 : inline TypeDescription::~TypeDescription()
     182             : {
     183     5608364 :     if (_pTypeDescr)
     184     4942288 :         typelib_typedescription_release( _pTypeDescr );
     185     5608614 : }
     186             : 
     187     1059550 : inline TypeDescription & TypeDescription::operator = ( typelib_TypeDescription * pTypeDescr )
     188             : {
     189     1059550 :     if (pTypeDescr)
     190      845073 :         typelib_typedescription_acquire( pTypeDescr );
     191     1059562 :     if (_pTypeDescr)
     192      144587 :         typelib_typedescription_release( _pTypeDescr );
     193     1059562 :     _pTypeDescr = pTypeDescr;
     194     1059562 :     return *this;
     195             : }
     196             : 
     197       24079 : inline bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const
     198             : {
     199       48158 :     return (_pTypeDescr && pTypeDescr &&
     200       48158 :             typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
     201             : }
     202             : 
     203     1468029 : inline void TypeDescription::makeComplete() const
     204             : {
     205     1468029 :     if (_pTypeDescr && !_pTypeDescr->bComplete)
     206         320 :         ::typelib_typedescription_complete( &_pTypeDescr );
     207     1468029 : }
     208             : 
     209             : }
     210             : }
     211             : }
     212             : }
     213             : 
     214             : #endif
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11