summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sal/inc/rtl/strbuf.hxx19
-rw-r--r--sal/inc/rtl/string.hxx18
-rw-r--r--sal/inc/rtl/ustrbuf.hxx19
-rw-r--r--sal/inc/rtl/ustring.hxx19
-rw-r--r--sal/qa/rtl/strings/test_ostring_concat.cxx19
-rw-r--r--sal/qa/rtl/strings/test_oustring_concat.cxx18
6 files changed, 106 insertions, 6 deletions
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 77e588fe3cd3..286a862d032b 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -496,6 +496,25 @@ public:
return *this;
}
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OStringBuffer& append( const OStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ if( l == 0 )
+ return *this;
+ rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
+ char* end = c.addData( pData->buffer + pData->length );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ return *this;
+ }
+#endif
+
/**
Appends the string representation of the <code>sal_Bool</code>
argument to the string buffer.
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 2c73168e63bb..1ef086025f85 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -320,6 +320,24 @@ public:
return *this;
}
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OString& operator+=( const OStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ if( l == 0 )
+ return *this;
+ rtl_string_ensureCapacity( &pData, pData->length + l );
+ char* end = c.addData( pData->buffer + pData->length );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ return *this;
+ }
+#endif
/**
Returns the length of this string.
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index 9b986b60791c..79af254983aa 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -494,6 +494,25 @@ public:
return *this;
}
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ if( l == 0 )
+ return *this;
+ rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
+ sal_Unicode* end = c.addData( pData->buffer + pData->length );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ return *this;
+ }
+#endif
+
/**
Appends a 8-Bit ASCII character string to this string buffer.
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index dd7f0a439c3d..07294f47fa3e 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -409,6 +409,25 @@ public:
return *this;
}
+#ifdef RTL_FAST_STRING
+ /**
+ @overload
+ @internal
+ */
+ template< typename T1, typename T2 >
+ OUString& operator+=( const OUStringConcat< T1, T2 >& c )
+ {
+ const int l = c.length();
+ if( l == 0 )
+ return *this;
+ rtl_uString_ensureCapacity( &pData, pData->length + l );
+ sal_Unicode* end = c.addData( pData->buffer + pData->length );
+ *end = '\0';
+ pData->length = end - pData->buffer;
+ return *this;
+ }
+#endif
+
/**
Returns the length of this string.
diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index c3a422a51f5f..4c0630c56351 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -12,6 +12,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <rtl/string.hxx>
+#include <rtl/strbuf.hxx>
#include <typeinfo>
@@ -32,12 +33,14 @@ namespace test { namespace ostring {
class StringConcat : public CppUnit::TestFixture
{
private:
- void check();
+ void checkConcat();
void checkEnsureCapacity();
+ void checkAppend();
CPPUNIT_TEST_SUITE(StringConcat);
-CPPUNIT_TEST(check);
+CPPUNIT_TEST(checkConcat);
CPPUNIT_TEST(checkEnsureCapacity);
+CPPUNIT_TEST(checkAppend);
CPPUNIT_TEST_SUITE_END();
};
@@ -46,7 +49,7 @@ CPPUNIT_TEST_SUITE_END();
#else
#define TYPES_ASSERT_EQUAL( a, b )
#endif
-void test::ostring::StringConcat::check()
+void test::ostring::StringConcat::checkConcat()
{
// All the extra () are to protect commas againsts being treated as separators of macro arguments.
CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString()) );
@@ -113,6 +116,16 @@ void test::ostring::StringConcat::checkEnsureCapacity()
rtl_string_release( oldStr );
}
+void test::ostring::StringConcat::checkAppend()
+{
+ OString str( "foo" );
+ str += OStringLiteral( "bar" ) + "baz";
+ CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), str );
+ OStringBuffer buf( "foo" );
+ buf.append( OStringLiteral( "bar" ) + "baz" );
+ CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), buf.makeStringAndClear());
+}
+
}} // namespace
CPPUNIT_TEST_SUITE_REGISTRATION(test::ostring::StringConcat);
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 108b166c6de2..8d98232a71a2 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -12,6 +12,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
#include <typeinfo>
@@ -32,12 +33,14 @@ namespace test { namespace oustring {
class StringConcat : public CppUnit::TestFixture
{
private:
- void check();
+ void checkConcat();
void checkEnsureCapacity();
+ void checkAppend();
CPPUNIT_TEST_SUITE(StringConcat);
-CPPUNIT_TEST(check);
+CPPUNIT_TEST(checkConcat);
CPPUNIT_TEST(checkEnsureCapacity);
+CPPUNIT_TEST(checkAppend);
CPPUNIT_TEST_SUITE_END();
};
@@ -46,7 +49,7 @@ CPPUNIT_TEST_SUITE_END();
#else
#define TYPES_ASSERT_EQUAL( a, b )
#endif
-void test::oustring::StringConcat::check()
+void test::oustring::StringConcat::checkConcat()
{
// All the extra () are to protect commas againsts being treated as separators of macro arguments.
CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString()) );
@@ -105,6 +108,15 @@ void test::oustring::StringConcat::checkEnsureCapacity()
rtl_uString_release( oldStr );
}
+void test::oustring::StringConcat::checkAppend()
+{
+ OUString str( "foo" );
+ str += OUStringLiteral( "bar" ) + "baz";
+ CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), str );
+ OUStringBuffer buf( "foo" );
+ buf.append( OUStringLiteral( "bar" ) + "baz" );
+ CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), buf.makeStringAndClear());
+}
}} // namespace