From bd577aa7f8252f3f95276cd17c93beae1902fd96 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Wed, 28 Mar 2012 22:31:25 +0200 Subject: string literal overload for OUStringBuffer::insert() --- sal/inc/rtl/ustrbuf.hxx | 13 +++++++++++++ sal/qa/rtl/strings/test_oustring_stringliterals.cxx | 2 ++ 2 files changed, 15 insertions(+) (limited to 'sal') diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx index ee17f77d3815..99afe44b782b 100644 --- a/sal/inc/rtl/ustrbuf.hxx +++ b/sal/inc/rtl/ustrbuf.hxx @@ -634,6 +634,19 @@ public: return *this; } + /** + @overload + This function accepts an ASCII string literal as its argument. + @since LibreOffice 3.6 + */ + template< typename T > + typename internal::ConstCharArrayDetector< T, OUStringBuffer& >::Type insert( sal_Int32 offset, T& literal ) + { + rtl_uStringbuffer_insert_ascii( &pData, &nCapacity, offset, literal, + internal::ConstCharArrayDetector< T, void >::size - 1 ); + return *this; + } + /** Inserts the string representation of the sal_Bool argument into this string buffer. diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx index 2783571736d3..ddac4d62e35f 100644 --- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx @@ -178,6 +178,8 @@ void test::oustring::StringLiterals::checkBuffer() CPPUNIT_ASSERT_EQUAL( buf.toString(), rtl::OUString( "foo" )); buf.append( "bar" ); CPPUNIT_ASSERT_EQUAL( buf.toString(), rtl::OUString( "foobar" )); + buf.insert( 3, "baz" ); + CPPUNIT_ASSERT_EQUAL( buf.toString(), rtl::OUString( "foobazbar" )); } }} // namespace -- cgit