summaryrefslogtreecommitdiff
path: root/include/com
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-10-18 18:14:14 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-11-21 19:44:56 +0000
commitbd614b91352b5a0a291f33a428c95d7bcbf34679 (patch)
tree1372effc15db45ec2fa8c9c248c9d66eacb99683 /include/com
parent05d175a8efceccd684c9e3d7f428073f1b142346 (diff)
Delete the "Any-to-Any" template specializations for LIBO_INTERNAL_ONLY
i.e., css::uno::Any function template specializations Any::has<Any>() const Any::get(Any const &) const operator >>=(Any const &, Any &) operator <<=(Any &, Any const &) that don't make much sense (the first is always true, the rest can be replaced with operator =, which additionally supports move semantics). For 3rd-party compatibility, do this only for LIBO_INTERNAL_ONLY, however. However, some generic template code did benefit from operator >>= working also for Any, so make up for that with a new (LIBO_INTERNAL_ONLY, given that operator >>= still covers if fine for !LIBO_INTERNAL_ONLY) fromAny, complementing the existing toAny. Change-Id: I8b1b5f803f0b909808159916366d53c948206a88 Reviewed-on: https://gerrit.libreoffice.org/30022 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/com')
-rw-r--r--include/com/sun/star/uno/Any.h27
-rw-r--r--include/com/sun/star/uno/Any.hxx31
2 files changed, 58 insertions, 0 deletions
diff --git a/include/com/sun/star/uno/Any.h b/include/com/sun/star/uno/Any.h
index d6c7477d3f4c..6e3d53b43c79 100644
--- a/include/com/sun/star/uno/Any.h
+++ b/include/com/sun/star/uno/Any.h
@@ -326,6 +326,31 @@ template<typename T> inline Any toAny(T const & value);
template<> inline Any toAny(Any const & value);
+#if defined LIBO_INTERNAL_ONLY
+
+/** Extract a value from an Any, if necessary.
+
+ The difference to operator >>= is that operator >>= cannot be called with an
+ Any as right-hand side (in LIBO_INTERNAL_ONLY), while fromAny just passes on
+ the given Any (and always succeeds) in the specialization for T = Any.
+
+ @tparam T any type representing a UNO type
+
+ @param any any Any value
+
+ @param value a non-null pointer, receiving the extracted value if
+ extraction succeeded (and left unmodified otherwise)
+
+ @return true iff extraction succeeded
+
+ @since LibreOffice 5.3
+*/
+template<typename T> inline bool fromAny(Any const & any, T * value);
+
+template<> inline bool fromAny(Any const & any, Any * value);
+
+#endif
+
class BaseReference;
/** Template binary <<= operator to set the value of an any.
@@ -423,8 +448,10 @@ inline bool SAL_CALL operator >>= ( const Any & rAny, Type & value );
template<>
inline bool SAL_CALL operator == ( const Any & rAny, const Type & value );
// any
+#if !defined LIBO_INTERNAL_ONLY
template<>
inline bool SAL_CALL operator >>= ( const Any & rAny, Any & value );
+#endif
// interface
template<>
inline bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value );
diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx
index 1e1f24e85fc8..0ea1fb9c4ad6 100644
--- a/include/com/sun/star/uno/Any.hxx
+++ b/include/com/sun/star/uno/Any.hxx
@@ -203,6 +203,10 @@ inline bool Any::has() const
cpp_release );
}
+#if defined LIBO_INTERNAL_ONLY
+template<> bool Any::has<Any>() const = delete;
+#endif
+
inline bool Any::operator == ( const Any & rAny ) const
{
return ::uno_type_equalData(
@@ -233,6 +237,21 @@ template<typename T> Any toAny(T const & value) { return makeAny(value); }
template<> Any toAny(Any const & value) { return value; }
+#if defined LIBO_INTERNAL_ONLY
+
+template<typename T> bool fromAny(Any const & any, T * value) {
+ assert(value != nullptr);
+ return any >>= *value;
+}
+
+template<> bool fromAny(Any const & any, Any * value) {
+ assert(value != nullptr);
+ *value = any;
+ return true;
+}
+
+#endif
+
template< class C >
inline void SAL_CALL operator <<= ( Any & rAny, const C & value )
{
@@ -266,6 +285,10 @@ inline void SAL_CALL operator <<= ( Any & rAny, const rtl::OUStringConcat< C1, C
}
#endif
+#if defined LIBO_INTERNAL_ONLY
+template<> void SAL_CALL operator <<=(Any &, Any const &) = delete;
+#endif
+
template< class C >
inline bool SAL_CALL operator >>= ( const Any & rAny, C & value )
{
@@ -566,6 +589,9 @@ inline bool SAL_CALL operator == ( const Any & rAny, const Type & value )
}
// any
+#if defined LIBO_INTERNAL_ONLY
+template<> bool SAL_CALL operator >>=(Any const &, Any &) = delete;
+#else
template<>
inline bool SAL_CALL operator >>= ( const Any & rAny, Any & value )
{
@@ -577,6 +603,7 @@ inline bool SAL_CALL operator >>= ( const Any & rAny, Any & value )
}
return true;
}
+#endif
// interface
template<>
@@ -623,6 +650,10 @@ T Any::get() const
return value;
}
+#if defined LIBO_INTERNAL_ONLY
+template<> Any Any::get() const = delete;
+#endif
+
/**
Support for Any in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO
macros, for example).