summaryrefslogtreecommitdiff
path: root/include/rtl/stringutils.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-08-28 09:47:27 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-08-29 11:44:31 +0000
commit2c10714426cc813c36aa82e4870b7b51c5c03050 (patch)
treedecd4f4343fb19a1e058c034e32b03be17cd9547 /include/rtl/stringutils.hxx
parent0c8fa58a2d73702770687ed15b98822d09f96ac3 (diff)
Make OUStringLiteral1 a wrapper around UTF-16 instead of just ASCII
...not merely an ASCII character Change-Id: Id2b381b35fe3a15574728ed973d60263dfef7249 Reviewed-on: https://gerrit.libreoffice.org/28446 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/rtl/stringutils.hxx')
-rw-r--r--include/rtl/stringutils.hxx41
1 files changed, 19 insertions, 22 deletions
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx
index 1e5761f0fab4..6965347788a0 100644
--- a/include/rtl/stringutils.hxx
+++ b/include/rtl/stringutils.hxx
@@ -36,13 +36,13 @@ namespace rtl
#if defined LIBO_INTERNAL_ONLY
/// @cond INTERNAL
-/** A simple wrapper around an ASCII character literal.
+/** A simple wrapper around a sal_Unicode character literal.
- Can be useful to pass a char constant with ASCII value into a
- OUString-related function that is optimized for ASCII string literal
- arguments. That is, instead of
+ 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,
+ instead of
- char const WILDCARD = '%';
+ sal_Unicode const WILDCARD = '%';
...
if (s[i] == WILDCARD) ...
...
@@ -50,7 +50,7 @@ namespace rtl
use
- char const WILDCARD = '%';
+ sal_Unicode const WILDCARD = '%';
...
if (s[i] == WILDCARD) ...
...
@@ -58,7 +58,7 @@ namespace rtl
to avoid creating a temporary OUString instance, and instead pick the
endsWith overload actually designed to take an argument of type
- char const[N].
+ sal_Unicode const[N].
Instances of OUStringLiteral1 need to be const, as those literal-optimized
functions take the literal argument by non-const lvalue reference, for
@@ -71,18 +71,15 @@ namespace rtl
@since LibreOffice 5.0
*/
-template<char C> struct SAL_WARN_UNUSED OUStringLiteral1_ {
- static_assert(
- static_cast<unsigned char>(C) < 0x80,
- "non-ASCII character in OUStringLiteral1");
- char const c = C;
+template<sal_Unicode C> struct SAL_WARN_UNUSED OUStringLiteral1_ {
+ sal_Unicode const c = C;
};
#if defined _MSC_VER && _MSC_VER <= 1900 && !defined __clang__
// Visual Studio 2015
-template<char C> using OUStringLiteral1 = OUStringLiteral1_<C>;
+template<sal_Unicode C> using OUStringLiteral1 = OUStringLiteral1_<C>;
#pragma warning(disable: 4239)
#else
-template<char C> using OUStringLiteral1 = OUStringLiteral1_<C> const;
+template<sal_Unicode C> using OUStringLiteral1 = OUStringLiteral1_<C> const;
#endif
/// @endcond
@@ -181,7 +178,7 @@ struct ConstCharArrayDetector<sal_Unicode const [N], T> {
sal_Unicode const (& literal)[N])
{ return literal; }
};
-template<char C, typename T> struct ConstCharArrayDetector<
+template<sal_Unicode C, typename T> struct ConstCharArrayDetector<
#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 8 \
&& !defined __clang__
OUStringLiteral1_<C> const,
@@ -190,11 +187,11 @@ template<char C, typename T> struct ConstCharArrayDetector<
#endif
T>
{
- typedef T Type;
- static const std::size_t length = 1;
- static const bool ok = true;
- static bool isValid(OUStringLiteral1_<C>) { return true; }
- static char const * toPointer(OUStringLiteral1_<C> const & literal)
+ using TypeUtf16 = T;
+ static SAL_CONSTEXPR bool const ok = true;
+ static SAL_CONSTEXPR std::size_t const length = 1;
+ static SAL_CONSTEXPR sal_Unicode const * toPointer(
+ OUStringLiteral1_<C> const & literal)
{ return &literal.c; }
};
#endif
@@ -212,7 +209,7 @@ struct ExceptConstCharArrayDetector< const char[ N ] >
#if defined LIBO_INTERNAL_ONLY
template<std::size_t N>
struct ExceptConstCharArrayDetector<sal_Unicode const[N]> {};
-template<char C> struct ExceptConstCharArrayDetector<
+template<sal_Unicode C> struct ExceptConstCharArrayDetector<
#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 8 \
&& !defined __clang__
OUStringLiteral1_<C> const
@@ -243,7 +240,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<char C> struct ExceptCharArrayDetector<OUStringLiteral1_<C>> {};
+template<sal_Unicode C> struct ExceptCharArrayDetector<OUStringLiteral1_<C>> {};
#endif
template< typename T1, typename T2 = void >