LibreOffice LibreOffice 4.3 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

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 * 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
42 class TypeDescription
43 {
46 mutable typelib_TypeDescription * _pTypeDescr;
47
48 public:
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(())
56 { return pMem; }
57 inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
58 {}
60
65 inline TypeDescription( typelib_TypeDescription * pTypeDescr = 0 ) SAL_THROW(());
70 inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ) SAL_THROW(());
75 inline TypeDescription( const ::com::sun::star::uno::Type & rType ) SAL_THROW(());
80 inline TypeDescription( const TypeDescription & rDescr ) SAL_THROW(());
85 inline TypeDescription( rtl_uString * pTypeName ) SAL_THROW(());
90 inline TypeDescription( const ::rtl::OUString & rTypeName ) SAL_THROW(());
93 inline ~TypeDescription() SAL_THROW(());
94
100 inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
106 inline TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr ) SAL_THROW(())
107 { return this->operator =( rTypeDescr.get() ); }
108
114 inline bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const SAL_THROW(());
120 inline bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const SAL_THROW(())
121 { return equals( rTypeDescr._pTypeDescr ); }
122
125 inline void SAL_CALL makeComplete() const SAL_THROW(());
126
131 inline typelib_TypeDescription * SAL_CALL get() const SAL_THROW(())
132 { return _pTypeDescr; }
137 inline bool SAL_CALL is() const SAL_THROW(())
138 { return (_pTypeDescr != 0); }
139 };
140
141 inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
142 : _pTypeDescr( pTypeDescr )
143 {
144 if (_pTypeDescr)
145 typelib_typedescription_acquire( _pTypeDescr );
146 }
147
148 inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ) SAL_THROW(())
149 : _pTypeDescr( 0 )
150 {
151 if (pTypeDescrRef)
152 typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
153 }
154
155 inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType ) SAL_THROW(())
156 : _pTypeDescr( 0 )
157 {
158 if (rType.getTypeLibType())
159 typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
160 }
161
162 inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr ) SAL_THROW(())
163 : _pTypeDescr( rTypeDescr._pTypeDescr )
164 {
165 if (_pTypeDescr)
166 typelib_typedescription_acquire( _pTypeDescr );
167 }
168
169 inline TypeDescription::TypeDescription( rtl_uString * pTypeName ) SAL_THROW(())
170 : _pTypeDescr( 0 )
171 {
172 typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
173 }
174
175 inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName ) SAL_THROW(())
176 : _pTypeDescr( 0 )
177 {
178 typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
179 }
180
181 inline TypeDescription::~TypeDescription() SAL_THROW(())
182 {
183 if (_pTypeDescr)
184 typelib_typedescription_release( _pTypeDescr );
185 }
186
187 inline TypeDescription & TypeDescription::operator = ( typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
188 {
189 if (pTypeDescr)
190 typelib_typedescription_acquire( pTypeDescr );
191 if (_pTypeDescr)
192 typelib_typedescription_release( _pTypeDescr );
193 _pTypeDescr = pTypeDescr;
194 return *this;
195 }
196
197 inline bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const SAL_THROW(())
198 {
199 return (_pTypeDescr && pTypeDescr &&
200 typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
201 }
202
203 inline void TypeDescription::makeComplete() const SAL_THROW(())
204 {
205 if (_pTypeDescr && !_pTypeDescr->bComplete)
206 ::typelib_typedescription_complete( &_pTypeDescr );
207 }
208
209 }
210 }
211 }
212 }
213
214 #endif
215
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
com::sun::star::uno::TypeDescription::get
typelib_TypeDescription * get() const SAL_THROW(())
Gets the UNacquired type description pointer.
Definition: typedescription.hxx:131
alloc.h
com::sun::star::uno::TypeDescription::makeComplete
void makeComplete() const SAL_THROW(())
Makes stored type description complete.
Definition: typedescription.hxx:203
typelib_typedescription_complete
CPPU_DLLPUBLIC sal_Bool typelib_typedescription_complete(typelib_TypeDescription **ppTypeDescr) SAL_THROW_EXTERN_C()
Completes a typedescription to be used for, e.g., marshalling values.
com::sun::star::uno::TypeDescription::TypeDescription
TypeDescription(typelib_TypeDescription *pTypeDescr=0) SAL_THROW(())
Constructor:
Definition: typedescription.hxx:141
rtl_allocateMemory
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
_typelib_TypeDescription::bComplete
sal_Bool bComplete
flag to determine whether the description is complete: compound types lack of member names...
Definition: typedescription.h:102
typelib_typedescriptionreference_getDescription
CPPU_DLLPUBLIC void typelib_typedescriptionreference_getDescription(typelib_TypeDescription **ppRet, typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
Retrieves the type description for a given reference.
_typelib_TypeDescriptionReference
Holds a weak reference to a type description.
Definition: typedescription.h:40
com::sun::star::uno::TypeDescription::equals
bool equals(const TypeDescription &rTypeDescr) const SAL_THROW(())
Tests whether two type descriptions are equal.
Definition: typedescription.hxx:120
typelib_typedescription_acquire
CPPU_DLLPUBLIC void typelib_typedescription_acquire(typelib_TypeDescription *pDesc) SAL_THROW_EXTERN_C()
Increments reference count of given type description.
SAL_THROW
#define SAL_THROW(x)
Exception specification documentation.
Definition: types.h:361
_typelib_TypeDescription
Full type description of a type.
Definition: typedescription.h:71
typelib_typedescription_equals
CPPU_DLLPUBLIC sal_Bool typelib_typedescription_equals(const typelib_TypeDescription *p1, const typelib_TypeDescription *p2) SAL_THROW_EXTERN_C()
Tests whether two types descriptions are equal, i.e.
typelib_typedescription_getByName
CPPU_DLLPUBLIC void typelib_typedescription_getByName(typelib_TypeDescription **ppRet, rtl_uString *pName) SAL_THROW_EXTERN_C()
Retrieves a type description via its fully qualified name.
typelib_typedescription_release
CPPU_DLLPUBLIC void typelib_typedescription_release(typelib_TypeDescription *pDesc) SAL_THROW_EXTERN_C()
Decrements reference count of given type.
com::sun::star::uno::TypeDescription::is
bool is() const SAL_THROW(())
Tests if a type description is set.
Definition: typedescription.hxx:137
typedescription.h
com::sun::star::uno::TypeDescription::operator=
TypeDescription & operator=(typelib_TypeDescription *pTypeDescr) SAL_THROW(())
Assignment operator: acquires given type description and releases a set one.
Definition: typedescription.hxx:187
com::sun::star::uno::TypeDescription::equals
bool equals(const typelib_TypeDescription *pTypeDescr) const SAL_THROW(())
Tests whether two type descriptions are equal.
Definition: typedescription.hxx:197
rtl_freeMemory
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
ustring.hxx
com::sun::star::uno::TypeDescription
C++ wrapper for typelib_TypeDescription.
Definition: typedescription.hxx:42
com
Definition: types.h:391
Type.h
com::sun::star::uno::TypeDescription::~TypeDescription
~TypeDescription() SAL_THROW(())
Destructor: releases type description.
Definition: typedescription.hxx:181