LCOV - code coverage report
Current view: top level - include/typelib - typedescription.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 50 54 92.6 %
Date: 2014-11-03 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     2034737 :     inline TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr )
     107     2034737 :         { 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       47988 :     inline bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const
     121       47988 :         { 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    26362707 :     inline typelib_TypeDescription * SAL_CALL get() const
     132    26362707 :         { return _pTypeDescr; }
     133             :     /** Tests if a type description is set.
     134             : 
     135             :         @return true, if a type description is set, false otherwise
     136             :     */
     137     1002672 :     inline bool SAL_CALL is() const
     138     1002672 :         { return (_pTypeDescr != 0); }
     139             : };
     140             : 
     141     2214668 : inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr )
     142     2214668 :     : _pTypeDescr( pTypeDescr )
     143             : {
     144     2214668 :     if (_pTypeDescr)
     145       47911 :         typelib_typedescription_acquire( _pTypeDescr );
     146     2214668 : }
     147             : 
     148     3529809 : inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef )
     149     3529809 :     : _pTypeDescr( 0 )
     150             : {
     151     3529809 :     if (pTypeDescrRef)
     152     3529809 :         typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
     153     3529810 : }
     154             : 
     155      640153 : inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType )
     156      640153 :     : _pTypeDescr( 0 )
     157             : {
     158      640153 :     if (rType.getTypeLibType())
     159      640153 :         typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
     160      640154 : }
     161             : 
     162     2977478 : inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr )
     163     2977478 :     : _pTypeDescr( rTypeDescr._pTypeDescr )
     164             : {
     165     2977478 :     if (_pTypeDescr)
     166     2543128 :         typelib_typedescription_acquire( _pTypeDescr );
     167     2977482 : }
     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       37540 : inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName )
     176       37540 :     : _pTypeDescr( 0 )
     177             : {
     178       37540 :     typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
     179       37540 : }
     180             : 
     181     9397627 : inline TypeDescription::~TypeDescription()
     182             : {
     183     9397627 :     if (_pTypeDescr)
     184     8140808 :         typelib_typedescription_release( _pTypeDescr );
     185     9398212 : }
     186             : 
     187     2034737 : inline TypeDescription & TypeDescription::operator = ( typelib_TypeDescription * pTypeDescr )
     188             : {
     189     2034737 :     if (pTypeDescr)
     190     1628669 :         typelib_typedescription_acquire( pTypeDescr );
     191     2034737 :     if (_pTypeDescr)
     192      284349 :         typelib_typedescription_release( _pTypeDescr );
     193     2034737 :     _pTypeDescr = pTypeDescr;
     194     2034737 :     return *this;
     195             : }
     196             : 
     197       47988 : inline bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const
     198             : {
     199       95976 :     return (_pTypeDescr && pTypeDescr &&
     200       95976 :             typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
     201             : }
     202             : 
     203     2930007 : inline void TypeDescription::makeComplete() const
     204             : {
     205     2930007 :     if (_pTypeDescr && !_pTypeDescr->bComplete)
     206         512 :         ::typelib_typedescription_complete( &_pTypeDescr );
     207     2930007 : }
     208             : 
     209             : }
     210             : }
     211             : }
     212             : }
     213             : 
     214             : #endif
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10