UDK 3.2.7 C/C++ API Reference
Public Member Functions
com::sun::star::uno::Any Class Reference

C++ class representing an IDL any. More...

#include <Any.h>

Inheritance diagram for com::sun::star::uno::Any:
_uno_Any

List of all members.

Public Member Functions

 Any () throw ()
 Default constructor: Any holds no value; its type is void.
template<typename T >
 Any (T const &value)
 Templated ctor.
 Any (bool value)
 Ctor support for C++ bool.
 Any (const Any &rAny) throw ()
 Copy constructor: Sets value of the given any.
 Any (const void *pData_, const Type &rType) throw ()
 Constructor: Sets a copy of the given data.
 Any (const void *pData_, typelib_TypeDescription *pTypeDescr) throw ()
 Constructor: Sets a copy of the given data.
 Any (const void *pData_, typelib_TypeDescriptionReference *pType) throw ()
 Constructor: Sets a copy of the given data.
 ~Any () throw ()
 Destructor: Destructs any content and frees memory.
Anyoperator= (const Any &rAny) throw ()
 Assignment operator: Sets the value of the given any.
const TypegetValueType () const throw ()
 Gets the type of the set value.
typelib_TypeDescriptionReferencegetValueTypeRef () const throw ()
 Gets the type of the set value.
void getValueTypeDescription (typelib_TypeDescription **ppTypeDescr) const throw ()
 Gets the type description of the set value.
TypeClass getValueTypeClass () const throw ()
 Gets the type class of the set value.
inline::rtl::OUString getValueTypeName () const throw ()
 Gets the type name of the set value.
sal_Bool hasValue () const throw ()
 Tests if any contains a value.
const void * getValue () const throw ()
 Gets a pointer to the set value.
template<typename T >
get () const
 Provides a value of specified type, so you can easily write e.g.
void setValue (const void *pData_, const Type &rType) throw ()
 Sets a value.
void setValue (const void *pData_, typelib_TypeDescriptionReference *pType) throw ()
 Sets a value.
void setValue (const void *pData_, typelib_TypeDescription *pTypeDescr) throw ()
 Sets a value.
void clear () throw ()
 Clears this any.
sal_Bool isExtractableTo (const Type &rType) const throw ()
 Tests whether this any is extractable to a value of given type.
template<typename T >
bool has () const
 Tests whether this any can provide a value of specified type.
sal_Bool operator== (const Any &rAny) const throw ()
 Equality operator: compares two anys.
sal_Bool operator!= (const Any &rAny) const throw ()
 Unequality operator: compares two anys.

Detailed Description

C++ class representing an IDL any.

This class is used to transport any type defined in IDL. The class inherits from the binary C representation of uno_Any. You can insert a value by either using the <<= operators or the template function makeAny(). No any can hold an any. You can extract values from an any by using the >>= operators which return true if the any contains an assignable value (no data loss), e.g. the any contains a short and you >>= it into a long variable.


Constructor & Destructor Documentation

com::sun::star::uno::Any::Any ( ) throw () [inline]

Default constructor: Any holds no value; its type is void.

template<typename T >
com::sun::star::uno::Any::Any ( T const &  value) [inline, explicit]

Templated ctor.

Sets a copy of the given value.

Parameters:
valuevalue of the Any
com::sun::star::uno::Any::Any ( bool  value) [inline, explicit]

Ctor support for C++ bool.

com::sun::star::uno::Any::Any ( const Any rAny) throw () [inline]

Copy constructor: Sets value of the given any.

Parameters:
rAnyanother any
com::sun::star::uno::Any::Any ( const void *  pData_,
const Type rType 
) throw () [inline]

Constructor: Sets a copy of the given data.

Parameters:
pData_value
rTypetype of value
com::sun::star::uno::Any::Any ( const void *  pData_,
typelib_TypeDescription pTypeDescr 
) throw () [inline]

Constructor: Sets a copy of the given data.

Parameters:
pData_value
pTypeDescrtype of value
com::sun::star::uno::Any::Any ( const void *  pData_,
typelib_TypeDescriptionReference pType 
) throw () [inline]

Constructor: Sets a copy of the given data.

Parameters:
pData_value
pTypetype of value
com::sun::star::uno::Any::~Any ( ) throw () [inline]

Destructor: Destructs any content and frees memory.


Member Function Documentation

void com::sun::star::uno::Any::clear ( ) throw () [inline]

Clears this any.

If the any already contains a value, that value will be destructed and its memory freed. After this has been called, the any does not contain a value.

sal_uInt16 com::sun::star::uno::Any::get< sal_uInt16 > ( ) const [inline]

Provides a value of specified type, so you can easily write e.g.

        sal_Int32 myVal = myAny.get<sal_Int32>();
        

Widening conversion without data loss is taken into account. Throws a <type scope="com::sun::star::uno">RuntimeException</type> if the specified type cannot be provided.

Returns:
value of specified type
Exceptions:
<typescope="com::sun::star::uno">RuntimeException</type> in case the specified type cannot be provided
const void* com::sun::star::uno::Any::getValue ( ) const throw () [inline]

Gets a pointer to the set value.

Returns:
a pointer to the set value
const Type& com::sun::star::uno::Any::getValueType ( ) const throw () [inline]

Gets the type of the set value.

Returns:
a Type object of the set value
TypeClass com::sun::star::uno::Any::getValueTypeClass ( ) const throw () [inline]

Gets the type class of the set value.

Returns:
the type class of the set value
void com::sun::star::uno::Any::getValueTypeDescription ( typelib_TypeDescription **  ppTypeDescr) const throw () [inline]

Gets the type description of the set value.

Provides ownership of the type description! Call an explicit typelib_typedescription_release() to release afterwards.

Parameters:
ppTypeDescra pointer to type description pointer
rtl::OUString com::sun::star::uno::Any::getValueTypeName ( ) const throw () [inline]

Gets the type name of the set value.

Returns:
the type name of the set value
typelib_TypeDescriptionReference* com::sun::star::uno::Any::getValueTypeRef ( ) const throw () [inline]

Gets the type of the set value.

Returns:
the unacquired type description reference of the set value
bool com::sun::star::uno::Any::has< sal_uInt16 > ( ) const [inline]

Tests whether this any can provide a value of specified type.

Widening conversion without data loss is taken into account.

Returns:
true if this any can provide a value of specified type (e.g. using >>= operator)
sal_Bool com::sun::star::uno::Any::hasValue ( ) const throw () [inline]

Tests if any contains a value.

Returns:
true if any has a value, false otherwise
sal_Bool com::sun::star::uno::Any::isExtractableTo ( const Type rType) const throw () [inline]

Tests whether this any is extractable to a value of given type.

Widening conversion without data loss is taken into account.

Parameters:
rTypedestination type
Returns:
true if this any is extractable to value of given type (e.g. using >>= operator)
sal_Bool com::sun::star::uno::Any::operator!= ( const Any rAny) const throw () [inline]

Unequality operator: compares two anys.

The values need not be of equal type, e.g. a short integer is compared to a long integer.

Parameters:
rAnyanother any (right side)
Returns:
true if both any contains unequal values
Any & com::sun::star::uno::Any::operator= ( const Any rAny) throw () [inline]

Assignment operator: Sets the value of the given any.

Parameters:
rAnyanother any (right side)
Returns:
this any
sal_Bool com::sun::star::uno::Any::operator== ( const Any rAny) const throw () [inline]

Equality operator: compares two anys.

The values need not be of equal type, e.g. a short integer is compared to a long integer.

Parameters:
rAnyanother any (right side)
Returns:
true if both any contains equal values
void com::sun::star::uno::Any::setValue ( const void *  pData_,
typelib_TypeDescriptionReference pType 
) throw () [inline]

Sets a value.

If the any already contains a value, that value will be destructed and its memory freed.

Parameters:
pData_pointer to value
pTypetype of value
void com::sun::star::uno::Any::setValue ( const void *  pData_,
const Type rType 
) throw () [inline]

Sets a value.

If the any already contains a value, that value will be destructed and its memory freed.

Parameters:
pData_pointer to value
rTypetype of value
void com::sun::star::uno::Any::setValue ( const void *  pData_,
typelib_TypeDescription pTypeDescr 
) throw () [inline]

Sets a value.

If the any already contains a value, that value will be destructed and its memory freed.

Parameters:
pData_pointer to value
pTypeDescrtype description of value

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines