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))) {}
89 template <std::
size_t N>
90 Any::Any(
const rtl::OUStringLiteral<N>& value): Any(
rtl::OUString(value)) {}
108 this, const_cast< void * >( pData_ ), pTypeDescr,
cpp_acquire );
114 this, const_cast< void * >( pData_ ), pType_,
cpp_acquire );
128 this, rAny.pData, rAny.pType,
134 #if defined LIBO_INTERNAL_ONLY 138 std::swap(other.pType, pType);
139 std::swap(other.pData, pData);
140 std::swap(other.pReserved, pReserved);
141 if (pData == &other.pReserved) {
151 std::swap(other.pType, pType);
152 std::swap(other.pData, pData);
153 std::swap(other.pReserved, pReserved);
154 if (pData == &other.pReserved) {
157 if (other.pData == &pReserved) {
158 other.pData = &other.pReserved;
167 return ::rtl::OUString( pType->pTypeName );
180 this, const_cast< void * >( pData_ ), pType_,
187 this, const_cast< void * >( pData_ ), pTypeDescr,
205 template <
typename T>
215 #if defined LIBO_INTERNAL_ONLY 216 template<>
bool Any::has<Any>()
const =
delete;
222 pData, pType, rAny.pData, rAny.pType,
229 pData, pType, rAny.pData, rAny.pType,
234 #if !defined LIBO_INTERNAL_ONLY 251 #if defined LIBO_INTERNAL_ONLY 253 template<
typename T1,
typename T2>
254 Any
toAny(rtl::OUStringConcat<T1, T2> && value)
255 {
return Any(std::move(value)); }
258 Any
toAny(rtl::OUStringNumber<T> && value)
259 {
return Any(std::move(value)); }
261 template<
typename T>
bool fromAny(Any
const & any, T * value) {
262 assert(value !=
nullptr);
263 return any >>= *value;
266 template<>
bool fromAny(Any
const & any, Any * value) {
267 assert(value !=
nullptr);
295 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 296 template<
class C1,
class C2 >
297 inline void operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& value )
302 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
305 template<
typename T1,
typename T2>
306 void operator <<=(Any &, rtl::OUStringConcat<T1, T2>
const &) =
delete;
308 inline void operator <<= ( Any & rAny, rtl::OUStringNumber< C >&& value )
313 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
317 void operator <<=(Any &, rtl::OUStringNumber<T>
const &) =
delete;
320 #if defined LIBO_INTERNAL_ONLY 321 template<>
void SAL_CALL
operator <<=(Any &, Any
const &) =
delete;
330 rAny.pData, rAny.pType,
342 value = bool(* static_cast< const sal_Bool * >( rAny.pData ));
352 bool(value) ==
bool(* static_cast< const sal_Bool * >( rAny.pData )));
361 value = *
static_cast< sal_Bool const *
>( rAny.pData );
373 bool(*static_cast< sal_Bool const * >( rAny.pData ))));
383 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
393 switch (rAny.pType->eTypeClass)
396 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
400 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
410 switch (rAny.pType->eTypeClass)
413 value =
static_cast<sal_uInt16
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
417 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
428 switch (rAny.pType->eTypeClass)
431 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
434 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
437 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
441 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
451 switch (rAny.pType->eTypeClass)
454 value =
static_cast<sal_uInt32
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
457 value =
static_cast<sal_uInt32
>( *
static_cast< const sal_Int16 *
>( rAny.pData ) );
460 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
464 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
475 switch (rAny.pType->eTypeClass)
478 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
481 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
484 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
487 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
490 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
494 value = *
static_cast< const sal_Int64 *
>( rAny.pData );
504 switch (rAny.pType->eTypeClass)
507 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
510 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int16 *
>( rAny.pData ) );
513 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
516 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int32 *
>( rAny.pData ) );
519 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
523 value = *
static_cast< const sal_uInt64 *
>( rAny.pData );
534 switch (rAny.pType->eTypeClass)
537 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
540 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
543 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
546 value = *
static_cast< const float *
>( rAny.pData );
557 switch (rAny.pType->eTypeClass)
560 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
563 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
566 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
569 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
572 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
575 value = *
static_cast< const float *
>( rAny.pData );
578 value = *
static_cast< const double *
>( rAny.pData );
591 value = *
static_cast< const ::
rtl::OUString *
>( rAny.pData );
598 inline bool SAL_CALL
operator == (
const Any & rAny, const ::rtl::OUString & value )
601 value == * static_cast< const ::rtl::OUString * >( rAny.pData ) );
604 #if defined LIBO_INTERNAL_ONLY 605 template<std::
size_t N>
606 inline bool SAL_CALL
operator == (
const Any& rAny,
const rtl::OUStringLiteral<N>& value)
618 value = *
static_cast< const Type *
>( rAny.pData );
628 value.
equals( * static_cast< const Type * >( rAny.pData ) ));
632 #if defined LIBO_INTERNAL_ONLY 633 template<>
bool SAL_CALL
operator >>=(Any
const &, Any &) =
delete;
641 &value, rAny.pData, rAny.pType,
654 return static_cast< const BaseReference *
>( rAny.pData )->
operator == ( value );
666 rAny.pData, rAny.pType,
675 return (!
operator == ( rAny, value ));
678 template <
typename T>
682 if (! (*
this >>= value)) {
683 throw RuntimeException(
693 #if defined LIBO_INTERNAL_ONLY 703 template<
typename charT,
typename traits>
704 inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o,
Any const &any) {
706 switch(any.pType->eTypeClass) {
710 o <<
' ' << any.get<
bool>();
716 o <<
' ' << any.get<sal_Int64>();
721 o <<
' ' << any.get<sal_uInt64>();
725 o <<
' ' << any.get<
double>();
728 std::ios_base::fmtflags flgs = o.setf(
729 std::ios_base::hex, std::ios_base::basefield);
730 charT fill = o.fill(
'0');
731 o <<
" U+" << std::setw(4)
732 << unsigned(*static_cast<sal_Unicode const *>(any.getValue()));
741 o <<
' ' << any.get<css::uno::Type>().
getTypeName();
745 << ((*
static_cast<uno_Sequence *
const *
>(any.getValue()))->
749 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
753 o <<
' ' << any.getValue();
756 o << ' ' << *static_cast<void * const *>(any.getValue());
773 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition: genfunc.hxx:50
type class of float
Definition: typeclass.h:52
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:334
T get() const
Provides a value of specified type, so you can easily write e.g.
Definition: Any.hxx:679
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.
bool equals(const Type &rType) const
Compares two types.
Definition: Type.h:181
Any()
Default constructor: Any holds no value; its type is void.
Definition: Any.hxx:59
Any & operator=(const Any &rAny)
Assignment operator: Sets the value of the given any.
Definition: Any.hxx:123
CPPU_DLLPUBLIC rtl_uString * cppu_Any_extraction_failure_msg(uno_Any const *pAny, typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
bool has() const
Tests whether this any can provide a value of specified type.
Definition: Any.hxx:206
signed char sal_Int8
Definition: types.h:43
void setValue(const void *pData_, const Type &rType)
Sets a value.
Definition: Any.hxx:170
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:162
Any toAny(T const &value)
Wrap a value in an Any, if necessary.
Definition: Any.hxx:245
This is the binary specification of a SAL sequence.
Definition: types.h:303
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:673
type class of enum
Definition: typeclass.h:62
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:662
type class of boolean
Definition: typeclass.h:36
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
void clear()
Clears this any.
Definition: Any.hxx:191
void * cpp_queryInterface(void *pCppI, typelib_TypeDescriptionReference *pType)
Function to query for a C++ interface.
Definition: genfunc.hxx:55
type class of exception
Definition: typeclass.h:73
bool operator>>=(const Any &rAny, C &value)
Template binary >>= operator to assign a value from an any.
Definition: Any.hxx:325
bool operator!=(const Any &rAny) const
Inequality operator: compares two anys.
Definition: Any.hxx:226
C++ class representing an IDL any.
Definition: Any.h:56
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 byte
Definition: typeclass.h:38
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:13
rtl::OUString getTypeName(rtl::OUString const &rEnvDcp)
Get the OBI type part of an environment descriptor.
Definition: EnvDcp.hxx:41
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 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 unsigned long
Definition: typeclass.h:46
type class of struct
Definition: typeclass.h:66
type class of short
Definition: typeclass.h:40
inline ::rtl::OUString getValueTypeName() const
Gets the type name of the set value.
Definition: Any.hxx:165
unsigned char sal_Bool
Definition: types.h:38
void cpp_acquire(void *pCppI)
Function to acquire a C++ interface.
Definition: genfunc.hxx:45
type class of void
Definition: typeclass.h:32
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.
void operator<<=(Any &rAny, const C &value)
Template binary <<= operator to set the value of an any.
Definition: Any.hxx:275
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescription typelib_TypeDescription
Full type description of a type.
type class of double
Definition: typeclass.h:54
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:51
Definition: bootstrap.hxx:33
bool operator==(const Any &rAny) const
Equality operator: compares two anys.
Definition: Any.hxx:219
~Any()
Destructor: Destructs any content and frees memory.
Definition: Any.hxx:117
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.
type class of unsigned hyper
Definition: typeclass.h:50
type class of interface
Definition: typeclass.h:82
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:202
definition of a no acquire enum for ctors
Definition: types.h:356
type class of unsigned short
Definition: typeclass.h:42
type class of string
Definition: typeclass.h:56
type class of char
Definition: typeclass.h:34
CPPU_DLLPUBLIC void uno_any_clear(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Sets value to void.
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:66
type class of long
Definition: typeclass.h:44
type class of hyper
Definition: typeclass.h:48
type class of sequence
Definition: typeclass.h:75
struct SAL_DLLPUBLIC_RTTI _uno_Any uno_Any
This is the binary specification of a UNO any.
css::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:324
bool isExtractableTo(const Type &rType) const
Tests whether this any is extractable to a value of given type.
Definition: Any.hxx:197
C++ class representing an IDL meta type.
Definition: Type.h:58
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 type
Definition: typeclass.h:58
Any makeAny(const C &value)
Template function to generically construct an any from a C++ value.
Definition: Any.hxx:236