19 #ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
20 #define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
34 #include <com/sun/star/uno/RuntimeException.hpp>
57 this, const_cast<T *>(&value),
127 this, const_cast< void * >( pData_ ), pType_,
134 this, const_cast< void * >( pData_ ), pTypeDescr,
152 template <
typename T>
193 #ifdef RTL_FAST_STRING
194 template<
class C1,
class C2 >
195 inline Any SAL_CALL
makeAny(
const rtl::OUStringConcat< C1, C2 >& value )
223 #ifdef RTL_FAST_STRING
224 template<
class C1,
class C2 >
225 inline void SAL_CALL operator <<= ( Any & rAny, const rtl::OUStringConcat< C1, C2 >& value )
230 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
272 value = *
reinterpret_cast< sal_Bool const *
>(
285 (*reinterpret_cast< sal_Bool const * >( rAny.
pData )
296 value = *
reinterpret_cast< const sal_Int8 *
>( rAny.pData );
309 value = *
reinterpret_cast< const sal_Int8 *
>( rAny.
pData );
313 value = *
reinterpret_cast< const sal_Int16 *
>( rAny.
pData );
326 value = (sal_uInt16)( * reinterpret_cast< const sal_Int8 * >( rAny.
pData ) );
330 value = *
reinterpret_cast< const sal_uInt16 *
>( rAny.
pData );
344 value = *
reinterpret_cast< const sal_Int8 *
>( rAny.
pData );
347 value = *
reinterpret_cast< const sal_Int16 *
>( rAny.
pData );
350 value = *
reinterpret_cast< const sal_uInt16 *
>( rAny.
pData );
354 value = *
reinterpret_cast< const sal_Int32 *
>( rAny.
pData );
367 value = (sal_uInt32)( * reinterpret_cast< const sal_Int8 * >( rAny.
pData ) );
370 value = (sal_uInt32)( * reinterpret_cast< const sal_Int16 * >( rAny.
pData ) );
373 value = *
reinterpret_cast< const sal_uInt16 *
>( rAny.
pData );
377 value = *
reinterpret_cast< const sal_uInt32 *
>( rAny.
pData );
391 value = *
reinterpret_cast< const sal_Int8 *
>( rAny.
pData );
394 value = *
reinterpret_cast< const sal_Int16 *
>( rAny.
pData );
397 value = *
reinterpret_cast< const sal_uInt16 *
>( rAny.
pData );
400 value = *
reinterpret_cast< const sal_Int32 *
>( rAny.
pData );
403 value = *
reinterpret_cast< const sal_uInt32 *
>( rAny.
pData );
407 value = *
reinterpret_cast< const sal_Int64 *
>( rAny.
pData );
420 value = (sal_uInt64)( * reinterpret_cast< const sal_Int8 * >( rAny.
pData ) );
423 value = (sal_uInt64)( * reinterpret_cast< const sal_Int16 * >( rAny.
pData ) );
426 value = *
reinterpret_cast< const sal_uInt16 *
>( rAny.
pData );
429 value = (sal_uInt64)( * reinterpret_cast< const sal_Int32 * >( rAny.
pData ) );
432 value = *
reinterpret_cast< const sal_uInt32 *
>( rAny.
pData );
436 value = *
reinterpret_cast< const sal_uInt64 *
>( rAny.
pData );
450 value = *
reinterpret_cast< const sal_Int8 *
>( rAny.
pData );
453 value = *
reinterpret_cast< const sal_Int16 *
>( rAny.
pData );
456 value = *
reinterpret_cast< const sal_uInt16 *
>( rAny.
pData );
459 value = *
reinterpret_cast< const float *
>( rAny.
pData );
473 value = *
reinterpret_cast< const sal_Int8 *
>( rAny.
pData );
476 value = *
reinterpret_cast< const sal_Int16 *
>( rAny.
pData );
479 value = *
reinterpret_cast< const sal_uInt16 *
>( rAny.
pData );
482 value = *
reinterpret_cast< const sal_Int32 *
>( rAny.
pData );
485 value = *
reinterpret_cast< const sal_uInt32 *
>( rAny.
pData );
488 value = *
reinterpret_cast< const float *
>( rAny.
pData );
491 value = *
reinterpret_cast< const double *
>( rAny.
pData );
511 inline bool SAL_CALL
operator == (
const Any & rAny, const ::rtl::OUString & value )
514 value.equals( * reinterpret_cast< const ::rtl::OUString * >( rAny.
pData ) ));
523 value = *
reinterpret_cast< const Type *
>( rAny.
pData );
533 value.
equals( * reinterpret_cast< const Type * >( rAny.
pData ) ));
555 return reinterpret_cast< const BaseReference *
>( rAny.
pData )->
operator == ( value );
576 return (!
operator == ( rAny, value ));
584 template <
typename T>
588 if (! (*
this >>= value)) {
589 throw RuntimeException(
605 template<
typename charT,
typename traits>
606 inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o,
Any const &any) {
608 switch(any.pType->eTypeClass) {
612 o <<
' ' << any.get<
bool>();
618 o <<
' ' << any.get<sal_Int64>();
623 o <<
' ' << any.get<sal_uInt64>();
627 o <<
' ' << any.get<
double>();
630 std::ios_base::fmtflags flgs = o.setf(
631 std::ios_base::hex, std::ios_base::basefield);
632 charT fill = o.fill(
'0');
633 o <<
" U+" << std::setw(4)
634 << *
static_cast<sal_Unicode const *
>(any.getValue());
643 o <<
' ' << any.get<css::uno::Type>().
getTypeName();
647 << ((*
static_cast<uno_Sequence *
const *
>(any.getValue()))->
651 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
655 o <<
' ' << any.getValue();
658 o << ' ' << *static_cast<void * const *>(any.getValue());
675 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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:563
type class of exception
Definition: typeclass.h:70
bool has() const
Tests whether this any can provide a value of specified type.
Definition: Any.hxx:153
definition of a no acquire enum for ctors
Definition: types.h:372
type class of unsigned long
Definition: typeclass.h:43
unsigned char sal_Bool
Definition: types.h:48
void *(* uno_QueryInterfaceFunc)(void *pInterface, struct _typelib_TypeDescriptionReference *pType)
Generic function pointer declaration to query for an interface.
Definition: data.h:40
type class of unsigned short
Definition: typeclass.h:39
type class of void
Definition: typeclass.h:29
type class of string
Definition: typeclass.h:53
const ::com::sun::star::uno::Type & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:110
type class of char
Definition: typeclass.h:31
bool operator!=(const Any &rAny) const
Unequality operator: compares two anys.
Definition: Any.hxx:169
type class of struct
Definition: typeclass.h:63
#define sal_False
Definition: types.h:49
type class of double
Definition: typeclass.h:51
void * cpp_queryInterface(void *pCppI, typelib_TypeDescriptionReference *pType)
Function to query for a C++ interface.
Definition: genfunc.hxx:47
void operator<<=(Any &rAny, const C &value)
Template binary <<= operator to set the value of an any.
Definition: Any.hxx:203
CPPU_DLLPUBLIC void uno_any_clear(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Sets value to void.
type class of interface
Definition: typeclass.h:79
CPPU_DLLPUBLIC void uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Destructs an any.
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.
rtl_uString * pTypeName
fully qualified name of type
Definition: typedescription.h:55
type class of long
Definition: typeclass.h:41
~Any()
Destructor: Destructs any content and frees memory.
Definition: Any.hxx:95
type class of unsigned hyper
Definition: typeclass.h:47
rtl::OUString getTypeName(rtl::OUString const &rEnvDcp)
Get the OBI type part of an environment descriptor.
Definition: EnvDcp.hxx:38
void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition: genfunc.hxx:42
struct _typelib_TypeDescriptionReference * pType
type of value
Definition: any2.h:44
Any()
Default constructor: Any holds no value; its type is void.
Definition: Any.hxx:47
Holds a weak reference to a type description.
Definition: typedescription.h:40
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:154
type class of type
Definition: typeclass.h:55
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:574
This is the binary specification of a SAL sequence.
Definition: types.h:329
bool equals(const Type &rType) const
Compares two types.
Definition: Type.h:173
bool operator==(const Any &rAny) const
Equality operator: compares two anys.
Definition: Any.hxx:162
type class of sequence
Definition: typeclass.h:72
type class of hyper
Definition: typeclass.h:45
C++ class representing an IDL meta type.
Definition: Type.h:54
rtl_uString * cppu_Any_extraction_failure_msg(uno_Any const *pAny, typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
signed char sal_Int8
Definition: types.h:53
type class of boolean
Definition: typeclass.h:33
C++ class representing an IDL any.
Definition: Any.h:49
type class of float
Definition: typeclass.h:49
Full type description of a type.
Definition: typedescription.h:71
::com::sun::star::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:287
void(* uno_AcquireFunc)(void *pInterface)
Generic function pointer declaration to acquire an interface.
Definition: data.h:46
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:57
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:81
void setValue(const void *pData_, const Type &rType)
Sets a value.
Definition: Any.hxx:117
bool isExtractableTo(const Type &rType) const
Tests whether this any is extractable to a value of given type.
Definition: Any.hxx:144
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 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 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 clear()
Clears this any.
Definition: Any.hxx:138
inline::rtl::OUString getValueTypeName() const
Gets the type name of the set value.
Definition: Any.hxx:112
sal_uInt16 sal_Unicode
Definition: types.h:152
void cpp_acquire(void *pCppI)
Function to acquire a C++ interface.
Definition: genfunc.hxx:37
Any makeAny(const C &value)
Template function to generically construct an any from a C++ value.
Definition: Any.hxx:178
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.
type class of short
Definition: typeclass.h:37
void(* uno_ReleaseFunc)(void *pInterface)
Generic function pointer declaration to release an interface.
Definition: data.h:52
This is the binary specification of an UNO any.
Definition: any2.h:40
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:354
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.
Any & operator=(const Any &rAny)
Assignment operator: Sets the value of the given any.
Definition: Any.hxx:101
bool operator>>=(const Any &rAny, C &value)
Template binary >>= operator to assign a value from an any.
Definition: Any.hxx:236
typelib_TypeClass eTypeClass
type class of type
Definition: typedescription.h:52
void * pData
pointer to value; this may point to pReserved and thus the uno_Any is not anytime mem-copyable! You m...
Definition: any2.h:49
type class of enum
Definition: typeclass.h:59
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.
type class of byte
Definition: typeclass.h:35
T get() const
Provides a value of specified type, so you can easily write e.g.
Definition: Any.hxx:585