LibreOffice
LibreOffice 6.2 SDK C/C++ API Reference
|
Go to the documentation of this file.
10 #ifndef INCLUDED_RTL_STRINGUTILS_HXX
11 #define INCLUDED_RTL_STRINGUTILS_HXX
19 #if defined LIBO_INTERNAL_ONLY
20 #include "config_global.h"
28 #ifdef RTL_STRING_UNITTEST
29 #define rtl rtlunittest
35 #ifdef RTL_STRING_UNITTEST
39 #if defined LIBO_INTERNAL_ONLY
78 constexpr OUStringLiteral1_(
sal_Unicode theC): c(theC) {}
81 #if defined _MSC_VER && _MSC_VER <= 1900 && !defined __clang__
83 using OUStringLiteral1 = OUStringLiteral1_;
84 #pragma warning(disable: 4239) // nonstandard extension used: 'argument': conversion from 'rtl::OUStringLiteral1_' to 'rtl::OUStringLiteral1_ &'
86 using OUStringLiteral1 = OUStringLiteral1_
const;
92 namespace libreoffice_internal
119 template<
typename T1,
typename T2 =
void >
122 static const bool ok =
false;
124 template<
typename T >
128 static const bool ok =
true;
130 template<
typename T >
134 static const bool ok =
true;
137 template<
typename T1,
typename T2 >
141 template<
typename T,
int N >
146 #ifdef RTL_STRING_UNITTEST
148 template<
typename T >
153 template<
typename T >
154 struct NonConstCharArrayDetector< const char[], T >
160 template<
typename T1,
typename T2 =
void >
163 static const bool ok =
false;
165 template< std::
size_t N,
typename T >
169 static const std::size_t length = N - 1;
170 static const bool ok =
true;
171 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX14_CONSTEXPR
174 static bool isValid(
char const (& literal)[N]) {
175 for (std::size_t i = 0; i != N - 1; ++i) {
176 if (literal[i] ==
'\0') {
180 return literal[N - 1] ==
'\0';
182 #if defined LIBO_INTERNAL_ONLY
185 static char const *
toPointer(
char const (& literal)[N]) {
return literal; }
188 #if defined(__COVERITY__)
191 template<
typename T >
192 struct ConstCharArrayDetector< const char[ 1 ], T >
195 static const std::size_t length = 0;
196 static const bool ok =
true;
197 #if defined LIBO_INTERNAL_ONLY && HAVE_CXX14_CONSTEXPR
200 static bool isValid(
char const (& literal)[1]) {
201 return literal[0] ==
'\0';
203 #if defined LIBO_INTERNAL_ONLY
206 static char const * toPointer(
char const (& literal)[1]) {
return literal; }
210 #if defined LIBO_INTERNAL_ONLY && defined __cpp_char8_t
211 template<std::
size_t N,
typename T>
212 struct ConstCharArrayDetector<char8_t const [N], T> {
214 static constexpr
bool const ok =
true;
215 static constexpr std::size_t
const length = N - 1;
216 #if HAVE_CXX14_CONSTEXPR
219 static bool isValid(char8_t
const (& literal)[N]) {
220 for (std::size_t i = 0; i != N - 1; ++i) {
221 if (literal[i] == u8
'\0') {
225 return literal[N - 1] == u8
'\0';
227 static constexpr
char const * toPointer(char8_t
const (& literal)[N])
228 {
return reinterpret_cast<char const *
>(literal); }
232 #if defined LIBO_INTERNAL_ONLY
233 template<std::
size_t N,
typename T>
234 struct ConstCharArrayDetector<
sal_Unicode const [N], T> {
236 static constexpr
bool const ok =
true;
237 static constexpr std::size_t
const length = N - 1;
242 template<
typename T>
struct ConstCharArrayDetector<
243 #if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 8 \
244 && !defined __clang__
245 OUStringLiteral1_
const,
252 static constexpr
bool const ok =
true;
253 static constexpr std::size_t
const length = 1;
255 OUStringLiteral1_
const & literal)
256 {
return &literal.c; }
261 template<
typename T >
270 #if defined LIBO_INTERNAL_ONLY
271 template<std::
size_t N>
273 template<>
struct ExceptConstCharArrayDetector<
274 #if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 8 \
275 && !defined __clang__
276 OUStringLiteral1_
const
288 template<
typename T >
301 #if defined LIBO_INTERNAL_ONLY
303 template<std::
size_t N>
struct ExceptCharArrayDetector<
sal_Unicode const[N]> {};
304 template<>
struct ExceptCharArrayDetector<OUStringLiteral1_> {};
307 template<
typename T1,
typename T2 =
void >
310 static const bool ok =
false;
312 template<
typename T >
316 static const bool ok =
true;
318 template<
typename T >
322 static const bool ok =
true;
326 template<
typename T,
bool >
331 template<
typename T >
342 #endif // INCLUDED_RTL_STRINGUTILS_HXX
Definition: stringutils.hxx:138
Definition: stringutils.hxx:327
Definition: stringutils.hxx:308
Dummy Type
Definition: stringutils.hxx:264
static const bool ok
Definition: stringutils.hxx:310
Definition: stringutils.hxx:262
T Type
Definition: stringutils.hxx:144
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:590
Definition: stringutils.hxx:161
Definition: stringutils.hxx:289
T Type
Definition: stringutils.hxx:334
static const char * toPointer(char const (&literal)[N])
Definition: stringutils.hxx:185
T Type
Definition: stringutils.hxx:315
T Type
Definition: stringutils.hxx:321
static const bool ok
Definition: stringutils.hxx:122
Definition: stringutils.hxx:120
Definition: bootstrap.hxx:29
static bool isValid(char const (&literal)[N])
Definition: stringutils.hxx:174
sal_uInt16 sal_Unicode
Definition: types.h:141
Definition: stringutils.hxx:118
T Type
Definition: stringutils.hxx:127
T Type
Definition: stringutils.hxx:168
static const bool ok
Definition: stringutils.hxx:163
Dummy Type
Definition: stringutils.hxx:291
T Type
Definition: stringutils.hxx:133