19 #ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX 20 #define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX 37 #include "com/sun/star/uno/RuntimeException.hpp" 65 this, const_cast<T *>(&value),
78 #if defined LIBO_INTERNAL_ONLY 79 template<
typename T1,
typename T2>
80 Any::Any(rtl::OUStringConcat<T1, T2> && value):
81 Any(
rtl::OUString(std::move(value)))
100 this, const_cast< void * >( pData_ ), pTypeDescr,
cpp_acquire );
106 this, const_cast< void * >( pData_ ), pType_,
cpp_acquire );
120 this, rAny.pData, rAny.pType,
126 #if defined LIBO_INTERNAL_ONLY 130 inline void moveAnyInternals(
Any & from,
Any & to) noexcept {
132 std::swap(from.pType, to.pType);
133 std::swap(from.pData, to.pData);
134 std::swap(from.pReserved, to.pReserved);
135 if (to.pData == &from.pReserved) {
136 to.pData = &to.pReserved;
147 detail::moveAnyInternals(other, *
this);
152 detail::moveAnyInternals(other, *
this);
160 return ::rtl::OUString( pType->pTypeName );
173 this, const_cast< void * >( pData_ ), pType_,
180 this, const_cast< void * >( pData_ ), pTypeDescr,
198 template <
typename T>
208 #if defined LIBO_INTERNAL_ONLY 209 template<>
bool Any::has<Any>()
const =
delete;
215 pData, pType, rAny.pData, rAny.pType,
222 pData, pType, rAny.pData, rAny.pType,
233 #if !defined LIBO_INTERNAL_ONLY 242 #if defined LIBO_INTERNAL_ONLY 244 template<
typename T1,
typename T2>
245 Any
makeAny(rtl::OUStringConcat<T1, T2> && value)
246 {
return Any(std::move(value)); }
248 template<
typename T1,
typename T2>
249 Any
toAny(rtl::OUStringConcat<T1, T2> && value)
250 {
return makeAny(std::move(value)); }
253 Any
makeAny(rtl::OUStringNumber<T> && value)
254 {
return Any(OUString(std::move(value))); }
257 Any
toAny(rtl::OUStringNumber<T> && value)
258 {
return makeAny(std::move(value)); }
260 template<
typename T>
bool fromAny(Any
const & any, T * value) {
261 assert(value !=
nullptr);
262 return any >>= *value;
265 template<>
bool fromAny(Any
const & any, Any * value) {
266 assert(value !=
nullptr);
294 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" 295 template<
class C1,
class C2 >
296 inline void SAL_CALL operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& value )
301 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
304 template<
typename T1,
typename T2>
305 void operator <<=(Any &, rtl::OUStringConcat<T1, T2>
const &) =
delete;
307 inline void SAL_CALL operator <<= ( Any & rAny, rtl::OUStringNumber< C >&& value )
312 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
316 void operator <<=(Any &, rtl::OUStringNumber<T>
const &) =
delete;
319 #if defined LIBO_INTERNAL_ONLY 320 template<>
void SAL_CALL
operator <<=(Any &, Any
const &) =
delete;
329 rAny.pData, rAny.pType,
341 value = bool(* static_cast< const sal_Bool * >( rAny.pData ));
351 bool(value) ==
bool(* static_cast< const sal_Bool * >( rAny.pData )));
360 value = *
static_cast< sal_Bool const *
>( rAny.pData );
372 bool(*static_cast< sal_Bool const * >( rAny.pData ))));
382 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
392 switch (rAny.pType->eTypeClass)
395 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
399 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
409 switch (rAny.pType->eTypeClass)
412 value =
static_cast<sal_uInt16
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
416 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
427 switch (rAny.pType->eTypeClass)
430 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
433 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
436 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
440 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
450 switch (rAny.pType->eTypeClass)
453 value =
static_cast<sal_uInt32
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
456 value =
static_cast<sal_uInt32
>( *
static_cast< const sal_Int16 *
>( rAny.pData ) );
459 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
463 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
474 switch (rAny.pType->eTypeClass)
477 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
480 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
483 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
486 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
489 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
493 value = *
static_cast< const sal_Int64 *
>( rAny.pData );
503 switch (rAny.pType->eTypeClass)
506 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
509 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int16 *
>( rAny.pData ) );
512 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
515 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int32 *
>( rAny.pData ) );
518 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
522 value = *
static_cast< const sal_uInt64 *
>( rAny.pData );
533 switch (rAny.pType->eTypeClass)
536 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
539 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
542 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
545 value = *
static_cast< const float *
>( rAny.pData );
556 switch (rAny.pType->eTypeClass)
559 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
562 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
565 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
568 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
571 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
574 value = *
static_cast< const float *
>( rAny.pData );
577 value = *
static_cast< const double *
>( rAny.pData );
590 value = *
static_cast< const ::
rtl::OUString *
>( rAny.pData );
597 inline bool SAL_CALL
operator == (
const Any & rAny, const ::rtl::OUString & value )
600 value == * static_cast< const ::rtl::OUString * >( rAny.pData ) );
609 value = *
static_cast< const Type *
>( rAny.pData );
619 value.
equals( * static_cast< const Type * >( rAny.pData ) ));
623 #if defined LIBO_INTERNAL_ONLY 624 template<>
bool SAL_CALL
operator >>=(Any
const &, Any &) =
delete;
632 &value, rAny.pData, rAny.pType,
645 return static_cast< const BaseReference *
>( rAny.pData )->
operator == ( value );
657 rAny.pData, rAny.pType,
666 return (!
operator == ( rAny, value ));
669 template <
typename T>
673 if (! (*
this >>= value)) {
674 throw RuntimeException(
684 #if defined LIBO_INTERNAL_ONLY 694 template<
typename charT,
typename traits>
695 inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o,
Any const &any) {
697 switch(any.pType->eTypeClass) {
701 o <<
' ' << any.get<
bool>();
707 o <<
' ' << any.get<sal_Int64>();
712 o <<
' ' << any.get<sal_uInt64>();
716 o <<
' ' << any.get<
double>();
719 std::ios_base::fmtflags flgs = o.setf(
720 std::ios_base::hex, std::ios_base::basefield);
721 charT fill = o.fill(
'0');
722 o <<
" U+" << std::setw(4)
723 << unsigned(*static_cast<sal_Unicode const *>(any.getValue()));
732 o <<
' ' << any.get<css::uno::Type>().
getTypeName();
736 << ((*
static_cast<uno_Sequence *
const *
>(any.getValue()))->
740 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
744 o <<
' ' << any.getValue();
747 o << ' ' << *static_cast<void * const *>(any.getValue());
764 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition: genfunc.hxx:46
type class of float
Definition: typeclass.h:49
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:346
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.
Any & operator=(const Any &rAny)
Assignment operator: Sets the value of the given any.
Definition: Any.hxx:115
bool has() const
Tests whether this any can provide a value of specified type.
Definition: Any.hxx:199
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()
void clear()
Clears this any.
Definition: Any.hxx:184
signed char sal_Int8
Definition: types.h:43
Any toAny(T const &value)
Wrap a value in an Any, if necessary.
Definition: Any.hxx:238
Any()
Default constructor: Any holds no value; its type is void.
Definition: Any.hxx:55
This is the binary specification of a SAL sequence.
Definition: types.h:321
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:664
type class of enum
Definition: typeclass.h:59
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:653
type class of boolean
Definition: typeclass.h:33
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
void * cpp_queryInterface(void *pCppI, typelib_TypeDescriptionReference *pType)
Function to query for a C++ interface.
Definition: genfunc.hxx:51
void setValue(const void *pData_, const Type &rType)
Sets a value.
Definition: Any.hxx:163
type class of exception
Definition: typeclass.h:70
bool operator>>=(const Any &rAny, C &value)
Template binary >>= operator to assign a value from an any.
Definition: Any.hxx:324
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.
inline ::rtl::OUString getValueTypeName() const
Gets the type name of the set value.
Definition: Any.hxx:158
type class of byte
Definition: typeclass.h:35
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:10
rtl::OUString getTypeName(rtl::OUString const &rEnvDcp)
Get the OBI type part of an environment descriptor.
Definition: EnvDcp.hxx:38
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:43
type class of struct
Definition: typeclass.h:63
type class of short
Definition: typeclass.h:37
bool operator!=(const Any &rAny) const
Inequality operator: compares two anys.
Definition: Any.hxx:219
C++ class representing an IDL any.
Definition: Any.h:52
unsigned char sal_Bool
Definition: types.h:38
void cpp_acquire(void *pCppI)
Function to acquire a C++ interface.
Definition: genfunc.hxx:41
type class of void
Definition: typeclass.h:29
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:274
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescription typelib_TypeDescription
Full type description of a type.
type class of double
Definition: typeclass.h:51
Definition: bootstrap.hxx:29
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:47
type class of interface
Definition: typeclass.h:79
definition of a no acquire enum for ctors
Definition: types.h:374
type class of unsigned short
Definition: typeclass.h:39
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:47
type class of string
Definition: typeclass.h:53
bool operator==(const Any &rAny) const
Equality operator: compares two anys.
Definition: Any.hxx:212
~Any()
Destructor: Destructs any content and frees memory.
Definition: Any.hxx:109
type class of char
Definition: typeclass.h:31
CPPU_DLLPUBLIC void uno_any_clear(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Sets value to void.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:126
bool equals(const Type &rType) const
Compares two types.
Definition: Type.h:173
type class of long
Definition: typeclass.h:41
type class of hyper
Definition: typeclass.h:45
type class of sequence
Definition: typeclass.h:72
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:320
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.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.
T get() const
Provides a value of specified type, so you can easily write e.g.
Definition: Any.hxx:670
type class of type
Definition: typeclass.h:55
Any makeAny(const C &value)
Template function to generically construct an any from a C++ value.
Definition: Any.hxx:228
bool isExtractableTo(const Type &rType) const
Tests whether this any is extractable to a value of given type.
Definition: Any.hxx:190
C++ class representing an IDL meta type.
Definition: Type.h:54