diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-03-26 18:51:59 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-03-26 18:57:04 +0200 |
commit | 09517a98fe44eafcd19a8eecb0c14384799e2684 (patch) | |
tree | 6baaabfb42f1b0b2f8889bff7da1643d4cc5db89 /sal/inc | |
parent | 62983d5ae66d510c3a6a3167eb41207a9d2777ec (diff) |
string literal overload for OString::operator=()
Diffstat (limited to 'sal/inc')
-rw-r--r-- | sal/inc/rtl/string.hxx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 79b9a15ae94a..d899067754b4 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -57,6 +57,12 @@ namespace rtl #ifdef RTL_STRING_UNITTEST #undef rtl +// helper macros to make functions appear more readable +#define RTL_STRING_CONST_FUNCTION rtl_string_unittest_const_literal_function = true; +#define RTL_STRING_NON_CONST_FUNCTION rtl_string_unittest_non_const_literal_function = true; +#else +#define RTL_STRING_CONST_FUNCTION +#define RTL_STRING_NON_CONST_FUNCTION #endif /* ======================================================================= */ @@ -209,6 +215,7 @@ public: 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 */ @@ -225,6 +232,7 @@ public: /** @overload New string from a non-const char array. + @since LibreOffice 3.6 @param value non-const char array */ @@ -299,6 +307,33 @@ public: } /** + @overload + This function accepts an ASCII string literal as its argument. + @since LibreOffice 3.6 + */ + template< int N > + OString& operator=( const char (&literal)[ N ] ) SAL_THROW(()) + { + rtl_string_newFromLiteral( &pData, literal, N - 1 ); + RTL_STRING_CONST_FUNCTION + return *this; + } + /** + @overload + This function accepts a non-const char array as its argument. + @since LibreOffice 3.6 + + @param value non-const char array + */ + template< int N > + OString& operator=( char (&value)[ N ] ) SAL_THROW(()) + { + rtl_string_newFromStr( &pData, value ); + RTL_STRING_NON_CONST_FUNCTION + return *this; + } + + /** Append a string to this string. @param str a OString. |