diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-12-12 17:00:50 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-12-12 17:04:47 +0100 |
commit | d79b96cf6564187c96f5a1451ca98e2c93adee77 (patch) | |
tree | d3cedc2a45b77e4e2e0109b62d359afca94f7a78 /include/com/sun/star/uno | |
parent | 7a85674c93150d6f5a59e998158909365b47d761 (diff) |
css::uno::Sequence ctor with initializer_list
(though LIBO_INTERNAL_ONLY, as it needs C++11, so cannot in general be used in
URE client code; I think it's better to not offer it outside LO at all, than
based on a feature-check macro, and thus catch accidental misuses of it via
CppunitTest_odk_checkapi)
...plus adapting binaryurp/ to use the new feature
Change-Id: I9a88a0e9eac5daf72896470e8b6a1deb1a6fc88f
Diffstat (limited to 'include/com/sun/star/uno')
-rw-r--r-- | include/com/sun/star/uno/Sequence.h | 14 | ||||
-rw-r--r-- | include/com/sun/star/uno/Sequence.hxx | 11 |
2 files changed, 25 insertions, 0 deletions
diff --git a/include/com/sun/star/uno/Sequence.h b/include/com/sun/star/uno/Sequence.h index fa2aa96f3fc9..21e3e9df6156 100644 --- a/include/com/sun/star/uno/Sequence.h +++ b/include/com/sun/star/uno/Sequence.h @@ -26,6 +26,10 @@ #include <new> +#if defined LIBO_INTERNAL_ONLY +#include <initializer_list> +#endif + namespace rtl { class ByteSequence; @@ -109,6 +113,16 @@ public: */ inline explicit Sequence( sal_Int32 len ); +#if defined LIBO_INTERNAL_ONLY + /** Create a sequence with the given elements. + + @param init an initializer_list + + @since LibreOffice 4.5 + */ + inline Sequence(std::initializer_list<E> init); +#endif + /** Destructor: Releases sequence handle. Last handle will destruct elements and free memory. */ diff --git a/include/com/sun/star/uno/Sequence.hxx b/include/com/sun/star/uno/Sequence.hxx index 1ee59aebac45..dce2609c2d77 100644 --- a/include/com/sun/star/uno/Sequence.hxx +++ b/include/com/sun/star/uno/Sequence.hxx @@ -92,6 +92,17 @@ inline Sequence< E >::Sequence( sal_Int32 len ) throw ::std::bad_alloc(); } +#if defined LIBO_INTERNAL_ONLY +template<typename E> Sequence<E>::Sequence(std::initializer_list<E> init) { + if (!uno_type_sequence_construct( + &_pSequence, cppu::getTypeFavourUnsigned(this).getTypeLibType(), + const_cast<E *>(init.begin()), init.size(), cpp_acquire)) + { + throw std::bad_alloc(); + } +} +#endif + template< class E > inline Sequence< E >::~Sequence() { |