UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 #ifndef _TYPELIB_TYPEDESCRIPTION_HXX_ 00029 #define _TYPELIB_TYPEDESCRIPTION_HXX_ 00030 00031 #include <rtl/alloc.h> 00032 #include <rtl/ustring.hxx> 00033 #include <com/sun/star/uno/Type.h> 00034 #include <typelib/typedescription.h> 00035 00036 00037 namespace com 00038 { 00039 namespace sun 00040 { 00041 namespace star 00042 { 00043 namespace uno 00044 { 00045 00051 class TypeDescription 00052 { 00055 mutable typelib_TypeDescription * _pTypeDescr; 00056 00057 public: 00059 // these are here to force memory de/allocation to sal lib. 00060 inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(()) 00061 { return ::rtl_allocateMemory( nSize ); } 00062 inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(()) 00063 { ::rtl_freeMemory( pMem ); } 00064 inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(()) 00065 { return pMem; } 00066 inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(()) 00067 {} 00069 00074 inline TypeDescription( typelib_TypeDescription * pTypeDescr = 0 ) SAL_THROW(()); 00079 inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ) SAL_THROW(()); 00084 inline TypeDescription( const ::com::sun::star::uno::Type & rType ) SAL_THROW(()); 00089 inline TypeDescription( const TypeDescription & rDescr ) SAL_THROW(()); 00094 inline TypeDescription( rtl_uString * pTypeName ) SAL_THROW(()); 00099 inline TypeDescription( const ::rtl::OUString & rTypeName ) SAL_THROW(()); 00102 inline ~TypeDescription() SAL_THROW(()); 00103 00109 inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr ) SAL_THROW(()); 00115 inline TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr ) SAL_THROW(()) 00116 { return this->operator =( rTypeDescr.get() ); } 00117 00123 inline sal_Bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const SAL_THROW(()); 00129 inline sal_Bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const SAL_THROW(()) 00130 { return equals( rTypeDescr._pTypeDescr ); } 00131 00134 inline void SAL_CALL makeComplete() const SAL_THROW(()); 00135 00140 inline typelib_TypeDescription * SAL_CALL get() const SAL_THROW(()) 00141 { return _pTypeDescr; } 00146 inline sal_Bool SAL_CALL is() const SAL_THROW(()) 00147 { return (_pTypeDescr != 0); } 00148 }; 00149 //__________________________________________________________________________________________________ 00150 inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr ) SAL_THROW(()) 00151 : _pTypeDescr( pTypeDescr ) 00152 { 00153 if (_pTypeDescr) 00154 typelib_typedescription_acquire( _pTypeDescr ); 00155 } 00156 //__________________________________________________________________________________________________ 00157 inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ) SAL_THROW(()) 00158 : _pTypeDescr( 0 ) 00159 { 00160 if (pTypeDescrRef) 00161 typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef ); 00162 } 00163 //__________________________________________________________________________________________________ 00164 inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType ) SAL_THROW(()) 00165 : _pTypeDescr( 0 ) 00166 { 00167 if (rType.getTypeLibType()) 00168 typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() ); 00169 } 00170 //__________________________________________________________________________________________________ 00171 inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr ) SAL_THROW(()) 00172 : _pTypeDescr( rTypeDescr._pTypeDescr ) 00173 { 00174 if (_pTypeDescr) 00175 typelib_typedescription_acquire( _pTypeDescr ); 00176 } 00177 //__________________________________________________________________________________________________ 00178 inline TypeDescription::TypeDescription( rtl_uString * pTypeName ) SAL_THROW(()) 00179 : _pTypeDescr( 0 ) 00180 { 00181 typelib_typedescription_getByName( &_pTypeDescr , pTypeName ); 00182 } 00183 //__________________________________________________________________________________________________ 00184 inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName ) SAL_THROW(()) 00185 : _pTypeDescr( 0 ) 00186 { 00187 typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData ); 00188 } 00189 //__________________________________________________________________________________________________ 00190 inline TypeDescription::~TypeDescription() SAL_THROW(()) 00191 { 00192 if (_pTypeDescr) 00193 typelib_typedescription_release( _pTypeDescr ); 00194 } 00195 //__________________________________________________________________________________________________ 00196 inline TypeDescription & TypeDescription::operator = ( typelib_TypeDescription * pTypeDescr ) SAL_THROW(()) 00197 { 00198 if (pTypeDescr) 00199 typelib_typedescription_acquire( pTypeDescr ); 00200 if (_pTypeDescr) 00201 typelib_typedescription_release( _pTypeDescr ); 00202 _pTypeDescr = pTypeDescr; 00203 return *this; 00204 } 00205 //__________________________________________________________________________________________________ 00206 inline sal_Bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const SAL_THROW(()) 00207 { 00208 return (_pTypeDescr && pTypeDescr && 00209 typelib_typedescription_equals( _pTypeDescr, pTypeDescr )); 00210 } 00211 //__________________________________________________________________________________________________ 00212 inline void TypeDescription::makeComplete() const SAL_THROW(()) 00213 { 00214 if (_pTypeDescr && !_pTypeDescr->bComplete) 00215 ::typelib_typedescription_complete( &_pTypeDescr ); 00216 } 00217 00218 } 00219 } 00220 } 00221 } 00222 00223 #endif 00224 00225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */