summaryrefslogtreecommitdiff
path: root/sal/inc/rtl/strbuf.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-04-06 13:45:47 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-04-06 13:46:21 +0200
commit066dbfd1970b8ea58ba16b07b2a57f61c0cb8e36 (patch)
tree635b7cdbca8b31e82fedbead441dfd298b53718b /sal/inc/rtl/strbuf.hxx
parent7d82fb18fe6ae68f6eb6a33c6030105f9e2fe232 (diff)
string literal O(U)StringBuffer ctors too, after all
Diffstat (limited to 'sal/inc/rtl/strbuf.hxx')
-rw-r--r--sal/inc/rtl/strbuf.hxx54
1 files changed, 54 insertions, 0 deletions
diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 122eb4b099e6..4500cf0f8de8 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -155,6 +155,60 @@ public:
}
/**
+ @overload
+ @since LibreOffice 3.6
+ */
+#ifdef HAVE_SFINAE_ANONYMOUS_BROKEN // see the OString ctors
+ OStringBuffer( const char* value )
+ : pData(NULL)
+ {
+ sal_Int32 length = rtl_str_getLength( value );
+ nCapacity = length + 16;
+ rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
+ }
+#else
+ template< typename T >
+ OStringBuffer( const T& value, typename internal::CharPtrDetector< T, internal::Dummy >::Type = internal::Dummy())
+ : pData(NULL)
+ {
+ sal_Int32 length = rtl_str_getLength( value );
+ nCapacity = length + 16;
+ rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
+ }
+
+ template< typename T >
+ OStringBuffer( T& value, typename internal::NonConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy())
+ : pData(NULL)
+ {
+ sal_Int32 length = rtl_str_getLength( value );
+ nCapacity = length + 16;
+ rtl_stringbuffer_newFromStr_WithLength( &pData, value, length );
+ }
+
+ /**
+ Constructs a string buffer so that it represents the same
+ sequence of characters as the string literal.
+
+ If there are any embedded \0's in the string literal, the result is undefined.
+ Use the overload that explicitly accepts length.
+
+ @since LibreOffice 3.6
+
+ @param literal a string literal
+ */
+ template< typename T >
+ OStringBuffer( T& literal, typename internal::ConstCharArrayDetector< T, internal::Dummy >::Type = internal::Dummy())
+ : pData(NULL)
+ , nCapacity( internal::ConstCharArrayDetector< T, void >::size - 1 + 16 )
+ {
+ rtl_string_newFromLiteral( &pData, literal, internal::ConstCharArrayDetector< T, void >::size - 1, 16 );
+#ifdef RTL_STRING_UNITTEST
+ rtl_string_unittest_const_literal = true;
+#endif
+ }
+#endif // HAVE_SFINAE_ANONYMOUS_BROKEN
+
+ /**
Constructs a string buffer so that it represents the same
sequence of characters as the string argument.