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
This commit is contained in:
parent
29433c6496
commit
bc4d465484
2 changed files with 15 additions and 24 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue