1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
20 #define _TYPELIB_TYPEDESCRIPTION_HXX_
22 #include <rtl/alloc.h>
23 #include <rtl/ustring.hxx>
24 #include <com/sun/star/uno/Type.h>
25 #include <typelib/typedescription.h>
37 /** C++ wrapper for typelib_TypeDescription.
38 Constructors by name, type, type description reference will get the full type description.
40 @see typelib_TypeDescription
44 /** C typelib type description
46 mutable typelib_TypeDescription
* _pTypeDescr
;
50 // these are here to force memory de/allocation to sal lib.
51 inline static void * SAL_CALL
operator new ( size_t nSize
) SAL_THROW(())
52 { return ::rtl_allocateMemory( nSize
); }
53 inline static void SAL_CALL
operator delete ( void * pMem
) SAL_THROW(())
54 { ::rtl_freeMemory( pMem
); }
55 inline static void * SAL_CALL
operator new ( size_t, void * pMem
) SAL_THROW(())
57 inline static void SAL_CALL
operator delete ( void *, void * ) SAL_THROW(())
63 @param pTypeDescr a type description
65 inline TypeDescription( typelib_TypeDescription
* pTypeDescr
= 0 ) SAL_THROW(());
68 @param pTypeDescrRef a type description reference
70 inline TypeDescription( typelib_TypeDescriptionReference
* pTypeDescrRef
) SAL_THROW(());
75 inline TypeDescription( const ::com::sun::star::uno::Type
& rType
) SAL_THROW(());
78 @param rDescr another TypeDescription
80 inline TypeDescription( const TypeDescription
& rDescr
) SAL_THROW(());
83 @param pTypeName a type name
85 inline TypeDescription( rtl_uString
* pTypeName
) SAL_THROW(());
88 @param rTypeName a type name
90 inline TypeDescription( const ::rtl::OUString
& rTypeName
) SAL_THROW(());
91 /** Destructor: releases type description
93 inline ~TypeDescription() SAL_THROW(());
95 /** Assignment operator: acquires given type description and releases a set one.
97 @param pTypeDescr another type description
98 @return this TypeDescription
100 inline TypeDescription
& SAL_CALL
operator = ( typelib_TypeDescription
* pTypeDescr
) SAL_THROW(());
101 /** Assignment operator: acquires given type description and releases a set one.
103 @param rTypeDescr another type description
104 @return this TypeDescription
106 inline TypeDescription
& SAL_CALL
operator =( const TypeDescription
& rTypeDescr
) SAL_THROW(())
107 { return this->operator =( rTypeDescr
.get() ); }
109 /** Tests whether two type descriptions are equal.
111 @param pTypeDescr another type description
112 @return true, if both type descriptions are equal, false otherwise
114 inline sal_Bool SAL_CALL
equals( const typelib_TypeDescription
* pTypeDescr
) const SAL_THROW(());
115 /** Tests whether two type descriptions are equal.
117 @param rTypeDescr another type description
118 @return true, if both type descriptions are equal, false otherwise
120 inline sal_Bool SAL_CALL
equals( const TypeDescription
& rTypeDescr
) const SAL_THROW(())
121 { return equals( rTypeDescr
._pTypeDescr
); }
123 /** Makes stored type description complete.
125 inline void SAL_CALL
makeComplete() const SAL_THROW(());
127 /** Gets the UNacquired type description pointer.
129 @return stored pointer of type description
131 inline typelib_TypeDescription
* SAL_CALL
get() const SAL_THROW(())
132 { return _pTypeDescr
; }
133 /** Tests if a type description is set.
135 @return true, if a type description is set, false otherwise
137 inline sal_Bool SAL_CALL
is() const SAL_THROW(())
138 { return (_pTypeDescr
!= 0); }
140 //__________________________________________________________________________________________________
141 inline TypeDescription::TypeDescription( typelib_TypeDescription
* pTypeDescr
) SAL_THROW(())
142 : _pTypeDescr( pTypeDescr
)
145 typelib_typedescription_acquire( _pTypeDescr
);
147 //__________________________________________________________________________________________________
148 inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference
* pTypeDescrRef
) SAL_THROW(())
152 typelib_typedescriptionreference_getDescription( &_pTypeDescr
, pTypeDescrRef
);
154 //__________________________________________________________________________________________________
155 inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type
& rType
) SAL_THROW(())
158 if (rType
.getTypeLibType())
159 typelib_typedescriptionreference_getDescription( &_pTypeDescr
, rType
.getTypeLibType() );
161 //__________________________________________________________________________________________________
162 inline TypeDescription::TypeDescription( const TypeDescription
& rTypeDescr
) SAL_THROW(())
163 : _pTypeDescr( rTypeDescr
._pTypeDescr
)
166 typelib_typedescription_acquire( _pTypeDescr
);
168 //__________________________________________________________________________________________________
169 inline TypeDescription::TypeDescription( rtl_uString
* pTypeName
) SAL_THROW(())
172 typelib_typedescription_getByName( &_pTypeDescr
, pTypeName
);
174 //__________________________________________________________________________________________________
175 inline TypeDescription::TypeDescription( const ::rtl::OUString
& rTypeName
) SAL_THROW(())
178 typelib_typedescription_getByName( &_pTypeDescr
, rTypeName
.pData
);
180 //__________________________________________________________________________________________________
181 inline TypeDescription::~TypeDescription() SAL_THROW(())
184 typelib_typedescription_release( _pTypeDescr
);
186 //__________________________________________________________________________________________________
187 inline TypeDescription
& TypeDescription::operator = ( typelib_TypeDescription
* pTypeDescr
) SAL_THROW(())
190 typelib_typedescription_acquire( pTypeDescr
);
192 typelib_typedescription_release( _pTypeDescr
);
193 _pTypeDescr
= pTypeDescr
;
196 //__________________________________________________________________________________________________
197 inline sal_Bool
TypeDescription::equals( const typelib_TypeDescription
* pTypeDescr
) const SAL_THROW(())
199 return (_pTypeDescr
&& pTypeDescr
&&
200 typelib_typedescription_equals( _pTypeDescr
, pTypeDescr
));
202 //__________________________________________________________________________________________________
203 inline void TypeDescription::makeComplete() const SAL_THROW(())
205 if (_pTypeDescr
&& !_pTypeDescr
->bComplete
)
206 ::typelib_typedescription_complete( &_pTypeDescr
);
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */