23 #ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
24 #define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
41 #include "com/sun/star/uno/RuntimeException.hpp"
69 this,
const_cast<T *
>(&value),
82 #if defined LIBO_INTERNAL_ONLY
83 template<
typename T1,
typename T2>
84 Any::Any(rtl::OUStringConcat<T1, T2> && value):
85 Any(
rtl::OUString(std::move(value)))
88 Any::Any(rtl::OUStringNumber<T> && value): Any(
rtl::OUString(std::move(value))) {}
106 this,
const_cast< void *
>( pData_ ), pTypeDescr,
cpp_acquire );
112 this,
const_cast< void *
>( pData_ ), pType_,
cpp_acquire );
126 this, rAny.pData, rAny.pType,
132 #if defined LIBO_INTERNAL_ONLY
136 std::swap(other.pType, pType);
137 std::swap(other.pData, pData);
138 std::swap(other.pReserved, pReserved);
139 if (pData == &other.pReserved) {
149 std::swap(other.pType, pType);
150 std::swap(other.pData, pData);
151 std::swap(other.pReserved, pReserved);
152 if (pData == &other.pReserved) {
155 if (other.pData == &pReserved) {
156 other.pData = &other.pReserved;
165 return ::rtl::OUString( pType->pTypeName );
178 this,
const_cast< void *
>( pData_ ), pType_,
185 this,
const_cast< void *
>( pData_ ), pTypeDescr,
203 template <
typename T>
213 #if defined LIBO_INTERNAL_ONLY
214 template<>
bool Any::has<Any>()
const =
delete;
220 pData, pType, rAny.pData, rAny.pType,
227 pData, pType, rAny.pData, rAny.pType,
232 #if !defined LIBO_INTERNAL_ONLY
249 #if defined LIBO_INTERNAL_ONLY
251 template<
typename T1,
typename T2>
252 Any
toAny(rtl::OUStringConcat<T1, T2> && value)
253 {
return Any(std::move(value)); }
256 Any
toAny(rtl::OUStringNumber<T> && value)
257 {
return Any(std::move(value)); }
259 template<
typename T>
bool fromAny(Any
const & any, T * value) {
260 assert(value !=
nullptr);
261 return any >>= *value;
264 template<>
bool fromAny(Any
const & any, Any * value) {
265 assert(value !=
nullptr);
293 #ifdef LIBO_INTERNAL_ONLY
294 template<
class C1,
class C2 >
295 inline void operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& value )
300 &rAny,
const_cast< rtl::OUString *
>( &str ), rType.getTypeLibType(),
303 template<
typename T1,
typename T2>
304 void operator <<=(Any &, rtl::OUStringConcat<T1, T2>
const &) =
delete;
306 inline void operator <<= ( Any & rAny, rtl::OUStringNumber< C >&& value )
311 &rAny,
const_cast< rtl::OUString *
>( &str ), rType.getTypeLibType(),
315 void operator <<=(Any &, rtl::OUStringNumber<T>
const &) =
delete;
318 #if defined LIBO_INTERNAL_ONLY
319 template<>
void SAL_CALL
operator <<=(Any &, Any
const &) =
delete;
328 rAny.pData, rAny.pType,
340 value = bool(*
static_cast< const sal_Bool *
>( rAny.pData ));
350 bool(value) ==
bool(*
static_cast< const sal_Bool *
>( rAny.pData )));
359 value = *
static_cast< sal_Bool const *
>( rAny.pData );
371 bool(*
static_cast< sal_Bool const *
>( rAny.pData ))));
381 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
391 switch (rAny.pType->eTypeClass)
394 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
398 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
408 switch (rAny.pType->eTypeClass)
411 value =
static_cast<sal_uInt16
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
415 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
426 switch (rAny.pType->eTypeClass)
429 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
432 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
435 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
439 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
449 switch (rAny.pType->eTypeClass)
452 value =
static_cast<sal_uInt32
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
455 value =
static_cast<sal_uInt32
>( *
static_cast< const sal_Int16 *
>( rAny.pData ) );
458 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
462 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
473 switch (rAny.pType->eTypeClass)
476 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
479 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
482 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
485 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
488 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
492 value = *
static_cast< const sal_Int64 *
>( rAny.pData );
502 switch (rAny.pType->eTypeClass)
505 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
508 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int16 *
>( rAny.pData ) );
511 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
514 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int32 *
>( rAny.pData ) );
517 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
521 value = *
static_cast< const sal_uInt64 *
>( rAny.pData );
532 switch (rAny.pType->eTypeClass)
535 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
538 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
541 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
544 value = *
static_cast< const float *
>( rAny.pData );
555 switch (rAny.pType->eTypeClass)
558 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
561 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
564 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
567 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
570 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
573 value = *
static_cast< const float *
>( rAny.pData );
576 value = *
static_cast< const double *
>( rAny.pData );
589 value = *
static_cast< const ::
rtl::OUString *
>( rAny.pData );
596 inline bool SAL_CALL
operator == (
const Any & rAny, const ::rtl::OUString & value )
599 value == *
static_cast< const ::
rtl::OUString *
>( rAny.pData ) );
608 value = *
static_cast< const Type *
>( rAny.pData );
618 value.
equals( *
static_cast< const Type *
>( rAny.pData ) ));
622 #if defined LIBO_INTERNAL_ONLY
623 template<>
bool SAL_CALL
operator >>=(Any
const &, Any &) =
delete;
631 &value, rAny.pData, rAny.pType,
644 return static_cast< const BaseReference *
>( rAny.pData )->
operator == ( value );
656 rAny.pData, rAny.pType,
665 return (!
operator == ( rAny, value ));
668 template <
typename T>
672 if (! (*
this >>= value)) {
673 throw RuntimeException(
683 #if defined LIBO_INTERNAL_ONLY
693 template<
typename charT,
typename traits>
694 inline std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> &o,
Any const &any) {
696 switch(any.pType->eTypeClass) {
700 o <<
' ' << any.
get<
bool>();
706 o <<
' ' << any.
get<sal_Int64>();
711 o <<
' ' << any.
get<sal_uInt64>();
715 o <<
' ' << any.
get<
double>();
718 std::ios_base::fmtflags flgs = o.setf(
719 std::ios_base::hex, std::ios_base::basefield);
720 charT fill = o.fill(
'0');
721 o <<
" U+" << std::setw(4)
739 o << ' ' << *static_cast<sal_Int32 const *>(any.
getValue());
746 o << ' ' << *static_cast<void * const *>(any.
getValue());
763 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:356
unsigned char sal_Bool
Definition: types.h:38
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:334
sal_uInt16 sal_Unicode
Definition: types.h:123
signed char sal_Int8
Definition: types.h:43
@ typelib_TypeClass_VOID
type class of void
Definition: typeclass.h:32
@ typelib_TypeClass_UNSIGNED_SHORT
type class of unsigned short
Definition: typeclass.h:42
@ typelib_TypeClass_STRUCT
type class of struct
Definition: typeclass.h:66
@ typelib_TypeClass_CHAR
type class of char
Definition: typeclass.h:34
@ typelib_TypeClass_HYPER
type class of hyper
Definition: typeclass.h:48
@ typelib_TypeClass_BYTE
type class of byte
Definition: typeclass.h:38
@ typelib_TypeClass_BOOLEAN
type class of boolean
Definition: typeclass.h:36
@ typelib_TypeClass_INTERFACE
type class of interface
Definition: typeclass.h:82
@ typelib_TypeClass_STRING
type class of string
Definition: typeclass.h:56
@ typelib_TypeClass_SHORT
type class of short
Definition: typeclass.h:40
@ typelib_TypeClass_FLOAT
type class of float
Definition: typeclass.h:52
@ typelib_TypeClass_DOUBLE
type class of double
Definition: typeclass.h:54
@ typelib_TypeClass_TYPE
type class of type
Definition: typeclass.h:58
@ typelib_TypeClass_UNSIGNED_HYPER
type class of unsigned hyper
Definition: typeclass.h:50
@ typelib_TypeClass_SEQUENCE
type class of sequence
Definition: typeclass.h:75
@ typelib_TypeClass_LONG
type class of long
Definition: typeclass.h:44
@ typelib_TypeClass_ENUM
type class of enum
Definition: typeclass.h:62
@ typelib_TypeClass_UNSIGNED_LONG
type class of unsigned long
Definition: typeclass.h:46
@ typelib_TypeClass_EXCEPTION
type class of exception
Definition: typeclass.h:73
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescription typelib_TypeDescription
Full type description of a type.
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
CPPU_DLLPUBLIC void uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Destructs an any.
CPPU_DLLPUBLIC void uno_any_construct(uno_Any *pDest, void *pSource, struct _typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
Constructs an any with a given value.
CPPU_DLLPUBLIC void uno_type_any_construct(uno_Any *pDest, void *pSource, struct _typelib_TypeDescriptionReference *pType, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
Constructs an any with a given value.
struct SAL_DLLPUBLIC_RTTI _uno_Any uno_Any
This is the binary specification of a UNO any.
CPPU_DLLPUBLIC void uno_type_any_assign(uno_Any *pDest, void *pSource, struct _typelib_TypeDescriptionReference *pType, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Assign an any with a given value.
CPPU_DLLPUBLIC void uno_any_clear(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Sets value to void.
CPPU_DLLPUBLIC void uno_any_assign(uno_Any *pDest, void *pSource, struct _typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Assign an any with a given value.
CPPU_DLLPUBLIC sal_Bool uno_type_isAssignableFromData(struct _typelib_TypeDescriptionReference *pAssignable, void *pFrom, struct _typelib_TypeDescriptionReference *pFromType, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Tests whether a value of given type is assignable from given value.
CPPU_DLLPUBLIC sal_Bool uno_type_equalData(void *pVal1, struct _typelib_TypeDescriptionReference *pVal1Type, void *pVal2, struct _typelib_TypeDescriptionReference *pVal2Type, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Tests if two values are equal.
CPPU_DLLPUBLIC sal_Bool uno_type_assignData(void *pDest, struct _typelib_TypeDescriptionReference *pDestType, void *pSource, struct _typelib_TypeDescriptionReference *pSourceType, uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Assigns a destination value with a source value.
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:13
CPPU_DLLPUBLIC rtl_uString * cppu_Any_extraction_failure_msg(uno_Any const *pAny, typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
Definition: bootstrap.hxx:34
bool operator==(const Any &rAny, const C &value)
Template equality operator: compares set value of left side any to right side value.
Definition: Any.hxx:652
Any makeAny(const C &value)
Template function to generically construct an any from a C++ value.
Definition: Any.hxx:234
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:663
bool operator>>=(const Any &rAny, C &value)
Template binary >>= operator to assign a value from an any.
Definition: Any.hxx:323
void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition: genfunc.hxx:50
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &o, Any const &any)
Support for Any in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: Any.hxx:694
void * cpp_queryInterface(void *pCppI, typelib_TypeDescriptionReference *pType)
Function to query for a C++ interface.
Definition: genfunc.hxx:55
void cpp_acquire(void *pCppI)
Function to acquire a C++ interface.
Definition: genfunc.hxx:45
Any toAny(T const &value)
Wrap a value in an Any, if necessary.
Definition: Any.hxx:243
void operator<<=(Any &rAny, const C &value)
Template binary <<= operator to set the value of an any.
Definition: Any.hxx:273
css::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:324
rtl::OUString getTypeName(rtl::OUString const &rEnvDcp)
Get the OBI type part of an environment descriptor.
Definition: EnvDcp.hxx:41
This is the binary specification of a SAL sequence.
Definition: types.h:304
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:203
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:290
C++ class representing an IDL any.
Definition: Any.h:57
bool has() const
Tests whether this any can provide a value of specified type.
Definition: Any.hxx:204
T get() const
Provides a value of specified type, so you can easily write e.g.
Definition: Any.hxx:669
bool operator!=(const Any &rAny) const
Inequality operator: compares two anys.
Definition: Any.hxx:224
Any & operator=(const Any &rAny)
Assignment operator: Sets the value of the given any.
Definition: Any.hxx:121
inline ::rtl::OUString getValueTypeName() const
Gets the type name of the set value.
Definition: Any.hxx:163
bool operator==(const Any &rAny) const
Equality operator: compares two anys.
Definition: Any.hxx:217
const void * getValue() const
Gets a pointer to the set value.
Definition: Any.h:196
void setValue(const void *pData_, const Type &rType)
Sets a value.
Definition: Any.hxx:168
bool isExtractableTo(const Type &rType) const
Tests whether this any is extractable to a value of given type.
Definition: Any.hxx:195
~Any()
Destructor: Destructs any content and frees memory.
Definition: Any.hxx:115
void clear()
Clears this any.
Definition: Any.hxx:189
Any()
Default constructor: Any holds no value; its type is void.
Definition: Any.hxx:59
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:67
C++ class representing an IDL meta type.
Definition: Type.h:59
bool equals(const Type &rType) const
Compares two types.
Definition: Type.h:181
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:162