3 #ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
4 #define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
21 #include "com/sun/star/uno/RuntimeException.hpp"
49 this, const_cast<T *>(&value),
62 #if defined LIBO_INTERNAL_ONLY
63 template<
typename T1,
typename T2>
64 Any::Any(rtl::OUStringConcat<T1, T2> && value):
65 Any(rtl::OUString(std::move(value)))
68 Any::Any(rtl::OUStringNumber<T> && value): Any(rtl::OUString(std::move(value))) {}
69 template <std::
size_t N>
70 Any::Any(
const rtl::OUStringLiteral<N>& value): Any(rtl::OUString(value)) {}
88 this, const_cast< void * >( pData_ ), pTypeDescr,
cpp_acquire );
94 this, const_cast< void * >( pData_ ), pType_,
cpp_acquire );
108 this, rAny.pData, rAny.pType,
114 #if defined LIBO_INTERNAL_ONLY
118 std::swap(other.pType, pType);
119 std::swap(other.pData, pData);
120 std::swap(other.pReserved, pReserved);
121 if (pData == &other.pReserved) {
131 std::swap(other.pType, pType);
132 std::swap(other.pData, pData);
133 std::swap(other.pReserved, pReserved);
134 if (pData == &other.pReserved) {
137 if (other.pData == &pReserved) {
138 other.pData = &other.pReserved;
147 return ::rtl::OUString( pType->pTypeName );
160 this, const_cast< void * >( pData_ ), pType_,
167 this, const_cast< void * >( pData_ ), pTypeDescr,
185 template <
typename T>
195 #if defined LIBO_INTERNAL_ONLY
196 template<>
bool Any::has<Any>()
const =
delete;
202 pData, pType, rAny.pData, rAny.pType,
209 pData, pType, rAny.pData, rAny.pType,
214 #if !defined LIBO_INTERNAL_ONLY
231 #if defined LIBO_INTERNAL_ONLY
233 template<
typename T1,
typename T2>
234 Any
toAny(rtl::OUStringConcat<T1, T2> && value)
235 {
return Any(std::move(value)); }
238 Any
toAny(rtl::OUStringNumber<T> && value)
239 {
return Any(std::move(value)); }
241 template<
typename T>
bool fromAny(Any
const & any, T * value) {
242 assert(value !=
nullptr);
243 return any >>= *value;
246 template<>
bool fromAny(Any
const & any, Any * value) {
247 assert(value !=
nullptr);
275 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
276 template<
class C1,
class C2 >
277 inline void operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& value )
282 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
285 template<
typename T1,
typename T2>
286 void operator <<=(Any &, rtl::OUStringConcat<T1, T2>
const &) =
delete;
288 inline void operator <<= ( Any & rAny, rtl::OUStringNumber< C >&& value )
293 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
297 void operator <<=(Any &, rtl::OUStringNumber<T>
const &) =
delete;
300 #if defined LIBO_INTERNAL_ONLY
301 template<>
void SAL_CALL
operator <<=(Any &, Any
const &) =
delete;
310 rAny.pData, rAny.pType,
322 value = bool(* static_cast< const sal_Bool * >( rAny.pData ));
332 bool(value) ==
bool(* static_cast< const sal_Bool * >( rAny.pData )));
341 value = *
static_cast< sal_Bool const *
>( rAny.pData );
353 bool(*static_cast< sal_Bool const * >( rAny.pData ))));
363 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
373 switch (rAny.pType->eTypeClass)
376 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
380 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
390 switch (rAny.pType->eTypeClass)
393 value =
static_cast<sal_uInt16
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
397 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
408 switch (rAny.pType->eTypeClass)
411 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
414 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
417 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
421 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
431 switch (rAny.pType->eTypeClass)
434 value =
static_cast<sal_uInt32
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
437 value =
static_cast<sal_uInt32
>( *
static_cast< const sal_Int16 *
>( rAny.pData ) );
440 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
444 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
455 switch (rAny.pType->eTypeClass)
458 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
461 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
464 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
467 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
470 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
474 value = *
static_cast< const sal_Int64 *
>( rAny.pData );
484 switch (rAny.pType->eTypeClass)
487 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int8 *
>( rAny.pData ) );
490 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int16 *
>( rAny.pData ) );
493 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
496 value =
static_cast<sal_uInt64
>( *
static_cast< const sal_Int32 *
>( rAny.pData ) );
499 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
503 value = *
static_cast< const sal_uInt64 *
>( rAny.pData );
514 switch (rAny.pType->eTypeClass)
517 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
520 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
523 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
526 value = *
static_cast< const float *
>( rAny.pData );
537 switch (rAny.pType->eTypeClass)
540 value = *
static_cast< const sal_Int8 *
>( rAny.pData );
543 value = *
static_cast< const sal_Int16 *
>( rAny.pData );
546 value = *
static_cast< const sal_uInt16 *
>( rAny.pData );
549 value = *
static_cast< const sal_Int32 *
>( rAny.pData );
552 value = *
static_cast< const sal_uInt32 *
>( rAny.pData );
555 value = *
static_cast< const float *
>( rAny.pData );
558 value = *
static_cast< const double *
>( rAny.pData );
571 value = *
static_cast< const ::
rtl::OUString *
>( rAny.pData );
578 inline bool SAL_CALL
operator == (
const Any & rAny, const ::rtl::OUString & value )
581 value == * static_cast< const ::rtl::OUString * >( rAny.pData ) );
584 #if defined LIBO_INTERNAL_ONLY
585 template<std::
size_t N>
586 inline bool SAL_CALL
operator == (
const Any& rAny,
const rtl::OUStringLiteral<N>& value)
598 value = *
static_cast< const Type *
>( rAny.pData );
608 value.
equals( * static_cast< const Type * >( rAny.pData ) ));
612 #if defined LIBO_INTERNAL_ONLY
613 template<>
bool SAL_CALL
operator >>=(Any
const &, Any &) =
delete;
621 &value, rAny.pData, rAny.pType,
634 return static_cast< const BaseReference *
>( rAny.pData )->
operator == ( value );
646 rAny.pData, rAny.pType,
655 return (!
operator == ( rAny, value ));
658 template <
typename T>
662 if (! (*
this >>= value)) {
663 throw RuntimeException(
673 #if defined LIBO_INTERNAL_ONLY
683 template<
typename charT,
typename traits>
684 inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o,
Any const &any) {
686 switch(any.pType->eTypeClass) {
690 o <<
' ' << any.get<
bool>();
696 o <<
' ' << any.get<sal_Int64>();
701 o <<
' ' << any.get<sal_uInt64>();
705 o <<
' ' << any.get<
double>();
708 std::ios_base::fmtflags flgs = o.setf(
709 std::ios_base::hex, std::ios_base::basefield);
710 charT fill = o.fill(
'0');
711 o <<
" U+" << std::setw(4)
712 << unsigned(*static_cast<sal_Unicode const *>(any.getValue()));
721 o <<
' ' << any.get<css::uno::Type>().
getTypeName();
725 << ((*
static_cast<uno_Sequence *
const *
>(any.getValue()))->
729 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
733 o <<
' ' << any.getValue();
736 o << ' ' << *static_cast<void * const *>(any.getValue());
753 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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.
void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition: genfunc.hxx:30
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.
unsigned char sal_Bool
Definition: types.h:18
type class of enum
Definition: typeclass.h:42
type class of void
Definition: typeclass.h:12
inline::rtl::OUString getValueTypeName() const
Gets the type name of the set value.
Definition: Any.hxx:145
bool isExtractableTo(const Type &rType) const
Tests whether this any is extractable to a value of given type.
Definition: Any.hxx:177
type class of long
Definition: typeclass.h:24
type class of string
Definition: typeclass.h:36
type class of exception
Definition: typeclass.h:53
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
This String class provides base functionality for C++ like Unicode character array handling...
Definition: ustring.hxx:182
type class of double
Definition: typeclass.h:34
type class of char
Definition: typeclass.h:14
type class of unsigned long
Definition: typeclass.h:26
Any & operator=(const Any &rAny)
Assignment operator: Sets the value of the given any.
Definition: Any.hxx:103
type class of short
Definition: typeclass.h:20
C++ class representing an IDL any.
Definition: Any.h:36
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:142
struct SAL_DLLPUBLIC_RTTI _uno_Any uno_Any
This is the binary specification of a UNO any.
bool has() const
Tests whether this any can provide a value of specified type.
Definition: Any.hxx:186
Any toAny(T const &value)
Wrap a value in an Any, if necessary.
Definition: Any.hxx:225
~Any()
Destructor: Destructs any content and frees memory.
Definition: Any.hxx:97
bool operator==(const Any &rAny) const
Equality operator: compares two anys.
Definition: Any.hxx:199
CPPU_DLLPUBLIC void uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Destructs an any.
bool operator>>=(const Any &rAny, C &value)
Template binary >>= operator to assign a value from an any.
Definition: Any.hxx:305
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:642
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
Inequality operator: compares two anys.
Definition: Any.hxx:206
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:31
void cpp_acquire(void *pCppI)
Function to acquire a C++ interface.
Definition: genfunc.hxx:25
CPPU_DLLPUBLIC void SAL_THROW_EXTERN_C()
This method is called to wait for a reply of a previously sent request.
type class of interface
Definition: typeclass.h:62
Any makeAny(const C &value)
Template function to generically construct an any from a C++ value.
Definition: Any.hxx:216
type class of sequence
Definition: typeclass.h:55
type class of boolean
Definition: typeclass.h:16
type class of hyper
Definition: typeclass.h:28
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.
type class of float
Definition: typeclass.h:32
void operator<<=(Any &rAny, const C &value)
Template binary <<= operator to set the value of an any.
Definition: Any.hxx:255
C++ class representing an IDL meta type.
Definition: Type.h:38
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescription typelib_TypeDescription
Full type description of a type.
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 type
Definition: typeclass.h:38
definition of a no acquire enum for ctors
Definition: types.h:336
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:653
Any()
Default constructor: Any holds no value; its type is void.
Definition: Any.hxx:39
void setValue(const void *pData_, const Type &rType)
Sets a value.
Definition: Any.hxx:150
This is the binary specification of a SAL sequence.
Definition: types.h:283
type class of struct
Definition: typeclass.h:46
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.
void * cpp_queryInterface(void *pCppI, typelib_TypeDescriptionReference *pType)
Function to query for a C++ interface.
Definition: genfunc.hxx:35
type class of byte
Definition: typeclass.h:18
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_any_clear(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Sets value to void.
signed char sal_Int8
Definition: types.h:23
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.
css::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:304
This base class serves as a base class for all template reference classes and has been introduced due...
Definition: Reference.h:46
type class of unsigned hyper
Definition: typeclass.h:30
T get() const
Provides a value of specified type, so you can easily write e.g.
Definition: Any.hxx:659
bool equals(const Type &rType) const
Compares two types.
Definition: Type.h:161
type class of unsigned short
Definition: typeclass.h:22
rtl::OUString getTypeName(rtl::OUString const &rEnvDcp)
Get the OBI type part of an environment descriptor.
Definition: EnvDcp.hxx:21
void clear()
Clears this any.
Definition: Any.hxx:171
#define CPPU_DLLPUBLIC
Definition: cppudllapi.h:11