AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 #ifndef INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
4 #define INCLUDED_TYPELIB_TYPEDESCRIPTION_HXX
5 
6 #include "sal/config.h"
7 
8 #include <cstddef>
9 
10 #include "rtl/alloc.h"
11 #include "rtl/ustring.hxx"
12 #include "com/sun/star/uno/Type.h"
14 
15 
16 namespace com
17 {
18 namespace sun
19 {
20 namespace star
21 {
22 namespace uno
23 {
24 
31 {
34  mutable typelib_TypeDescription * _pTypeDescr;
35 
36 public:
38  // these are here to force memory de/allocation to sal lib.
39  static void * SAL_CALL operator new ( size_t nSize )
40  { return ::rtl_allocateMemory( nSize ); }
41  static void SAL_CALL operator delete ( void * pMem )
42  { ::rtl_freeMemory( pMem ); }
43  static void * SAL_CALL operator new ( size_t, void * pMem )
44  { return pMem; }
45  static void SAL_CALL operator delete ( void *, void * )
46  {}
48 
53  inline TypeDescription( typelib_TypeDescription * pTypeDescr = NULL );
58  inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef );
63  inline TypeDescription( const css::uno::Type & rType );
68  inline TypeDescription( const TypeDescription & rDescr );
69 #if defined LIBO_INTERNAL_ONLY
70  TypeDescription(TypeDescription && other) noexcept : _pTypeDescr(other._pTypeDescr)
71  { other._pTypeDescr = nullptr; }
72 #endif
73 
77  inline TypeDescription( rtl_uString * pTypeName );
82  inline TypeDescription( const ::rtl::OUString & rTypeName );
85  inline ~TypeDescription();
86 
92  inline TypeDescription & SAL_CALL operator = ( typelib_TypeDescription * pTypeDescr );
98  TypeDescription & SAL_CALL operator =( const TypeDescription & rTypeDescr )
99  { return this->operator =( rTypeDescr.get() ); }
100 
101 #if defined LIBO_INTERNAL_ONLY
102  TypeDescription & operator =(TypeDescription && other) noexcept {
103  if (_pTypeDescr != nullptr) {
104  typelib_typedescription_release(_pTypeDescr);
105  }
106  _pTypeDescr = other._pTypeDescr;
107  other._pTypeDescr = nullptr;
108  return *this;
109  }
110 #endif
111 
117  inline bool SAL_CALL equals( const typelib_TypeDescription * pTypeDescr ) const;
123  bool SAL_CALL equals( const TypeDescription & rTypeDescr ) const
124  { return equals( rTypeDescr._pTypeDescr ); }
125 
128  inline void SAL_CALL makeComplete() const;
129 
134  typelib_TypeDescription * SAL_CALL get() const
135  { return _pTypeDescr; }
140  bool SAL_CALL is() const
141  { return (_pTypeDescr != NULL); }
142 };
143 
145  : _pTypeDescr( pTypeDescr )
146 {
147  if (_pTypeDescr)
148  typelib_typedescription_acquire( _pTypeDescr );
149 }
150 
152  : _pTypeDescr( NULL )
153 {
154  if (pTypeDescrRef)
155  typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef );
156 }
157 
158 inline TypeDescription::TypeDescription( const css::uno::Type & rType )
159  : _pTypeDescr( NULL )
160 {
161  if (rType.getTypeLibType())
162  typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() );
163 }
164 
166  : _pTypeDescr( rTypeDescr._pTypeDescr )
167 {
168  if (_pTypeDescr)
169  typelib_typedescription_acquire( _pTypeDescr );
170 }
171 
172 inline TypeDescription::TypeDescription( rtl_uString * pTypeName )
173  : _pTypeDescr( NULL )
174 {
175  typelib_typedescription_getByName( &_pTypeDescr , pTypeName );
176 }
177 
178 inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName )
179  : _pTypeDescr( NULL )
180 {
181  typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData );
182 }
183 
185 {
186  if (_pTypeDescr)
187  typelib_typedescription_release( _pTypeDescr );
188 }
189 
191 {
192  if (pTypeDescr)
193  typelib_typedescription_acquire( pTypeDescr );
194  if (_pTypeDescr)
195  typelib_typedescription_release( _pTypeDescr );
196  _pTypeDescr = pTypeDescr;
197  return *this;
198 }
199 
200 inline bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const
201 {
202  return (_pTypeDescr && pTypeDescr &&
203  typelib_typedescription_equals( _pTypeDescr, pTypeDescr ));
204 }
205 
206 inline void TypeDescription::makeComplete() const
207 {
208  if (_pTypeDescr && !_pTypeDescr->bComplete)
209  ::typelib_typedescription_complete( &_pTypeDescr );
210 }
211 
212 }
213 }
214 }
215 }
216 
217 #endif
218 
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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.
~TypeDescription()
Destructor: releases type description.
Definition: typedescription.hxx:184
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
void makeComplete() const
Makes stored type description complete.
Definition: typedescription.hxx:206
C++ wrapper for typelib_TypeDescription.
Definition: typedescription.hxx:30
CPPU_DLLPUBLIC void typelib_typedescriptionreference_getDescription(typelib_TypeDescription **ppRet, typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
Retrieves the type description for a given reference.
TypeDescription & operator=(typelib_TypeDescription *pTypeDescr)
Assignment operator: acquires given type description and releases a set one.
Definition: typedescription.hxx:190
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.
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescription typelib_TypeDescription
Full type description of a type.
typelib_TypeDescription * get() const
Gets the UNacquired type description pointer.
Definition: typedescription.hxx:134
bool equals(const typelib_TypeDescription *pTypeDescr) const
Tests whether two type descriptions are equal.
Definition: typedescription.hxx:200
TypeDescription(typelib_TypeDescription *pTypeDescr=NULL)
Constructor:
Definition: typedescription.hxx:144
bool is() const
Tests if a type description is set.
Definition: typedescription.hxx:140
bool equals(const TypeDescription &rTypeDescr) const
Tests whether two type descriptions are equal.
Definition: typedescription.hxx:123
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
CPPU_DLLPUBLIC void typelib_typedescription_release(typelib_TypeDescription *pDesc) SAL_THROW_EXTERN_C()
Decrements reference count of given type.
CPPU_DLLPUBLIC void typelib_typedescription_acquire(typelib_TypeDescription *pDesc) SAL_THROW_EXTERN_C()
Increments reference count of given type description.
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.