| 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_COM_SUN_STAR_UNO_TYPE_H |
| 24 |
#define INCLUDED_COM_SUN_STAR_UNO_TYPE_H |
| 25 |
|
| 26 |
#include "typelib/typedescription.h" |
| 27 |
#include "com/sun/star/uno/TypeClass.hdl" |
| 28 |
#include "rtl/ustring.hxx" |
| 29 |
#include "rtl/alloc.h" |
| 30 |
|
| 31 |
|
| 32 |
namespace com |
| 33 |
{ |
| 34 |
namespace sun |
| 35 |
{ |
| 36 |
namespace star |
| 37 |
{ |
| 38 |
namespace uno |
| 39 |
{ |
| 40 |
|
| 41 |
/** Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer. |
| 42 |
*/ |
| 43 |
enum UnoType_NoAcquire |
| 44 |
{ |
| 45 |
/** This enum value can be used for creating a Type object granting a given type description |
| 46 |
reference, i.e. transferring ownership to it. |
| 47 |
*/ |
| 48 |
UNO_TYPE_NO_ACQUIRE |
| 49 |
}; |
| 50 |
|
| 51 |
/** C++ class representing an IDL meta type. This class is used to represent a type, |
| 52 |
i.e. a type name and its type class. |
| 53 |
Internally the type holds a C type description reference of the runtime. |
| 54 |
You can obtain a full type description of a type by calling member function getDescription(). |
| 55 |
|
| 56 |
@see typelib_TypeDescriptionReference |
| 57 |
*/ |
| 58 |
class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI Type |
| 59 |
{ |
| 60 |
/** the C typelib reference pointer |
| 61 |
*/ |
| 62 |
typelib_TypeDescriptionReference * _pType; |
| 63 |
|
| 64 |
public: |
| 65 |
/// @cond INTERNAL |
| 66 |
// these are here to force memory de/allocation to sal lib. |
| 67 |
static void * SAL_CALL operator new ( size_t nSize ) |
| 68 |
{ return ::rtl_allocateMemory( nSize ); } |
| 69 |
static void SAL_CALL operator delete ( void * pMem ) |
| 70 |
{ ::rtl_freeMemory( pMem ); } |
| 71 |
static void * SAL_CALL operator new ( size_t, void * pMem ) |
| 72 |
{ return pMem; } |
| 73 |
static void SAL_CALL operator delete ( void *, void * ) |
| 74 |
{} |
| 75 |
/// @endcond |
| 76 |
|
| 77 |
/** Default Constructor: Type is set to void. |
| 78 |
*/ |
| 79 |
inline Type(); |
| 80 |
|
| 81 |
/** Constructor: Type is constructed by given name and type class. |
| 82 |
|
| 83 |
@param eTypeClass type class of type |
| 84 |
@param rTypeName name of type |
| 85 |
*/ |
| 86 |
inline Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ); |
| 87 |
|
| 88 |
/** Constructor: Type is constructed by given name and type class. |
| 89 |
|
| 90 |
@param eTypeClass type class of type |
| 91 |
@param pTypeName name of type |
| 92 |
*/ |
| 93 |
inline Type( TypeClass eTypeClass, const char * pTypeName ); |
| 94 |
|
| 95 |
/** Constructor: Type is (copy) constructed by given C type description reference. |
| 96 |
|
| 97 |
@param pType C type description reference |
| 98 |
*/ |
| 99 |
inline Type( typelib_TypeDescriptionReference * pType ); |
| 100 |
|
| 101 |
/** Constructor: Type is (copy) constructed by given C type description reference |
| 102 |
without acquiring it. |
| 103 |
|
| 104 |
@param pType C type description reference |
| 105 |
@param dummy UNO_TYPE_NO_ACQUIRE to force obvious distinction to other constructors |
| 106 |
*/ |
| 107 |
inline Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire dummy ); |
| 108 |
/** Constructor: Type is (copy) constructed by given C type description reference |
| 109 |
without acquiring it. |
| 110 |
|
| 111 |
@param pType C type description reference |
| 112 |
@param dummy SAL_NO_ACQUIRE to force obvious distinction to other constructors |
| 113 |
*/ |
| 114 |
inline Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire dummy ); |
| 115 |
|
| 116 |
/** Copy constructor: Type is copy constructed by given type. |
| 117 |
|
| 118 |
@param rType another type |
| 119 |
*/ |
| 120 |
inline Type( const Type & rType ); |
| 121 |
|
| 122 |
/** Destructor: Releases acquired C type description reference. |
| 123 |
*/ |
| 124 |
~Type() |
| 125 |
{ ::typelib_typedescriptionreference_release( _pType ); } |
| 126 |
|
| 127 |
/** Assignment operator: Acquires right side type and releases previously set type. |
| 128 |
|
| 129 |
@param rType another type (right side) |
| 130 |
@return this type |
| 131 |
*/ |
| 132 |
inline Type & SAL_CALL operator = ( const Type & rType ); |
| 133 |
|
| 134 |
#if defined LIBO_INTERNAL_ONLY |
| 135 |
inline Type & SAL_CALL operator = ( Type && ); |
| 136 |
#endif |
| 137 |
|
| 138 |
/** Gets the type class of set type. |
| 139 |
|
| 140 |
@return type class of set type |
| 141 |
*/ |
| 142 |
TypeClass SAL_CALL getTypeClass() const |
| 143 |
{ return static_cast<TypeClass>(_pType->eTypeClass); } |
| 144 |
|
| 145 |
/** Gets the name of the set type. |
| 146 |
|
| 147 |
@return name of the set type |
| 148 |
*/ |
| 149 |
inline ::rtl::OUString SAL_CALL getTypeName() const; |
| 150 |
|
| 151 |
/** Obtains a full type description of set type. |
| 152 |
|
| 153 |
@param ppDescr [inout] type description |
| 154 |
*/ |
| 155 |
void SAL_CALL getDescription( typelib_TypeDescription ** ppDescr ) const |
| 156 |
{ ::typelib_typedescriptionreference_getDescription( ppDescr, _pType ); } |
| 157 |
|
| 158 |
/** Gets the C typelib type description reference pointer. Does not acquire the reference! |
| 159 |
|
| 160 |
@return UNacquired type description reference |
| 161 |
*/ |
| 162 |
typelib_TypeDescriptionReference * SAL_CALL getTypeLibType() const |
| 163 |
{ return _pType; } |
| 164 |
|
| 165 |
/** Tests if values of this reflected type can be assigned by values of given type. |
| 166 |
This includes widening conversion (e.g., long assignable from short), as long as there |
| 167 |
is no data loss. |
| 168 |
|
| 169 |
@param rType another type |
| 170 |
@return true if values of this type can be assigned from values of given type, |
| 171 |
false otherwise |
| 172 |
*/ |
| 173 |
bool SAL_CALL isAssignableFrom( const Type & rType ) const |
| 174 |
{ return ::typelib_typedescriptionreference_isAssignableFrom( _pType, rType._pType ); } |
| 175 |
|
| 176 |
/** Compares two types. |
| 177 |
|
| 178 |
@param rType another type |
| 179 |
@return true if both types refer the same type, false otherwise |
| 180 |
*/ |
| 181 |
bool SAL_CALL equals( const Type & rType ) const |
| 182 |
{ return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); } |
| 183 |
/** Equality operator: Compares two types. |
| 184 |
|
| 185 |
@param rType another type |
| 186 |
@return true if both types refer the same type, false otherwise |
| 187 |
*/ |
| 188 |
bool SAL_CALL operator == ( const Type & rType ) const |
| 189 |
{ return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); } |
| 190 |
/** Inequality operator: Compares two types. |
| 191 |
|
| 192 |
@param rType another type |
| 193 |
@return false if both types refer the same type, true otherwise |
| 194 |
*/ |
| 195 |
bool SAL_CALL operator != ( const Type & rType ) const |
| 196 |
{ return (! ::typelib_typedescriptionreference_equals( _pType, rType._pType )); } |
| 197 |
}; |
| 198 |
|
| 199 |
/** Helper class to specify a type pointer for idl arrays. |
| 200 |
*/ |
| 201 |
template< class T > |
| 202 |
class Array |
| 203 |
{ |
| 204 |
public: |
| 205 |
static typelib_TypeDescriptionReference * s_pType; |
| 206 |
}; |
| 207 |
|
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
/** Gets the meta type of IDL type "type". |
| 214 |
|
| 215 |
There are cases (involving templates) where uses of getCppuType are known to |
| 216 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 217 |
|
| 218 |
The dummy parameter is just a typed pointer for function signature. |
| 219 |
|
| 220 |
@return type of IDL type "type" |
| 221 |
|
| 222 |
@deprecated |
| 223 |
Use cppu::UnoType instead. |
| 224 |
*/ |
| 225 |
SAL_DEPRECATED("use cppu::UnoType") |
| 226 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * ); |
| 227 |
|
| 228 |
/** Gets the meta type of IDL type void. |
| 229 |
@return type of IDL type void |
| 230 |
|
| 231 |
@deprecated |
| 232 |
Use cppu::UnoType instead. |
| 233 |
*/ |
| 234 |
SAL_DEPRECATED("use cppu::UnoType") |
| 235 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType(); |
| 236 |
/** Gets the meta type of IDL type void. |
| 237 |
|
| 238 |
@return type of IDL type void |
| 239 |
|
| 240 |
@deprecated |
| 241 |
Use cppu::UnoType instead. |
| 242 |
*/ |
| 243 |
SAL_DEPRECATED("use cppu::UnoType") |
| 244 |
inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType(); |
| 245 |
|
| 246 |
/** Gets the meta type of IDL type boolean. |
| 247 |
|
| 248 |
@return type of IDL type boolean |
| 249 |
|
| 250 |
@deprecated |
| 251 |
Use cppu::UnoType instead. |
| 252 |
*/ |
| 253 |
SAL_DEPRECATED("use cppu::UnoType") |
| 254 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType(); |
| 255 |
/** Gets the meta type of IDL type boolean. |
| 256 |
|
| 257 |
@return type of IDL type boolean |
| 258 |
|
| 259 |
@deprecated |
| 260 |
Use cppu::UnoType instead. |
| 261 |
*/ |
| 262 |
SAL_DEPRECATED("use cppu::UnoType") |
| 263 |
inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType(); |
| 264 |
/** Gets the meta type of IDL type boolean. |
| 265 |
|
| 266 |
There are cases (involving templates) where uses of getCppuType are known to |
| 267 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 268 |
|
| 269 |
The dummy parameter is just a typed pointer for function signature. |
| 270 |
|
| 271 |
@return type of IDL type boolean |
| 272 |
|
| 273 |
@deprecated |
| 274 |
Use cppu::UnoType instead. |
| 275 |
*/ |
| 276 |
SAL_DEPRECATED("use cppu::UnoType") |
| 277 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * ); |
| 278 |
/** Gets the meta type of IDL type boolean. |
| 279 |
|
| 280 |
There are cases (involving templates) where uses of getCppuType are known to |
| 281 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 282 |
|
| 283 |
The dummy parameter is just a typed pointer for function signature. |
| 284 |
|
| 285 |
@return type of IDL type boolean |
| 286 |
|
| 287 |
@deprecated |
| 288 |
Use cppu::UnoType instead. |
| 289 |
*/ |
| 290 |
SAL_DEPRECATED("use cppu::UnoType") |
| 291 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( |
| 292 |
bool const * ); |
| 293 |
|
| 294 |
/** Gets the meta type of IDL type char. |
| 295 |
|
| 296 |
@return type of IDL type char |
| 297 |
|
| 298 |
@deprecated |
| 299 |
Use cppu::UnoType instead. |
| 300 |
*/ |
| 301 |
SAL_DEPRECATED("use cppu::UnoType") |
| 302 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType(); |
| 303 |
/** Gets the meta type of IDL type char. |
| 304 |
|
| 305 |
@return type of IDL type char |
| 306 |
|
| 307 |
@deprecated |
| 308 |
Use cppu::UnoType instead. |
| 309 |
*/ |
| 310 |
SAL_DEPRECATED("use cppu::UnoType") |
| 311 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType(); |
| 312 |
|
| 313 |
/** Gets the meta type of IDL type byte. |
| 314 |
|
| 315 |
There are cases (involving templates) where uses of getCppuType are known to |
| 316 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 317 |
|
| 318 |
The dummy parameter is just a typed pointer for function signature. |
| 319 |
|
| 320 |
@return type of IDL type byte |
| 321 |
|
| 322 |
@deprecated |
| 323 |
Use cppu::UnoType instead. |
| 324 |
*/ |
| 325 |
SAL_DEPRECATED("use cppu::UnoType") |
| 326 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * ); |
| 327 |
|
| 328 |
/** Gets the meta type of IDL type string. |
| 329 |
|
| 330 |
There are cases (involving templates) where uses of getCppuType are known to |
| 331 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 332 |
|
| 333 |
The dummy parameter is just a typed pointer for function signature. |
| 334 |
|
| 335 |
@return type of IDL type string |
| 336 |
|
| 337 |
@deprecated |
| 338 |
Use cppu::UnoType instead. |
| 339 |
*/ |
| 340 |
SAL_DEPRECATED("use cppu::UnoType") |
| 341 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * ); |
| 342 |
|
| 343 |
/** Gets the meta type of IDL type short. |
| 344 |
|
| 345 |
There are cases (involving templates) where uses of getCppuType are known to |
| 346 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 347 |
|
| 348 |
The dummy parameter is just a typed pointer for function signature. |
| 349 |
|
| 350 |
@return type of IDL type short |
| 351 |
|
| 352 |
@deprecated |
| 353 |
Use cppu::UnoType instead. |
| 354 |
*/ |
| 355 |
SAL_DEPRECATED("use cppu::UnoType") |
| 356 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * ); |
| 357 |
|
| 358 |
/** Gets the meta type of IDL type unsigned short. |
| 359 |
|
| 360 |
There are cases (involving templates) where uses of getCppuType are known to |
| 361 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 362 |
|
| 363 |
The dummy parameter is just a typed pointer for function signature. |
| 364 |
|
| 365 |
@return type of IDL type unsigned short |
| 366 |
|
| 367 |
@deprecated |
| 368 |
Use cppu::UnoType instead. |
| 369 |
*/ |
| 370 |
SAL_DEPRECATED("use cppu::UnoType") |
| 371 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * ); |
| 372 |
|
| 373 |
/** Gets the meta type of IDL type long. |
| 374 |
|
| 375 |
There are cases (involving templates) where uses of getCppuType are known to |
| 376 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 377 |
|
| 378 |
The dummy parameter is just a typed pointer for function signature. |
| 379 |
|
| 380 |
@return type of IDL type long |
| 381 |
|
| 382 |
@deprecated |
| 383 |
Use cppu::UnoType instead. |
| 384 |
*/ |
| 385 |
SAL_DEPRECATED("use cppu::UnoType") |
| 386 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * ); |
| 387 |
|
| 388 |
/** Gets the meta type of IDL type unsigned long. |
| 389 |
|
| 390 |
There are cases (involving templates) where uses of getCppuType are known to |
| 391 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 392 |
|
| 393 |
The dummy parameter is just a typed pointer for function signature. |
| 394 |
|
| 395 |
@return type of IDL type unsigned long |
| 396 |
|
| 397 |
@deprecated |
| 398 |
Use cppu::UnoType instead. |
| 399 |
*/ |
| 400 |
SAL_DEPRECATED("use cppu::UnoType") |
| 401 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * ); |
| 402 |
|
| 403 |
/** Gets the meta type of IDL type hyper. |
| 404 |
|
| 405 |
There are cases (involving templates) where uses of getCppuType are known to |
| 406 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 407 |
|
| 408 |
The dummy parameter is just a typed pointer for function signature. |
| 409 |
|
| 410 |
@return type of IDL type hyper |
| 411 |
|
| 412 |
@deprecated |
| 413 |
Use cppu::UnoType instead. |
| 414 |
*/ |
| 415 |
SAL_DEPRECATED("use cppu::UnoType") |
| 416 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * ); |
| 417 |
|
| 418 |
/** Gets the meta type of IDL type unsigned hyper. |
| 419 |
|
| 420 |
There are cases (involving templates) where uses of getCppuType are known to |
| 421 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 422 |
|
| 423 |
The dummy parameter is just a typed pointer for function signature. |
| 424 |
|
| 425 |
@return type of IDL type unsigned hyper |
| 426 |
|
| 427 |
@deprecated |
| 428 |
Use cppu::UnoType instead. |
| 429 |
*/ |
| 430 |
SAL_DEPRECATED("use cppu::UnoType") |
| 431 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * ); |
| 432 |
|
| 433 |
/** Gets the meta type of IDL type float. |
| 434 |
|
| 435 |
There are cases (involving templates) where uses of getCppuType are known to |
| 436 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 437 |
|
| 438 |
The dummy parameter is just a typed pointer for function signature. |
| 439 |
|
| 440 |
@return type of IDL type float |
| 441 |
|
| 442 |
@deprecated |
| 443 |
Use cppu::UnoType instead. |
| 444 |
*/ |
| 445 |
SAL_DEPRECATED("use cppu::UnoType") |
| 446 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * ); |
| 447 |
|
| 448 |
/** Gets the meta type of IDL type double. |
| 449 |
|
| 450 |
There are cases (involving templates) where uses of getCppuType are known to |
| 451 |
not compile. Use cppu::UnoType or cppu::getTypeFavourUnsigned instead. |
| 452 |
|
| 453 |
The dummy parameter is just a typed pointer for function signature. |
| 454 |
|
| 455 |
@return type of IDL type double |
| 456 |
|
| 457 |
@deprecated |
| 458 |
Use cppu::UnoType instead. |
| 459 |
*/ |
| 460 |
SAL_DEPRECATED("use cppu::UnoType") |
| 461 |
inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * ); |
| 462 |
|
| 463 |
/** Gets the meta type of an IDL type. |
| 464 |
|
| 465 |
The difference between this function template (with a type parameter) and |
| 466 |
the overloaded getCppuType function with a single (dummy) parameter of a |
| 467 |
specific type is that this function template may not work for the UNO type |
| 468 |
"unsigned short" (sal_uInt16 in C++), while the overloaded one-parameter |
| 469 |
function may not work for the UNO type "char" (sal_Unicode in C++, which may |
| 470 |
have the same underlying C++ type as sal_uInt16 on certain platforms). |
| 471 |
|
| 472 |
@return type of the given IDL type |
| 473 |
|
| 474 |
@deprecated |
| 475 |
Use cppu::UnoType instead (or the internal-only cppu::getTypeFavourChar). |
| 476 |
Also note that getCppuType< com::sun::star::uno::Sequence< sal_Unicode > >() |
| 477 |
does not work as expected. |
| 478 |
|
| 479 |
@since UDK 3.2.0 |
| 480 |
*/ |
| 481 |
template< typename T > SAL_DEPRECATED("use cppu::UnoType") |
| 482 |
inline const ::com::sun::star::uno::Type & SAL_CALL |
| 483 |
getCppuType(); |
| 484 |
|
| 485 |
/** Gets the meta type of IDL type char. |
| 486 |
|
| 487 |
@return type of IDL type char |
| 488 |
|
| 489 |
@deprecated |
| 490 |
Use cppu::UnoType instead (or the internal-only cppu::getTypeFavourChar). |
| 491 |
Also note that getCppuType< com::sun::star::uno::Sequence< sal_Unicode > >() |
| 492 |
does not work as expected. |
| 493 |
|
| 494 |
@since UDK 3.2.0 |
| 495 |
*/ |
| 496 |
template<> SAL_DEPRECATED("use cppu::UnoType") |
| 497 |
inline const ::com::sun::star::uno::Type & SAL_CALL |
| 498 |
getCppuType< sal_Unicode >(); |
| 499 |
|
| 500 |
#endif |
| 501 |
|
| 502 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |