LibreOffice
LibreOffice 6.3 SDK C/C++ API Reference
|
Go to the documentation of this file.
10 #ifndef INCLUDED_RTL_STRINGUTILS_HXX
11 #define INCLUDED_RTL_STRINGUTILS_HXX
24 #ifdef RTL_STRING_UNITTEST
25 #define rtl rtlunittest
31 #ifdef RTL_STRING_UNITTEST
35 #if defined LIBO_INTERNAL_ONLY
69 constexpr OUStringLiteral1_(
sal_Unicode theC): c(theC) {}
72 using OUStringLiteral1 = OUStringLiteral1_
const;
77 namespace libreoffice_internal
104 template<
typename T1,
typename T2 =
void >
107 static const bool ok =
false;
109 template<
typename T >
113 static const bool ok =
true;
115 template<
typename T >
119 static const bool ok =
true;
122 template<
typename T1,
typename T2 >
126 template<
typename T,
int N >
131 #ifdef RTL_STRING_UNITTEST
133 template<
typename T >
138 template<
typename T >
139 struct NonConstCharArrayDetector< const char[], T >
145 template<
typename T1,
typename T2 =
void >
148 static const bool ok =
false;
150 template< std::
size_t N,
typename T >
154 static const std::size_t length = N - 1;
155 static const bool ok =
true;
156 #if defined LIBO_INTERNAL_ONLY
159 static bool isValid(
char const (& literal)[N]) {
160 for (std::size_t i = 0; i != N - 1; ++i) {
161 if (literal[i] ==
'\0') {
165 return literal[N - 1] ==
'\0';
167 #if defined LIBO_INTERNAL_ONLY
170 static char const *
toPointer(
char const (& literal)[N]) {
return literal; }
173 #if defined(__COVERITY__)
176 template<
typename T >
177 struct ConstCharArrayDetector< const char[ 1 ], T >
180 static const std::size_t length = 0;
181 static const bool ok =
true;
182 #if defined LIBO_INTERNAL_ONLY
185 static bool isValid(
char const (& literal)[1]) {
186 return literal[0] ==
'\0';
188 #if defined LIBO_INTERNAL_ONLY
191 static char const * toPointer(
char const (& literal)[1]) {
return literal; }
195 #if defined LIBO_INTERNAL_ONLY && defined __cpp_char8_t
196 template<std::
size_t N,
typename T>
197 struct ConstCharArrayDetector<char8_t const [N], T> {
199 static constexpr
bool const ok =
true;
200 static constexpr std::size_t
const length = N - 1;
201 static constexpr
bool isValid(char8_t
const (& literal)[N]) {
202 for (std::size_t i = 0; i != N - 1; ++i) {
203 if (literal[i] == u8
'\0') {
207 return literal[N - 1] == u8
'\0';
209 static constexpr
char const * toPointer(char8_t
const (& literal)[N])
210 {
return reinterpret_cast<char const *
>(literal); }
214 #if defined LIBO_INTERNAL_ONLY
215 template<std::
size_t N,
typename T>
216 struct ConstCharArrayDetector<
sal_Unicode const [N], T> {
218 static constexpr
bool const ok =
true;
219 static constexpr std::size_t
const length = N - 1;
224 template<
typename T>
struct ConstCharArrayDetector<
229 static constexpr
bool const ok =
true;
230 static constexpr std::size_t
const length = 1;
232 OUStringLiteral1_
const & literal)
233 {
return &literal.c; }
238 template<
typename T >
247 #if defined LIBO_INTERNAL_ONLY
248 template<std::
size_t N>
250 template<>
struct ExceptConstCharArrayDetector<
260 template<
typename T >
273 #if defined LIBO_INTERNAL_ONLY
275 template<std::
size_t N>
struct ExceptCharArrayDetector<
sal_Unicode const[N]> {};
276 template<>
struct ExceptCharArrayDetector<OUStringLiteral1_> {};
279 template<
typename T1,
typename T2 =
void >
282 static const bool ok =
false;
284 template<
typename T >
288 static const bool ok =
true;
290 template<
typename T >
294 static const bool ok =
true;
298 template<
typename T,
bool >
303 template<
typename T >
314 #endif // INCLUDED_RTL_STRINGUTILS_HXX
Definition: stringutils.hxx:123
Definition: stringutils.hxx:299
Definition: stringutils.hxx:280
Dummy Type
Definition: stringutils.hxx:241
static const bool ok
Definition: stringutils.hxx:282
Definition: stringutils.hxx:239
T Type
Definition: stringutils.hxx:129
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:578
Definition: stringutils.hxx:146
Definition: stringutils.hxx:261
T Type
Definition: stringutils.hxx:306
static const char * toPointer(char const (&literal)[N])
Definition: stringutils.hxx:170
T Type
Definition: stringutils.hxx:287
T Type
Definition: stringutils.hxx:293
static const bool ok
Definition: stringutils.hxx:107
Definition: stringutils.hxx:105
Definition: bootstrap.hxx:29
static bool isValid(char const (&literal)[N])
Definition: stringutils.hxx:159
sal_uInt16 sal_Unicode
Definition: types.h:141
Definition: stringutils.hxx:103
T Type
Definition: stringutils.hxx:112
T Type
Definition: stringutils.hxx:153
static const bool ok
Definition: stringutils.hxx:148
Dummy Type
Definition: stringutils.hxx:263
T Type
Definition: stringutils.hxx:118