bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / typelib / typedescription.hxx
blobae8599bb1fdd2c428edb32f2df7b3da2c560f8f3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
20 #define INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
22 #include "sal/config.h"
24 #include <cstddef>
26 #include "rtl/alloc.h"
27 #include "rtl/ustring.hxx"
28 #include "com/sun/star/uno/Type.h"
29 #include "typelib/typedescription.h"
32 namespace com
34 namespace sun
36 namespace star
38 namespace uno
41 /** C++ wrapper for typelib_TypeDescription.
42 Constructors by name, type, type description reference will get the full type description.
44 @see typelib_TypeDescription
46 class TypeDescription
48 /** C typelib type description
50 mutable typelib_TypeDescription * _pTypeDescr;
52 public:
53 /// @cond INTERNAL
54 // these are here to force memory de/allocation to sal lib.
55 static void * SAL_CALL operator new ( size_t nSize )
56 { return ::rtl_allocateMemory( nSize ); }
57 static void SAL_CALL operator delete ( void * pMem )
58 { ::rtl_freeMemory( pMem ); }
59 static void * SAL_CALL operator new ( size_t, void * pMem )
60 { return pMem; }
61 static void SAL_CALL operator delete ( void *, void * )
63 /// @endcond
65 /** Constructor:
67 @param pTypeDescr a type description
69 inline TypeDescription( typelib_TypeDescription * pTypeDescr = NULL );
70 /** Constructor:
72 @param pTypeDescrRef a type description reference
74 inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef );
75 /** Constructor:
77 @param rType a type
79 inline TypeDescription( const css::uno::Type & rType );
80 /** Copy constructor:
82 @param rDescr another TypeDescription
84 inline TypeDescription( const TypeDescription & rDescr );
85 #if defined LIBO_INTERNAL_ONLY
86 TypeDescription(TypeDescription && other): _pTypeDescr(other._pTypeDescr)
87 { other._pTypeDescr = nullptr; }
88 #endif
89 /** Constructor:
91 @param pTypeName a type name
93 inline TypeDescription( rtl_uString * pTypeName );
94 /** Constructor:
96 @param rTypeName a type name
98 inline TypeDescription( const ::rtl::OUString & rTypeName );
99 /** Destructor: releases type description
101 inline ~TypeDescription();
103 /** Assignment operator: acquires given type description and releases a set one.
105 @param pTypeDescr another type description
106 @return this TypeDescription
108 inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr );
109 /** Assignment operator: acquires given type description and releases a set one.
111 @param rTypeDescr another type description
112 @return this TypeDescription
114 TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr )
115 { return this->operator =( rTypeDescr.get() ); }
117 #if defined LIBO_INTERNAL_ONLY
118 TypeDescription & operator =(TypeDescription && other) {
119 if (_pTypeDescr != nullptr) {
120 typelib_typedescription_release(_pTypeDescr);
122 _pTypeDescr = other._pTypeDescr;
123 other._pTypeDescr = nullptr;
124 return *this;
126 #endif
128 /** Tests whether two type descriptions are equal.
130 @param pTypeDescr another type description
131 @return true, if both type descriptions are equal, false otherwise
133 inline bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const;
134 /** Tests whether two type descriptions are equal.
136 @param rTypeDescr another type description
137 @return true, if both type descriptions are equal, false otherwise
139 bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const
140 { return equals( rTypeDescr._pTypeDescr ); }
142 /** Makes stored type description complete.
144 inline void SAL_CALL makeComplete() const;
146 /** Gets the UNacquired type description pointer.
148 @return stored pointer of type description
150 typelib_TypeDescription * SAL_CALL get() const
151 { return _pTypeDescr; }
152 /** Tests if a type description is set.
154 @return true, if a type description is set, false otherwise
156 bool SAL_CALL is() const
157 { return (_pTypeDescr != NULL); }
160 inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr )
161 : _pTypeDescr( pTypeDescr )
163 if (_pTypeDescr)
164 typelib_typedescription_acquire( _pTypeDescr );
167 inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef )
168 : _pTypeDescr( NULL )
170 if (pTypeDescrRef)
171 typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
174 inline TypeDescription::TypeDescription( const css::uno::Type & rType )
175 : _pTypeDescr( NULL )
177 if (rType.getTypeLibType())
178 typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
181 inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr )
182 : _pTypeDescr( rTypeDescr._pTypeDescr )
184 if (_pTypeDescr)
185 typelib_typedescription_acquire( _pTypeDescr );
188 inline TypeDescription::TypeDescription( rtl_uString * pTypeName )
189 : _pTypeDescr( NULL )
191 typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
194 inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName )
195 : _pTypeDescr( NULL )
197 typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
200 inline TypeDescription::~TypeDescription()
202 if (_pTypeDescr)
203 typelib_typedescription_release( _pTypeDescr );
206 inline TypeDescription & TypeDescription::operator = ( typelib_TypeDescription * pTypeDescr )
208 if (pTypeDescr)
209 typelib_typedescription_acquire( pTypeDescr );
210 if (_pTypeDescr)
211 typelib_typedescription_release( _pTypeDescr );
212 _pTypeDescr = pTypeDescr;
213 return *this;
216 inline bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const
218 return (_pTypeDescr && pTypeDescr &&
219 typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
222 inline void TypeDescription::makeComplete() const
224 if (_pTypeDescr && !_pTypeDescr->bComplete)
225 ::typelib_typedescription_complete( &_pTypeDescr );
233 #endif
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */