LibreOffice: typelib/typedescription.hxx Source File

LibreOffice LibreOffice 26.2 SDK C/C++ API Reference

Loading...
Searching...
No Matches
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
20/*
21 * This file is part of LibreOffice published API.
22 */
23#ifndef INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
24#define INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
25
26#include "sal/config.h"
27
28#include <cstddef>
29
30#include "rtl/alloc.h"
31#include "rtl/ustring.hxx"
32#include "com/sun/star/uno/Type.h"
33#include "typelib/typedescription.h"
34
35
36namespace com
37{
38namespace sun
39{
40namespace star
41{
42 namespace uno
43{
44
50 class TypeDescription
51{
54 mutable typelib_TypeDescription * _pTypeDescr;
55
56public:
58 // these are here to force memory de/allocation to sal lib.
59 static void * SAL_CALL operator new ( size_t nSize )
60 { return ::rtl_allocateMemory( nSize ); }
61 static void SAL_CALL operator delete ( void * pMem )
62 { ::rtl_freeMemory( pMem ); }
63 static void * SAL_CALL operator new ( size_t, void * pMem )
64 { return pMem; }
65 static void SAL_CALL operator delete ( void *, void * )
66 {}
68
73 inline TypeDescription( typelib_TypeDescription * pTypeDescr = NULL );
78 inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef );
83 inline TypeDescription( const css::uno::Type & rType );
88 inline TypeDescription( const TypeDescription & rDescr );
89#if defined LIBO_INTERNAL_ONLY
90 TypeDescription(TypeDescription && other) noexcept : _pTypeDescr(other._pTypeDescr)
91 { other._pTypeDescr = nullptr; }
92#endif
97 inline TypeDescription( rtl_uString * pTypeName );
102 inline TypeDescription( const ::rtl::OUString & rTypeName );
105 inline ~TypeDescription();
106
112 inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr );
118 TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr )
119 { return this->operator =( rTypeDescr.get() ); }
120
121#if defined LIBO_INTERNAL_ONLY
122 TypeDescription & operator =(TypeDescription && other) noexcept {
123 if (_pTypeDescr != nullptr) {
124 typelib_typedescription_release(_pTypeDescr);
125 }
126 _pTypeDescr = other._pTypeDescr;
127 other._pTypeDescr = nullptr;
128 return *this;
129 }
130#endif
131
137 inline bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const;
143 bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const
144 { return equals( rTypeDescr._pTypeDescr ); }
145
148 inline void SAL_CALL makeComplete() const;
149
154 typelib_TypeDescription * SAL_CALL get() const
155 { return _pTypeDescr; }
156
160 bool SAL_CALL is() const
161 { return (_pTypeDescr != NULL); }
162};
163
164 inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr )
165 : _pTypeDescr( pTypeDescr )
166{
167 if (_pTypeDescr)
168 typelib_typedescription_acquire( _pTypeDescr );
169}
170
171 inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef )
172 : _pTypeDescr( NULL )
173{
174 if (pTypeDescrRef)
175 typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
176}
177
178 inline TypeDescription::TypeDescription( const css::uno::Type & rType )
179 : _pTypeDescr( NULL )
180{
181 if (rType.getTypeLibType())
182 typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
183}
184
185 inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr )
186 : _pTypeDescr( rTypeDescr._pTypeDescr )
187{
188 if (_pTypeDescr)
189 typelib_typedescription_acquire( _pTypeDescr );
190}
191
192 inline TypeDescription::TypeDescription( rtl_uString * pTypeName )
193 : _pTypeDescr( NULL )
194{
195 typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
196}
197
198 inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName )
199 : _pTypeDescr( NULL )
200{
201 typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
202}
203
204 inline TypeDescription::~TypeDescription()
205{
206 if (_pTypeDescr)
207 typelib_typedescription_release( _pTypeDescr );
208}
209
210 inline TypeDescription & TypeDescription::operator = ( typelib_TypeDescription * pTypeDescr )
211{
212 if (pTypeDescr)
213 typelib_typedescription_acquire( pTypeDescr );
214 if (_pTypeDescr)
215 typelib_typedescription_release( _pTypeDescr );
216 _pTypeDescr = pTypeDescr;
217 return *this;
218}
219
220 inline bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const
221{
222 return (_pTypeDescr && pTypeDescr &&
223 typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
224}
225
226 inline void TypeDescription::makeComplete() const
227{
228 if (_pTypeDescr && !_pTypeDescr->bComplete)
229 ::typelib_typedescription_complete( &_pTypeDescr );
230}
231
232}
233}
234}
235}
236
237#endif
238
239/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
config.h
alloc.h
rtl_freeMemory
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
ustring.hxx
typedescription.h
typelib_TypeDescription
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescription typelib_TypeDescription
Full type description of a type.
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_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
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
typelib_typedescription_acquire
CPPU_DLLPUBLIC void typelib_typedescription_acquire(typelib_TypeDescription *pDesc) SAL_THROW_EXTERN_C()
Increments reference count of given type description.
typelib_typedescription_release
CPPU_DLLPUBLIC void typelib_typedescription_release(typelib_TypeDescription *pDesc) SAL_THROW_EXTERN_C()
Decrements reference count of given type.
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_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.
Type.h
com
Definition types.h:377
com::sun
Definition types.h:377
com::sun::star
Definition types.h:377
com::sun::star::uno
Definition typedescription.hxx:43
com::sun::star::uno::TypeDescription
C++ wrapper for typelib_TypeDescription.
Definition typedescription.hxx:51
com::sun::star::uno::TypeDescription::TypeDescription
TypeDescription(typelib_TypeDescription *pTypeDescr=NULL)
Constructor:
Definition typedescription.hxx:164
com::sun::star::uno::TypeDescription::get
typelib_TypeDescription * get() const
Gets the UNacquired type description pointer.
Definition typedescription.hxx:154
com::sun::star::uno::TypeDescription::is
bool is() const
Tests if a type description is set.
Definition typedescription.hxx:160
com::sun::star::uno::TypeDescription::equals
bool equals(const typelib_TypeDescription *pTypeDescr) const
Tests whether two type descriptions are equal.
Definition typedescription.hxx:220
com::sun::star::uno::TypeDescription::operator=
TypeDescription & operator=(typelib_TypeDescription *pTypeDescr)
Assignment operator: acquires given type description and releases a set one.
Definition typedescription.hxx:210
com::sun::star::uno::TypeDescription::~TypeDescription
~TypeDescription()
Destructor: releases type description.
Definition typedescription.hxx:204
com::sun::star::uno::TypeDescription::equals
bool equals(const TypeDescription &rTypeDescr) const
Tests whether two type descriptions are equal.
Definition typedescription.hxx:143
com::sun::star::uno::TypeDescription::makeComplete
void makeComplete() const
Makes stored type description complete.
Definition typedescription.hxx:226
com::sun::star::uno::Type
C++ class representing an IDL meta type.
Definition Type.h:59
com::sun::star::uno::Type::getTypeLibType
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition Type.h:162