diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-10-16 15:06:23 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-10-17 07:28:49 +0200 |
commit | 8b4719c29fc9bd7e198ad6ced301e1ff7a350f16 (patch) | |
tree | d3ec594b343f56c76056418d835d3bc7b696a9ab /include/rtl | |
parent | f51cd77bcecc5134e0e04c398bfb7b34eb65d68d (diff) |
Rename OUStringLiteral1 to OUStringChar
It started out as a wrapper around character literals, but has by now become a
wrapper around arbitrary single characters. Besides updating the documentation,
this change is a mechanical
for i in $(git grep -Fl OUStringLiteral1); do sed -i -e s/OUStringLiteral1/OUStringChar/g "$i"; done
Change-Id: I1b9eaa4b3fbc9025ce4a4bffea3db1c16188b76f
Reviewed-on: https://gerrit.libreoffice.org/80892
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/rtl')
-rw-r--r-- | include/rtl/stringconcat.hxx | 6 | ||||
-rw-r--r-- | include/rtl/stringutils.hxx | 32 | ||||
-rw-r--r-- | include/rtl/ustring.hxx | 2 |
3 files changed, 26 insertions, 14 deletions
diff --git a/include/rtl/stringconcat.hxx b/include/rtl/stringconcat.hxx index 96b018d23d7a..588be8f0073e 100644 --- a/include/rtl/stringconcat.hxx +++ b/include/rtl/stringconcat.hxx @@ -185,10 +185,10 @@ struct ToStringHelper<sal_Unicode const[N]> }; template<> -struct ToStringHelper<OUStringLiteral1_> +struct ToStringHelper<OUStringChar_> { - static std::size_t length(OUStringLiteral1_) { return 1; } - static sal_Unicode * addData(sal_Unicode * buffer, OUStringLiteral1_ literal) + static std::size_t length(OUStringChar_) { return 1; } + static sal_Unicode * addData(sal_Unicode * buffer, OUStringChar_ literal) { return addDataHelper(buffer, &literal.c, 1); } static bool const allowOStringConcat = false; static bool const allowOUStringConcat = true; diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx index ec8c88211593..6ea44c72d8be 100644 --- a/include/rtl/stringutils.hxx +++ b/include/rtl/stringutils.hxx @@ -35,7 +35,7 @@ namespace rtl #if defined LIBO_INTERNAL_ONLY /// @cond INTERNAL -/** A simple wrapper around a sal_Unicode character literal. +/** A simple wrapper around a single sal_Unicode character. Can be useful to pass a sal_Unicode constant into an OUString-related function that is optimized for UTF-16 string literal arguments. That is, @@ -53,23 +53,35 @@ namespace rtl ... if (s[i] == WILDCARD) ... ... - if (s.endsWith(OUStringLiteral1(WILDCARD))) ... + if (s.endsWith(OUStringChar(WILDCARD))) ... to avoid creating a temporary OUString instance, and instead pick the endsWith overload actually designed to take an argument of type sal_Unicode const[N]. - Instances of OUStringLiteral1 need to be const, as those literal-optimized + (Because of the above use case, + instances of OUStringChar need to be const, as those literal-optimized functions take the literal argument by non-const lvalue reference, for technical reasons. + For actual arrays, it is important to distinguish string literals from other char or sal_Unicode + arrays, which may contain junk after the first NUL character or may be non-ASCII in the case of + char arrays. This is not so much a concern for single char and sal_Unicode values, where NUL is + assumed to always be meant as an actual character.) + + Can also be useful in string concatenation contexts, like in + + sal_Unicode const * s = ...; + sal_Unicode c = ...; + OUString t = s + OUStringChar(c); + @since LibreOffice 5.0 */ -struct SAL_WARN_UNUSED OUStringLiteral1_ { - constexpr OUStringLiteral1_(sal_Unicode theC): c(theC) {} +struct SAL_WARN_UNUSED OUStringChar_ { + constexpr OUStringChar_(sal_Unicode theC): c(theC) {} sal_Unicode const c; }; -using OUStringLiteral1 = OUStringLiteral1_ const; +using OUStringChar = OUStringChar_ const; /// @endcond #endif @@ -222,14 +234,14 @@ struct ConstCharArrayDetector<sal_Unicode const [N], T> { { return literal; } }; template<typename T> struct ConstCharArrayDetector< - OUStringLiteral1, + OUStringChar, T> { using TypeUtf16 = T; static constexpr bool const ok = true; static constexpr std::size_t const length = 1; static constexpr sal_Unicode const * toPointer( - OUStringLiteral1_ const & literal) + OUStringChar_ const & literal) { return &literal.c; } }; #endif @@ -248,7 +260,7 @@ struct ExceptConstCharArrayDetector< const char[ N ] > template<std::size_t N> struct ExceptConstCharArrayDetector<sal_Unicode const[N]> {}; template<> struct ExceptConstCharArrayDetector< - OUStringLiteral1 + OUStringChar > {}; #endif @@ -273,7 +285,7 @@ struct ExceptCharArrayDetector< const char[ N ] > #if defined LIBO_INTERNAL_ONLY template<std::size_t N> struct ExceptCharArrayDetector<sal_Unicode[N]> {}; template<std::size_t N> struct ExceptCharArrayDetector<sal_Unicode const[N]> {}; -template<> struct ExceptCharArrayDetector<OUStringLiteral1_> {}; +template<> struct ExceptCharArrayDetector<OUStringChar_> {}; #endif template< typename T1, typename T2 = void > diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx index a2bb6c09c086..f648cddce1d8 100644 --- a/include/rtl/ustring.hxx +++ b/include/rtl/ustring.hxx @@ -3789,7 +3789,7 @@ using ::rtl::OUStringHash; using ::rtl::OStringToOUString; using ::rtl::OUStringToOString; using ::rtl::OUStringLiteral; -using ::rtl::OUStringLiteral1; +using ::rtl::OUStringChar; #endif /// @cond INTERNAL |