LibreOffice
LibreOffice 6.4 SDK C/C++ API Reference
|
Go to the documentation of this file.
10 #ifndef INCLUDED_RTL_STRINGUTILS_HXX
11 #define INCLUDED_RTL_STRINGUTILS_HXX
25 #ifdef RTL_STRING_UNITTEST
26 #define rtl rtlunittest
32 #ifdef RTL_STRING_UNITTEST
36 #if defined LIBO_INTERNAL_ONLY
46 constexpr OStringChar(
char theC): c(theC) {}
47 template<
typename T> OStringChar(T &&) =
delete;
94 constexpr OUStringChar_(
sal_Unicode theC): c(theC) {}
95 constexpr OUStringChar_(
char theC): c(theC) { assert(c <= 0x7F); }
96 template<
typename T> OUStringChar_(T &&) =
delete;
99 using OUStringChar = OUStringChar_
const;
104 namespace libreoffice_internal
131 template<
typename T1,
typename T2 =
void >
134 static const bool ok =
false;
136 template<
typename T >
140 static const bool ok =
true;
142 template<
typename T >
146 static const bool ok =
true;
148 #if defined LIBO_INTERNAL_ONLY
150 template<
typename T>
struct CharPtrDetector<
sal_Unicode const *, T> {
using TypeUtf16 = T; };
151 template<
typename T>
struct CharPtrDetector<
sal_Unicode[], T> {
using TypeUtf16 = T; };
152 template<
typename T>
struct CharPtrDetector<
sal_Unicode const[], T> {
using TypeUtf16 = T; };
155 template<
typename T1,
typename T2 >
159 template<
typename T,
int N >
164 #ifdef RTL_STRING_UNITTEST
166 template<
typename T >
171 template<
typename T >
172 struct NonConstCharArrayDetector< const char[], T >
177 #if defined LIBO_INTERNAL_ONLY
178 template<
typename T, std::
size_t N>
struct NonConstCharArrayDetector<
sal_Unicode[N], T> {
183 template<
typename T1,
typename T2 =
void >
186 static const bool ok =
false;
188 template< std::
size_t N,
typename T >
192 static const std::size_t length = N - 1;
193 static const bool ok =
true;
194 #if defined LIBO_INTERNAL_ONLY
197 static bool isValid(
char const (& literal)[N]) {
198 for (std::size_t i = 0; i != N - 1; ++i) {
199 if (literal[i] ==
'\0') {
203 return literal[N - 1] ==
'\0';
205 #if defined LIBO_INTERNAL_ONLY
208 static char const *
toPointer(
char const (& literal)[N]) {
return literal; }
211 #if defined(__COVERITY__)
214 template<
typename T >
215 struct ConstCharArrayDetector< const char[ 1 ], T >
218 static const std::size_t length = 0;
219 static const bool ok =
true;
220 #if defined LIBO_INTERNAL_ONLY
223 static bool isValid(
char const (& literal)[1]) {
224 return literal[0] ==
'\0';
226 #if defined LIBO_INTERNAL_ONLY
229 static char const * toPointer(
char const (& literal)[1]) {
return literal; }
233 #if defined LIBO_INTERNAL_ONLY && defined __cpp_char8_t
234 template<std::
size_t N,
typename T>
235 struct ConstCharArrayDetector<char8_t const [N], T> {
237 static constexpr
bool const ok =
true;
238 static constexpr std::size_t
const length = N - 1;
239 static constexpr
bool isValid(char8_t
const (& literal)[N]) {
240 for (std::size_t i = 0; i != N - 1; ++i) {
241 if (literal[i] == u8
'\0') {
245 return literal[N - 1] == u8
'\0';
247 static constexpr
char const * toPointer(char8_t
const (& literal)[N])
248 {
return reinterpret_cast<char const *
>(literal); }
252 #if defined LIBO_INTERNAL_ONLY
253 template<std::
size_t N,
typename T>
254 struct ConstCharArrayDetector<
sal_Unicode const [N], T> {
256 static constexpr
bool const ok =
true;
257 static constexpr std::size_t
const length = N - 1;
262 template<
typename T>
struct ConstCharArrayDetector<
267 static constexpr
bool const ok =
true;
268 static constexpr std::size_t
const length = 1;
270 OUStringChar_
const & literal)
271 {
return &literal.c; }
276 template<
typename T >
285 #if defined LIBO_INTERNAL_ONLY
286 template<std::
size_t N>
288 template<>
struct ExceptConstCharArrayDetector<
298 template<
typename T >
311 #if defined LIBO_INTERNAL_ONLY
313 template<std::
size_t N>
struct ExceptCharArrayDetector<
sal_Unicode const[N]> {};
314 template<>
struct ExceptCharArrayDetector<OUStringChar_> {};
317 template<
typename T1,
typename T2 =
void >
320 static const bool ok =
false;
322 template<
typename T >
326 static const bool ok =
true;
328 template<
typename T >
332 static const bool ok =
true;
336 template<
typename T,
bool >
341 template<
typename T >
352 #endif // INCLUDED_RTL_STRINGUTILS_HXX
Definition: stringutils.hxx:133
Definition: stringutils.hxx:300
T Type
Definition: stringutils.hxx:145
T Type
Definition: stringutils.hxx:191
T Type
Definition: stringutils.hxx:331
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:578
Definition: stringutils.hxx:338
static const bool ok
Definition: stringutils.hxx:186
Definition: stringutils.hxx:319
Definition: bootstrap.hxx:30
T Type
Definition: stringutils.hxx:325
T Type
Definition: stringutils.hxx:162
Definition: stringutils.hxx:278
Definition: stringutils.hxx:130
Dummy Type
Definition: stringutils.hxx:301
Definition: stringutils.hxx:185
sal_uInt16 sal_Unicode
Definition: types.h:141
static bool isValid(char const (&literal)[N])
Definition: stringutils.hxx:197
static const bool ok
Definition: stringutils.hxx:134
Dummy Type
Definition: stringutils.hxx:279
static const bool ok
Definition: stringutils.hxx:320
Definition: stringutils.hxx:157
T Type
Definition: stringutils.hxx:139
T Type
Definition: stringutils.hxx:344
static char const * toPointer(char const (&literal)[N])
Definition: stringutils.hxx:208