LibreOffice: com::sun::star::uno::Any Class Reference

LibreOffice LibreOffice 26.8 SDK C/C++ API Reference

Loading...
Searching...
No Matches
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:

## Public Member Functions
| Any ()
| 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)
| Copy constructor: Sets value of the given any.
| Any (const void *pData_, const Type &rType)
| Constructor: Sets a copy of the given data.
| Any (const void *pData_, typelib_TypeDescription *pTypeDescr)
| Constructor: Sets a copy of the given data.
| Any (const void *pData_, typelib_TypeDescriptionReference *pType_)
| Constructor: Sets a copy of the given data.
| ~Any ()
| Destructor: Destructs any content and frees memory.
Any & | operator= (const Any &rAny)
| Assignment operator: Sets the value of the given any.
const Type & | getValueType () const
| Gets the type of the set value.
typelib_TypeDescriptionReference * | getValueTypeRef () const
| Gets the type of the set value.
void | getValueTypeDescription (typelib_TypeDescription **ppTypeDescr) const
| Gets the type description of the set value.
TypeClass | getValueTypeClass () const
| Gets the type class of the set value.
inline ::rtl::OUString | getValueTypeName () const
| Gets the type name of the set value.
bool | hasValue () const
| Tests if any contains a value.
const void * | getValue () const
| Gets a pointer to the set value.
template<typename T>
T | get () const
| Provides a value of specified type, so you can easily write e.g.
void | setValue (const void *pData_, const Type &rType)
| Sets a value.
void | setValue (const void *pData_, typelib_TypeDescriptionReference *pType_)
| Sets a value.
void | setValue (const void *pData_, typelib_TypeDescription *pTypeDescr)
| Sets a value.
void | clear ()
| Clears this any.
bool | isExtractableTo (const Type &rType) const
| 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.
bool | operator== (const Any &rAny) const
| Equality operator: compares two anys.
bool | operator!= (const Any &rAny) const
| Inequality 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 using the <<= operators. 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

## ◆ Any() [1/7]

com::sun::star::uno::Any::Any | ( |  | ) |
| inline

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

## ◆ Any() [2/7]

template<typename T>

com::sun::star::uno::Any::Any | ( | T const & | value | ) |
| inlineexplicit

Templated ctor.

Sets a copy of the given value.

Parameters

  value | value of the Any

## ◆ Any() [3/7]

com::sun::star::uno::Any::Any | ( | bool | value | ) |
| inlineexplicit

Ctor support for C++ bool.

## ◆ Any() [4/7]

com::sun::star::uno::Any::Any | ( | const Any & | rAny | ) |
| inline

Copy constructor: Sets value of the given any.

Parameters

  rAny | another any

## ◆ Any() [5/7]

com::sun::star::uno::Any::Any | ( | const void * | pData_,
|  | const Type & | rType )
| inline

Constructor: Sets a copy of the given data.

Parameters

  pData_ | value
  rType | type of value

## ◆ Any() [6/7]

com::sun::star::uno::Any::Any | ( | const void * | pData_,
|  | typelib_TypeDescription * | pTypeDescr )
| inline

Constructor: Sets a copy of the given data.

Parameters

  pData_ | value
  pTypeDescr | type of value

## ◆ Any() [7/7]

com::sun::star::uno::Any::Any | ( | const void * | pData_,
|  | typelib_TypeDescriptionReference * | pType_ )
| inline

Constructor: Sets a copy of the given data.

Parameters

  pData_ | value
  pType_ | type of value

## ◆ ~Any()

com::sun::star::uno::Any::~Any | ( |  | ) |
| inline

Destructor: Destructs any content and frees memory.

## Member Function Documentation

## ◆ clear()

void com::sun::star::uno::Any::clear | ( |  | ) |
| 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.

## ◆ get()

template<typename T>

T com::sun::star::uno::Any::get | ( |  | ) | 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 com::sun::star::uno::RuntimeException if the specified type cannot be provided.

Returns
  value of specified type

Exceptions

  com::sun::star::uno::RuntimeException | in case the specified type cannot be provided

## ◆ getValue()

const void * com::sun::star::uno::Any::getValue | ( |  | ) | const
| inline

Gets a pointer to the set value.

Returns
  a pointer to the set value

## ◆ getValueType()

const Type & com::sun::star::uno::Any::getValueType | ( |  | ) | const
| inline

Gets the type of the set value.

Returns
  a Type object of the set value

## ◆ getValueTypeClass()

TypeClass com::sun::star::uno::Any::getValueTypeClass | ( |  | ) | const
| inline

Gets the type class of the set value.

Returns
  the type class of the set value

## ◆ getValueTypeDescription()

void com::sun::star::uno::Any::getValueTypeDescription | ( | typelib_TypeDescription ** | ppTypeDescr | ) | const
| 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

  ppTypeDescr | a pointer to type description pointer

## ◆ getValueTypeName()

rtl::OUString com::sun::star::uno::Any::getValueTypeName | ( |  | ) | const
| inline

Gets the type name of the set value.

Returns
  the type name of the set value

## ◆ getValueTypeRef()

typelib_TypeDescriptionReference * com::sun::star::uno::Any::getValueTypeRef | ( |  | ) | const
| inline

Gets the type of the set value.

Returns
  the unacquired type description reference of the set value

## ◆ has()

template<typename T>

bool com::sun::star::uno::Any::has | ( |  | ) | 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)

## ◆ hasValue()

bool com::sun::star::uno::Any::hasValue | ( |  | ) | const
| inline

Tests if any contains a value.

Returns
  true if any has a value, false otherwise

## ◆ isExtractableTo()

bool com::sun::star::uno::Any::isExtractableTo | ( | const Type & | rType | ) | const
| inline

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

Widening conversion without data loss is taken into account.

Parameters

  rType | destination type

Returns
  true if this any is extractable to value of given type (e.g. using >>= operator)

## ◆ operator!=()

bool com::sun::star::uno::Any::operator!= | ( | const Any & | rAny | ) | const
| inline

Inequality operator: compares two anys.

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

Parameters

  rAny | another any (right side)

Returns
  true if both any contains unequal values

## ◆ operator=()

Any & com::sun::star::uno::Any::operator= | ( | const Any & | rAny | ) |
| inline

Assignment operator: Sets the value of the given any.

Parameters

  rAny | another any (right side)

Returns
  this any

## ◆ operator==()

bool com::sun::star::uno::Any::operator== | ( | const Any & | rAny | ) | const
| 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

  rAny | another any (right side)

Returns
  true if both any contains equal values

## ◆ setValue() [1/3]

void com::sun::star::uno::Any::setValue | ( | const void * | pData_,
|  | const Type & | rType )
| 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
  rType | type of value

## ◆ setValue() [2/3]

void com::sun::star::uno::Any::setValue | ( | const void * | pData_,
|  | typelib_TypeDescription * | pTypeDescr )
| 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
  pTypeDescr | type description of value

## ◆ setValue() [3/3]

void com::sun::star::uno::Any::setValue | ( | const void * | pData_,
|  | typelib_TypeDescriptionReference * | pType_ )
| 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
  pType_ | type of value

The documentation for this class was generated from the following files:

- com/sun/star/uno/Any.h
- com/sun/star/uno/Any.hxx