10#ifndef INCLUDED_O3TL_ANY_HXX
11#define INCLUDED_O3TL_ANY_HXX
21#include <com/sun/star/uno/Any.hxx>
22#include <com/sun/star/uno/RuntimeException.hpp>
23#include <com/sun/star/uno/Reference.hxx>
24#include <com/sun/star/uno/XInterface.hpp>
26#include <rtl/ustring.hxx>
39template<>
struct Optional<void> {
using type = std::optional<Void const>; };
40template<>
struct Optional<bool> {
using type = std::optional<bool const>; };
42 using type = std::optional<sal_Int8 const>;
45 using type = std::optional<sal_Int16 const>;
48 using type = std::optional<sal_uInt16 const>;
51 using type = std::optional<sal_Int32 const>;
54 using type = std::optional<sal_uInt32 const>;
57 using type = std::optional<sal_Int64 const>;
60 using type = std::optional<sal_uInt64 const>;
63 using type = std::optional<float const>;
66 using type = std::optional<double const>;
68template<
typename T>
struct Optional<css::uno::Reference<T>> {
69 using type = std::optional<css::uno::Reference<T>
const>;
71template<>
struct Optional<css::uno::Reference<css::uno::XInterface>> {
72 using type = css::uno::Reference<css::uno::XInterface>
const *;
89 css::uno::Any
const & any)
93 ? std::optional<T const>(std::move(
v)) : std::optional<T const>();
142template<
typename T>
inline
143typename std::enable_if<
144 !(detail::IsDerivedReference<T>::value
145 || detail::IsUnoSequenceType<T>::value
146 || std::is_base_of<css::uno::XInterface, T>::value),
152 ?
static_cast<T
const *
>(
any.getValue()) :
nullptr;
156 css::uno::Any
const & any)
158 return any.hasValue()
159 ? std::optional<detail::Void const>()
164 css::uno::Any
const & any)
166 return detail::tryGetConverted<bool>(
any);
170 css::uno::Any
const & any)
172 return detail::tryGetConverted<sal_Int8>(
any);
176 css::uno::Any
const & any)
178 return detail::tryGetConverted<sal_Int16>(
any);
182 css::uno::Any
const & any)
184 return detail::tryGetConverted<sal_uInt16>(
any);
188 css::uno::Any
const & any)
190 return detail::tryGetConverted<sal_Int32>(
any);
194 css::uno::Any
const & any)
196 return detail::tryGetConverted<sal_uInt32>(
any);
200 css::uno::Any
const & any)
202 return detail::tryGetConverted<sal_Int64>(
any);
206 css::uno::Any
const & any)
208 return detail::tryGetConverted<sal_uInt64>(
any);
212 css::uno::Any
const & any)
214 return detail::tryGetConverted<float>(
any);
218 css::uno::Any
const & any)
220 return detail::tryGetConverted<double>(
any);
224 css::uno::Any
const &) =
delete;
227 css::uno::Any
const &) =
delete;
245template<
typename T>
inline
246typename std::enable_if<
250 return detail::tryGetConverted<T>(
any);
254 css::uno::Any
const volatile &&) =
delete;
280 css::uno::Any
const & any)
282 auto opt = tryAccess<T>(
any);
284 throw css::uno::RuntimeException(
314 css::uno::Any
const & any)
316 auto opt = tryAccess<T>(
any);
css::uno::Type const & get()
rtl_uString *SAL_CALL cppu_Any_extraction_failure_msg(uno_Any const *pAny, typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
std::optional< T const > tryGetConverted(css::uno::Any const &any)
detail::Optional< sal_uInt16 >::type tryAccess< sal_uInt16 >(css::uno::Any const &any)
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
detail::Optional< sal_uInt64 >::type tryAccess< sal_uInt64 >(css::uno::Any const &any)
detail::Optional< sal_uInt32 >::type tryAccess< sal_uInt32 >(css::uno::Any const &any)
detail::Optional< sal_Bool >::type tryAccess< sal_Bool >(css::uno::Any const &)=delete
detail::Optional< float >::type tryAccess< float >(css::uno::Any const &any)
detail::Optional< sal_Int32 >::type tryAccess< sal_Int32 >(css::uno::Any const &any)
detail::Optional< sal_Int8 >::type tryAccess< sal_Int8 >(css::uno::Any const &any)
detail::Optional< sal_Int64 >::type tryAccess< sal_Int64 >(css::uno::Any const &any)
detail::Optional< T >::type forceAccess(css::uno::Any const &any)
Access the value of a specific type stored in an Any, knowing the Any contains a value of a matching ...
detail::Optional< T >::type doAccess(css::uno::Any const &any)
Access the value of a specific type stored in an Any, throwing an exception on failure.
detail::Optional< void >::type tryAccess< void >(css::uno::Any const &any)
detail::Optional< sal_Int16 >::type tryAccess< sal_Int16 >(css::uno::Any const &any)
detail::Optional< double >::type tryAccess< double >(css::uno::Any const &any)
std::enable_if<!(detail::IsDerivedReference< T >::value||detail::IsUnoSequenceType< T >::value||std::is_base_of< css::uno::XInterface, T >::value), typenamedetail::Optional< T >::type >::type tryAccess(css::uno::Any const &any)
Try to access the value of a specific type stored in an Any.
std::optional< bool const > type
std::optional< css::uno::Reference< T > const > type
css::uno::Reference< css::uno::XInterface > const * type
std::optional< double const > type
std::optional< float const > type
std::optional< sal_Int16 const > type
std::optional< sal_Int32 const > type
std::optional< sal_Int64 const > type
std::optional< sal_Int8 const > type
std::optional< sal_uInt16 const > type
std::optional< sal_uInt32 const > type
std::optional< sal_uInt64 const > type
std::optional< Void const > type