52 #ifndef __PCL_CharTraits_h
53 #define __PCL_CharTraits_h
58 #include <pcl/Diagnostics.h>
82 extern const uint8* PCL_DATA PCL_toLowercaseLatin1;
83 extern const uint8* PCL_DATA PCL_toUppercaseLatin1;
100 #define PCL_COMPARE_CODE_POINTS() \
101 PCL_PRECONDITION( n1 == 0 || n2 == 0 || s1 != nullptr && s2 != nullptr ) \
102 if ( caseSensitive ) \
104 for ( size_type n = pcl::Min( n1, n2 ); n > 0; --n, ++s1, ++s2 ) \
106 return (*s1 < *s2) ? -1 : +1; \
110 for ( size_type n = pcl::Min( n1, n2 ); n > 0; --n, ++s1, ++s2 ) \
112 char_type c1 = ToCaseFolded( *s1 ), c2 = ToCaseFolded( *s2 ); \
114 return (c1 < c2) ? -1 : +1; \
117 return (n1 == n2) ? 0 : ((n1 < n2) ? -1 : +1)
130 template <
typename Tt,
typename Tp>
inline
133 PCL_PRECONDITION( nt == 0 || np == 0 || t !=
nullptr && p !=
nullptr )
135 if ( nt == 0 || np == 0 )
138 const Tt* et = t + nt;
139 const Tp* ep = p + np;
140 const Tt* bt =
nullptr;
141 const Tp* bp =
nullptr;
147 if ( c == Tp(
'*' ) )
152 while ( (c = *p) == Tp(
'*' ) );
154 if ( c != Tp(
'?' ) )
155 while ( Tt( c ) != *t )
162 else if ( Tt( c ) != *t && c != Tp(
'?' ) )
170 if ( Tt( *p ) != *t )
197 while ( *p == Tp(
'*' ) )
206 template <
typename Tt,
typename Tp,
class Ut,
class Up>
inline
207 bool WildMatchIC(
const Tt* t,
size_type nt,
const Tp* p,
size_type np, Ut ut, Up up )
209 PCL_PRECONDITION( nt == 0 || np == 0 || t !=
nullptr && p !=
nullptr && ut !=
nullptr && up !=
nullptr )
211 if ( nt == 0 || np == 0 )
214 const Tt* et = t + nt;
215 const Tp* ep = p + np;
216 const Tt* bt =
nullptr;
217 const Tp* bp =
nullptr;
223 if ( c == Tp(
'*' ) )
228 while ( (c = *p) == Tp(
'*' ) );
230 if ( c != Tp(
'?' ) )
233 while ( Tt( c ) != ut( *t ) )
241 else if ( c != Tp(
'?' ) )
245 if ( Tt( up( c ) ) != ft )
253 if ( Tt( up( *p ) ) != ft )
281 while ( *p == Tp(
'*' ) )
314 template <
typename T>
343 for ( ; *t != Null(); ++t ) {}
356 PCL_PRECONDITION( n == 0 || s !=
nullptr )
374 PCL_PRECONDITION( n == 0 || dst !=
nullptr && src !=
nullptr )
375 ::memcpy( dst, src, n*
sizeof(
char_type ) );
388 PCL_PRECONDITION( n == 0 || dst !=
nullptr && src !=
nullptr )
389 ::memmove( dst, src, n*
sizeof(
char_type ) );
421 PCL_COMPARE_CODE_POINTS();
457 const char_type* __restrict__ s2,
size_type n2,
bool caseSensitive =
true,
bool localeAware =
true ) noexcept
459 return CompareCodePoints( s1, n1, s2, n2, caseSensitive );
488 return pcl::WildMatch( t, nt, p, np );
489 return pcl::WildMatchIC( t, nt, p, np, ToCaseFolded, ToCaseFolded );
505 return ToLowercase( c );
545 PCL_PRECONDITION( n == 0 || s !=
nullptr )
546 for ( ; n > 0; --n, ++s )
547 *s = ToLowercase( *s );
559 PCL_PRECONDITION( n == 0 || s !=
nullptr )
560 for ( ; n > 0; --n, ++s )
561 *s = ToUppercase( *s );
705 return c == Blank() || c == Tab() || c == CR() || c == LF();
741 return IsLowercaseAlpha( c ) || IsUppercaseAlpha( c );
765 return c == Underscore();
774 return IsAlpha( c ) || IsDigit( c ) || IsUnderscore( c );
783 return IsAlpha( c ) || IsUnderscore( c );
791 return c == MinusSign() || c == PlusSign();
799 return c == DecimalSeparator();
825 template <
typename Ptr1,
typename Ptr2>
828 for ( ; i < j && IsTrimable( *i ); ++i ) {}
840 template <
typename Ptr1,
typename Ptr2>
843 for ( ; i < j && IsTrimable( *(j-1) ); --j ) {}
881 return (s !=
nullptr) ? ::strlen( s ) : 0;
893 PCL_PRECONDITION( n == 0 || s !=
nullptr )
910 PCL_PRECONDITION( n == 0 || dst !=
nullptr && src !=
nullptr )
911 ::memcpy( dst, src, n );
924 PCL_PRECONDITION( n == 0 || dst !=
nullptr && src !=
nullptr )
925 ::memmove( dst, src, n );
951 PCL_COMPARE_CODE_POINTS();
1010 const char_type* __restrict__ s2,
size_type n2,
bool caseSensitive =
true,
bool localeAware =
true ) noexcept;
1037 if ( caseSensitive )
1038 return pcl::WildMatch( t, nt, p, np );
1039 return pcl::WildMatchIC( t, nt, p, np,
1040 [](
char_type c ) {
return ToCaseFolded( c ); },
1041 [](
char_type c ) {
return ToCaseFolded( c ); } );
1056 return ToLowercase( c );
1082 PCL_PRECONDITION( n == 0 || s !=
nullptr )
1083 for ( ; n > 0; --n, ++s )
1084 *s = ToCaseFolded( *s );
1092 PCL_PRECONDITION( n == 0 || s !=
nullptr )
1093 for ( ; n > 0; --n, ++s )
1094 *s = ToLowercase( *s );
1102 PCL_PRECONDITION( n == 0 || s !=
nullptr )
1103 for ( ; n > 0; --n, ++s )
1104 *s = ToUppercase( *s );
1141 #ifdef __PCL_WINDOWS
1142 return (s !=
nullptr) ? ::wcslen(
reinterpret_cast<const wchar_t*
>( s ) ) : 0u;
1144 return traits_base::Length( s );
1161 PCL_PRECONDITION( n == 0 || dst !=
nullptr && src !=
nullptr )
1162 ::memcpy( dst, src, n << 1 );
1175 PCL_PRECONDITION( n == 0 || dst !=
nullptr && src !=
nullptr )
1176 ::memmove( dst, src, n << 1 );
1202 PCL_COMPARE_CODE_POINTS();
1261 const char_type* __restrict__ s2,
size_type n2,
bool caseSensitive =
true,
bool localeAware =
true ) noexcept;
1288 if ( caseSensitive )
1289 return pcl::WildMatch( t, nt, p, np );
1290 return pcl::WildMatchIC( t, nt, p, np,
1291 [](
char_type c ) {
return ToCaseFolded( c ); },
1292 [](
char_type c ) {
return ToCaseFolded( c ); } );
1300 const char* __restrict__ p,
size_type np,
bool caseSensitive =
true ) noexcept
1302 if ( caseSensitive )
1303 return pcl::WildMatch( t, nt, p, np );
1304 return pcl::WildMatchIC( t, nt, p, np,
1305 [](
char_type c ) {
return ToCaseFolded( c ); },
1324 if ( c >= 65 && c <= 90 || c >= 192 && c <= 214 || c >= 216 && c <= 222 )
1328 return PCL_ToCaseFolded( c );
1339 if ( c >= 65 && c <= 90 || c >= 192 && c <= 214 || c >= 216 && c <= 222 )
1343 return PCL_ToLowercase( c );
1354 if ( c >= 97 && c <= 122 || c >= 224 && c <= 246 || c >= 248 && c <= 254 )
1358 return PCL_ToUppercase( c );
1366 PCL_PRECONDITION( n == 0 || s !=
nullptr )
1367 for ( ; n > 0; --n, ++s )
1368 *s = ToCaseFolded( *s );
1376 PCL_PRECONDITION( n == 0 || s !=
nullptr )
1377 for ( ; n > 0; --n, ++s )
1378 *s = ToLowercase( *s );
1386 PCL_PRECONDITION( n == 0 || s !=
nullptr )
1387 for ( ; n > 0; --n, ++s )
1388 *s = ToUppercase( *s );
1399 return (c16 & 0xFC00) == 0xD800;
1410 return char_type( (c32 >> 10) + 0xD7C0 );
1421 return (c16 & 0xFC00) == 0xDC00;
1432 return char_type( (c32%0x400) + 0xDC00 );
1442 return (
char32_type( high ) << 10) + low - 0x035FDC00;
A template instantiation of GenericCharTraits for char16_type.
static char_type ToUppercase(char_type c) noexcept
static char_type ToCaseFolded(char_type c) noexcept
static constexpr char_type LowSurrogate(char32_type c32) noexcept
static void CopyOverlapped(char_type *dst, const char_type *src, size_type n) noexcept
static bool WildMatch(const char_type *__restrict__ t, size_type nt, const char *__restrict__ p, size_type np, bool caseSensitive=true) noexcept
static void Copy(char_type *__restrict__ dst, const char_type *__restrict__ src, size_type n) noexcept
static void ToUppercase(char_type *s, size_type n) noexcept
static char_type ToLowercase(char_type c) noexcept
static void ToCaseFolded(char_type *s, size_type n) noexcept
static int CompareCodePoints(const char_type *__restrict__ s1, size_type n1, const char_type *__restrict__ s2, size_type n2, bool caseSensitive=true) noexcept
traits_base::char_type char_type
static constexpr bool IsHighSurrogate(char_type c16) noexcept
static size_type Length(const char_type *__restrict__ s) noexcept
static int Compare(const char_type *__restrict__ s1, size_type n1, const char_type *__restrict__ s2, size_type n2, bool caseSensitive=true, bool localeAware=true) noexcept
static void ToLowercase(char_type *s, size_type n) noexcept
static constexpr char_type HighSurrogate(char32_type c32) noexcept
static constexpr char32_type SurrogatePairToUTF32(char_type high, char_type low) noexcept
static constexpr bool IsLowSurrogate(char_type c16) noexcept
Generic base class of character traits classes.
static constexpr char_type LF() noexcept
static constexpr bool IsExponentDelimiter(char_type c) noexcept
static constexpr bool IsNull(char_type c) noexcept
static constexpr bool IsDigit(char_type c) noexcept
static int Compare(const char_type *__restrict__ s1, size_type n1, const char_type *__restrict__ s2, size_type n2, bool caseSensitive=true, bool localeAware=true) noexcept
static constexpr char_type ExponentDelimiter() noexcept
static constexpr bool IsSymbolDigit(char_type c) noexcept
static char_type ToCaseFolded(char_type c) noexcept
static constexpr char_type DecimalSeparator() noexcept
static constexpr char_type Underscore() noexcept
static int CompareCodePoints(const char_type *__restrict__ s1, size_type n1, const char_type *__restrict__ s2, size_type n2, bool caseSensitive=true) noexcept
static void ToLowercase(char_type *__restrict__ s, size_type n) noexcept
static constexpr char_type Colon() noexcept
static constexpr bool IsTrimable(char_type c) noexcept
static constexpr bool IsDecimalSeparator(char_type c) noexcept
static constexpr char_type Null() noexcept
static constexpr bool IsStartingSymbolDigit(char_type c) noexcept
static constexpr size_type BytesPerChar() noexcept
static Ptr1 SearchTrimLeft(Ptr1 i, Ptr2 j) noexcept
static void Fill(char_type *__restrict__ s, char_type c, size_type n) noexcept
static constexpr char_type SingleQuote() noexcept
static void ToUppercase(char_type *__restrict__ s, size_type n) noexcept
static constexpr char_type Hyphen() noexcept
static constexpr bool IsUnderscore(char_type c) noexcept
static constexpr char_type MinusSign() noexcept
static constexpr bool IsAlpha(char_type c) noexcept
static constexpr char_type Blank() noexcept
static constexpr char_type CR() noexcept
static Ptr2 SearchTrimRight(Ptr1 i, Ptr2 j) noexcept
static constexpr bool IsHexDigit(char_type c) noexcept
static constexpr char_type Semicolon() noexcept
static void Copy(char_type *__restrict__ dst, const char_type *__restrict__ src, size_type n) noexcept
static constexpr bool IsWildcard(char_type c) noexcept
static constexpr char_type Comma() noexcept
static bool WildMatch(const char_type *__restrict__ t, size_type nt, const char_type *__restrict__ p, size_type np, bool caseSensitive=true) noexcept
static size_type Length(const char_type *s) noexcept
static constexpr char_type ToUppercase(char_type c) noexcept
static constexpr char_type ToLowercase(char_type c) noexcept
static constexpr bool IsLowercaseAlpha(char_type c) noexcept
static constexpr char_type Tab() noexcept
static constexpr bool IsSign(char_type c) noexcept
static constexpr char_type PlusSign() noexcept
static constexpr bool IsUppercaseAlpha(char_type c) noexcept
static constexpr char_type DoubleQuote() noexcept
static constexpr bool IsSpace(char_type c) noexcept
static void CopyOverlapped(char_type *dst, const char_type *src, size_type n) noexcept
A template instantiation of GenericCharTraits for the char type.
static void ToCaseFolded(char_type *s, size_type n) noexcept
static void ToUppercase(char_type *s, size_type n) noexcept
static constexpr size_type Length(const char_type *__restrict__ s) noexcept
traits_base::char_type char_type
static void ToLowercase(char_type *s, size_type n) noexcept
static char_type ToLowercase(char_type c) noexcept
static char_type ToCaseFolded(char_type c) noexcept
static int Compare(const char_type *__restrict__ s1, size_type n1, const char_type *__restrict__ s2, size_type n2, bool caseSensitive=true, bool localeAware=true) noexcept
static int CompareCodePoints(const char_type *__restrict__ s1, size_type n1, const char_type *__restrict__ s2, size_type n2, bool caseSensitive=true) noexcept
static void CopyOverlapped(char_type *dst, const char_type *src, size_type n) noexcept
static void Copy(char_type *__restrict__ dst, const char_type *__restrict__ src, size_type n) noexcept
static char_type ToUppercase(char_type c) noexcept
static void Fill(char_type *__restrict__ s, char_type c, size_type n) noexcept