19 #ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
20 #define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
36 #include <com/sun/star/uno/RuntimeException.hpp>
64 this, const_cast<T *>(&value),
77 #if defined LIBO_INTERNAL_ONLY
78 template<
typename T1,
typename T2>
79 Any::Any(rtl::OUStringConcat<T1, T2>
const & value):
Any(rtl::OUString(value))
98 this, const_cast< void * >( pData_ ), pTypeDescr,
cpp_acquire );
104 this, const_cast< void * >( pData_ ), pType_,
cpp_acquire );
118 this, rAny.pData, rAny.pType,
124 #if defined LIBO_INTERNAL_ONLY
128 inline void moveAnyInternals(
Any & from,
Any & to) {
130 std::swap(from.pType, to.pType);
131 std::swap(from.pData, to.pData);
132 std::swap(from.pReserved, to.pReserved);
133 if (to.pData == &from.pReserved) {
134 to.pData = &to.pReserved;
145 detail::moveAnyInternals(other, *
this);
150 detail::moveAnyInternals(other, *
this);
158 return ::rtl::OUString( pType->pTypeName );
171 this, const_cast< void * >( pData_ ), pType_,
178 this, const_cast< void * >( pData_ ), pTypeDescr,
196 template <
typename T>
206 #if defined LIBO_INTERNAL_ONLY
207 template<>
bool Any::has<Any>()
const =
delete;
213 pData, pType, rAny.pData, rAny.pType,
220 pData, pType, rAny.pData, rAny.pType,
231 #if !defined LIBO_INTERNAL_ONLY
240 #if defined LIBO_INTERNAL_ONLY
242 template<
typename T>
bool fromAny(Any
const & any, T * value) {
243 assert(value !=
nullptr);
244 return any >>= *value;
247 template<>
bool fromAny(Any
const & any, Any * value) {
248 assert(value !=
nullptr);
276 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
277 template<
class C1,
class C2 >
278 inline void SAL_CALL operator <<= ( Any & rAny, const rtl::OUStringConcat< C1, C2 >& value )
283 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
288 #if defined LIBO_INTERNAL_ONLY
289 template<>
void SAL_CALL
operator <<=(Any &, Any
const &) =
delete;
298 rAny.pData, rAny.pType,
310 value = bool(* static_cast< const sal_Bool * >( rAny.pData ));
320 bool(value) ==
bool(* static_cast< const sal_Bool * >( rAny.pData )));
329 value = *
static_cast< sal_Bool const *
>( rAny.pData );
341 bool(*static_cast< sal_Bool const * >( rAny.pData ))));
351 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
361 switch (rAny.pType->eTypeClass)
364 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
368 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
378 switch (rAny.pType->eTypeClass)
381 value = (sal_uInt16)( * static_cast< const sal_Int8 * >( rAny.pData ) );
385 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
396 switch (rAny.pType->eTypeClass)
399 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
402 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
405 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
409 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
419 switch (rAny.pType->eTypeClass)
422 value = (sal_uInt32)( * static_cast< const sal_Int8 * >( rAny.pData ) );
425 value = (sal_uInt32)( * static_cast< const sal_Int16 * >( rAny.pData ) );
428 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
432 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
443 switch (rAny.pType->eTypeClass)
446 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
449 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
452 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
455 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
458 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
462 value = *
static_cast< const sal_Int64 *
>( rAny.pData );
472 switch (rAny.pType->eTypeClass)
475 value = (sal_uInt64)( * static_cast< const sal_Int8 * >( rAny.pData ) );
478 value = (sal_uInt64)( * static_cast< const sal_Int16 * >( rAny.pData ) );
481 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
484 value = (sal_uInt64)( * static_cast< const sal_Int32 * >( rAny.pData ) );
487 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
491 value = *
static_cast< const sal_uInt64 *
>( rAny.pData );
502 switch (rAny.pType->eTypeClass)
505 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
508 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
511 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
514 value = *
static_cast< const float *
>( rAny.pData );
525 switch (rAny.pType->eTypeClass)
528 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
531 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
534 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
537 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
540 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
543 value = *
static_cast< const float *
>( rAny.pData );
546 value = *
static_cast< const double *
>( rAny.pData );
559 value = *
static_cast< const ::
rtl::OUString *
>( rAny.pData );
566 inline bool SAL_CALL
operator == (
const Any & rAny, const ::rtl::OUString & value )
569 value.equals( * static_cast< const ::rtl::OUString * >( rAny.pData ) ));
578 value = *
static_cast< const Type *
>( rAny.pData );
588 value.
equals( * static_cast< const Type * >( rAny.pData ) ));
592 #if defined LIBO_INTERNAL_ONLY
593 template<>
bool SAL_CALL
operator >>=(Any
const &, Any &) =
delete;
601 &value, rAny.pData, rAny.pType,
614 return static_cast< const BaseReference *
>( rAny.pData )->
operator == ( value );
626 rAny.pData, rAny.pType,
635 return (!
operator == ( rAny, value ));
638 template <
typename T>
642 if (! (*
this >>= value)) {
643 throw RuntimeException(
653 #if defined LIBO_INTERNAL_ONLY
663 template<
typename charT,
typename traits>
664 inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o,
Any const &any) {
666 switch(any.pType->eTypeClass) {
670 o <<
' ' << any.get<
bool>();
676 o <<
' ' << any.get<sal_Int64>();
681 o <<
' ' << any.get<sal_uInt64>();
685 o <<
' ' << any.get<
double>();
688 std::ios_base::fmtflags flgs = o.setf(
689 std::ios_base::hex, std::ios_base::basefield);
690 charT fill = o.fill(
'0');
691 o <<
" U+" << std::setw(4)
692 << *
static_cast<sal_Unicode const *
>(any.getValue());
701 o <<
' ' << any.get<css::uno::Type>().
getTypeName();
705 << ((*
static_cast<uno_Sequence *
const *
>(any.getValue()))->
709 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
713 o <<
' ' << any.getValue();
716 o << ' ' << *static_cast<void * const *>(any.getValue());
733 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
type class of double
Definition: typeclass.h:51
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:622
type class of unsigned long
Definition: typeclass.h:43
type class of short
Definition: typeclass.h:37
type class of unsigned hyper
Definition: typeclass.h:47
type class of unsigned short
Definition: typeclass.h:39
CPPU_DLLPUBLIC void uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Destructs an any.
CPPU_DLLPUBLIC void uno_any_clear(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Sets value to void.
inline::rtl::OUString getValueTypeName() const
Gets the type name of the set value.
Definition: Any.hxx:156
bool isExtractableTo(const Type &rType) const
Tests whether this any is extractable to a value of given type.
Definition: Any.hxx:188
void * cpp_queryInterface(void *pCppI, typelib_TypeDescriptionReference *pType)
Function to query for a C++ interface.
Definition: genfunc.hxx:51
void operator<<=(Any &rAny, const C &value)
Template binary <<= operator to set the value of an any.
Definition: Any.hxx:256
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:10
Any & operator=(const Any &rAny)
Assignment operator: Sets the value of the given any.
Definition: Any.hxx:113
type class of interface
Definition: typeclass.h:79
type class of sequence
Definition: typeclass.h:72
css::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:320
C++ class representing an IDL any.
Definition: Any.h:52
type class of hyper
Definition: typeclass.h:45
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.
bool has() const
Tests whether this any can provide a value of specified type.
Definition: Any.hxx:197
~Any()
Destructor: Destructs any content and frees memory.
Definition: Any.hxx:107
bool operator==(const Any &rAny) const
Equality operator: compares two anys.
Definition: Any.hxx:210
struct SAL_DLLPUBLIC_RTTI _uno_Any uno_Any
This is the binary specification of an UNO any.
bool operator!=(const Any &rAny) const
Unequality operator: compares two anys.
Definition: Any.hxx:217
type class of long
Definition: typeclass.h:41
type class of string
Definition: typeclass.h:53
void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition: genfunc.hxx:46
unsigned char sal_Bool
Definition: types.h:48
type class of type
Definition: typeclass.h:55
type class of char
Definition: typeclass.h:31
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.
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:154
CPPU_DLLPUBLIC rtl_uString * cppu_Any_extraction_failure_msg(uno_Any const *pAny, typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:633
bool equals(const Type &rType) const
Compares two types.
Definition: Type.h:173
C++ class representing an IDL meta type.
Definition: Type.h:54
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.
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescription typelib_TypeDescription
Full type description of a type.
signed char sal_Int8
Definition: types.h:53
sal_uInt16 sal_Unicode
Definition: types.h:155
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.
Any()
Default constructor: Any holds no value; its type is void.
Definition: Any.hxx:54
type class of boolean
Definition: typeclass.h:33
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.
void setValue(const void *pData_, const Type &rType)
Sets a value.
Definition: Any.hxx:161
CPPU_DLLPUBLIC void SAL_THROW_EXTERN_C()
This method is called to wait for a reply of a previously sent request.
This is the binary specification of a SAL sequence.
Definition: types.h:345
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:106
definition of a no acquire enum for ctors
Definition: types.h:388
type class of float
Definition: typeclass.h:49
rtl::OUString getTypeName(rtl::OUString const &rEnvDcp)
Get the OBI type part of an environment descriptor.
Definition: EnvDcp.hxx:38
void cpp_acquire(void *pCppI)
Function to acquire a C++ interface.
Definition: genfunc.hxx:41
Any makeAny(const C &value)
Template function to generically construct an any from a C++ value.
Definition: Any.hxx:226
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:58
type class of struct
Definition: typeclass.h:63
Any toAny(T const &value)
Wrap a value in an Any, if necessary.
Definition: Any.hxx:236
T get() const
Provides a value of specified type, so you can easily write e.g.
Definition: Any.hxx:639
bool operator>>=(const Any &rAny, C &value)
Template binary >>= operator to assign a value from an any.
Definition: Any.hxx:293
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:47
type class of enum
Definition: typeclass.h:59
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.
type class of void
Definition: typeclass.h:29
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.
type class of byte
Definition: typeclass.h:35
void clear()
Clears this any.
Definition: Any.hxx:182
type class of exception
Definition: typeclass.h:70