My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
typedescription.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
29 #define _TYPELIB_TYPEDESCRIPTION_HXX_
30 
31 #include <rtl/alloc.h>
32 #include <rtl/ustring.hxx>
33 #include <com/sun/star/uno/Type.h>
35 
36 
37 namespace com
38 {
39 namespace sun
40 {
41 namespace star
42 {
43 namespace uno
44 {
45 
52 {
55  mutable typelib_TypeDescription * _pTypeDescr;
56 
57 public:
59  // these are here to force memory de/allocation to sal lib.
60  inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
61  { return ::rtl_allocateMemory( nSize ); }
62  inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
63  { ::rtl_freeMemory( pMem ); }
64  inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
65  { return pMem; }
66  inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
67  {}
69 
74  inline TypeDescription( typelib_TypeDescription * pTypeDescr = 0 ) SAL_THROW(());
79  inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ) SAL_THROW(());
84  inline TypeDescription( const ::com::sun::star::uno::Type & rType ) SAL_THROW(());
89  inline TypeDescription( const TypeDescription & rDescr ) SAL_THROW(());
94  inline TypeDescription( rtl_uString * pTypeName ) SAL_THROW(());
99  inline TypeDescription( const ::rtl::OUString & rTypeName ) SAL_THROW(());
102  inline ~TypeDescription() SAL_THROW(());
103 
109  inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
115  inline TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr ) SAL_THROW(())
116  { return this->operator =( rTypeDescr.get() ); }
117 
123  inline sal_Bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const SAL_THROW(());
129  inline sal_Bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const SAL_THROW(())
130  { return equals( rTypeDescr._pTypeDescr ); }
131 
134  inline void SAL_CALL makeComplete() const SAL_THROW(());
135 
140  inline typelib_TypeDescription * SAL_CALL get() const SAL_THROW(())
141  { return _pTypeDescr; }
146  inline sal_Bool SAL_CALL is() const SAL_THROW(())
147  { return (_pTypeDescr != 0); }
148 };
149 //__________________________________________________________________________________________________
151  : _pTypeDescr( pTypeDescr )
152 {
153  if (_pTypeDescr)
154  typelib_typedescription_acquire( _pTypeDescr );
155 }
156 //__________________________________________________________________________________________________
158  : _pTypeDescr( 0 )
159 {
160  if (pTypeDescrRef)
161  typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
162 }
163 //__________________________________________________________________________________________________
164 inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType ) SAL_THROW(())
165  : _pTypeDescr( 0 )
166 {
167  if (rType.getTypeLibType())
168  typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
169 }
170 //__________________________________________________________________________________________________
172  : _pTypeDescr( rTypeDescr._pTypeDescr )
173 {
174  if (_pTypeDescr)
175  typelib_typedescription_acquire( _pTypeDescr );
176 }
177 //__________________________________________________________________________________________________
178 inline TypeDescription::TypeDescription( rtl_uString * pTypeName ) SAL_THROW(())
179  : _pTypeDescr( 0 )
180 {
181  typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
182 }
183 //__________________________________________________________________________________________________
184 inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName ) SAL_THROW(())
185  : _pTypeDescr( 0 )
186 {
187  typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
188 }
189 //__________________________________________________________________________________________________
190 inline TypeDescription::~TypeDescription() SAL_THROW(())
191 {
192  if (_pTypeDescr)
193  typelib_typedescription_release( _pTypeDescr );
194 }
195 //__________________________________________________________________________________________________
197 {
198  if (pTypeDescr)
199  typelib_typedescription_acquire( pTypeDescr );
200  if (_pTypeDescr)
201  typelib_typedescription_release( _pTypeDescr );
202  _pTypeDescr = pTypeDescr;
203  return *this;
204 }
205 //__________________________________________________________________________________________________
207 {
208  return (_pTypeDescr && pTypeDescr &&
209  typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
210 }
211 //__________________________________________________________________________________________________
212 inline void TypeDescription::makeComplete() const SAL_THROW(())
213 {
214  if (_pTypeDescr && !_pTypeDescr->bComplete)
215  ::typelib_typedescription_complete( &_pTypeDescr );
216 }
217 
218 }
219 }
220 }
221 }
222 
223 #endif
224 
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */