summaryrefslogtreecommitdiff
path: root/include/com
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-05-03 18:23:59 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-05-03 18:34:17 +0200
commitbc4d465484c67fa27d6c59807176d5f57155d9f5 (patch)
treeed38e5f2459826ff785bfc31e1b4b194f2b4f005 /include/com
parent29433c6496e8aa2d82ce56731d4bb734538a9f80 (diff)
Clean up makeAny functions
Let the templated makeAny(v) just call Any(v), so that any special handling of argument types needs to be only done for the Any ctor, not also for makeAny (both the original makeAny implementation and the Any ctor implementation internally use cppu::getTypeFavourUnsigned to determine the UNO type, so this does not cause any difference in behavior): * The specialization of makeAny for bool can be dropped. * The overload of makeAny for OUStringConcat is replaced with an overloaded Any ctor, so that Any(s + "foo") works now, too. Curiously, only the Any ctor had been deleted for a sal_uInt16 argument (which can conflict with sal_Unicode), but not makeAny. So introduce a specialization of makeAny for sal_uInt16, so that that continues to work. (For backwards compatiblity in the non-LIBO_INTERNAL_ONLY case; and in the LIBO_INIERNAL_ONLY case we're moving away from the sal_uInt16/sal_Unicode clash anyway thanks to C++11 char16_t, so it is arguably better to allow makeAny for sal_uIn16 than to prohibit it.) Change-Id: I7803703769730024863bb4e5b1b3416b81bd8960
Diffstat (limited to 'include/com')
-rw-r--r--include/com/sun/star/uno/Any.h12
-rw-r--r--include/com/sun/star/uno/Any.hxx27
2 files changed, 15 insertions, 24 deletions
diff --git a/include/com/sun/star/uno/Any.h b/include/com/sun/star/uno/Any.h
index 90107d5cbb4b..8367eca7718b 100644
--- a/include/com/sun/star/uno/Any.h
+++ b/include/com/sun/star/uno/Any.h
@@ -23,14 +23,13 @@
#include <cstddef>
+#include <rtl/ustring.hxx>
#include <uno/any2.h>
#include <typelib/typedescription.h>
#include <cppu/unotype.hxx>
#include <com/sun/star/uno/TypeClass.hdl>
#include <rtl/alloc.h>
-namespace rtl { class OUString; }
-
namespace com
{
namespace sun
@@ -78,6 +77,11 @@ public:
/// Ctor support for C++ bool.
explicit inline Any( bool value );
+#if defined LIBO_INTERNAL_ONLY
+ template<typename T1, typename T2>
+ explicit inline Any(rtl::OUStringConcat<T1, T2> const & value);
+#endif
+
/** Copy constructor: Sets value of the given any.
@param rAny another any
@@ -289,9 +293,7 @@ template<> bool Any::has<sal_uInt16>() const SAL_DELETED_FUNCTION;
template< class C >
inline Any SAL_CALL makeAny( const C & value );
-// additionally specialized for C++ bool
-template<>
-inline Any SAL_CALL makeAny( bool const & value );
+template<> inline Any SAL_CALL makeAny(sal_uInt16 const & value);
template<> Any SAL_CALL makeAny(Any const &) SAL_DELETED_FUNCTION;
diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx
index cbd8fb6e287e..d0a45061caa1 100644
--- a/include/com/sun/star/uno/Any.hxx
+++ b/include/com/sun/star/uno/Any.hxx
@@ -73,6 +73,11 @@ inline Any::Any( bool value )
cpp_acquire );
}
+#if defined LIBO_INTERNAL_ONLY
+template<typename T1, typename T2>
+Any::Any(rtl::OUStringConcat<T1, T2> const & value): Any(rtl::OUString(value))
+{}
+#endif
inline Any::Any( const Any & rAny )
{
@@ -183,27 +188,11 @@ inline bool Any::operator != ( const Any & rAny ) const
template< class C >
inline Any SAL_CALL makeAny( const C & value )
{
- return Any( &value, ::cppu::getTypeFavourUnsigned(&value) );
+ return Any(value);
}
-// additionally specialized for C++ bool
-
-template<>
-inline Any SAL_CALL makeAny( bool const & value )
-{
- const sal_Bool b = value;
- return Any( &b, cppu::UnoType<bool>::get() );
-}
-
-
-#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
-template< class C1, class C2 >
-inline Any SAL_CALL makeAny( const rtl::OUStringConcat< C1, C2 >& value )
-{
- const rtl::OUString str( value );
- return Any( &str, ::cppu::getTypeFavourUnsigned(&str) );
-}
-#endif
+template<> Any makeAny(sal_uInt16 const & value)
+{ return Any(&value, cppu::UnoType<cppu::UnoUnsignedShortType>::get()); }
template<typename T> Any toAny(T const & value) { return makeAny(value); }