PCL
pcl::GenericCharTraits< T > Class Template Reference

Generic base class of character traits classes. More...

#include <CharTraits.h>

+ Inheritance diagram for pcl::GenericCharTraits< T >:

Public Types

using char_type = T
 

Static Public Member Functions

static constexpr char_type Blank () noexcept
 
static constexpr size_type BytesPerChar () noexcept
 
static constexpr char_type Colon () noexcept
 
static constexpr char_type Comma () 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 Copy (char_type *__restrict__ dst, const char_type *__restrict__ src, size_type n) noexcept
 
static void CopyOverlapped (char_type *dst, const char_type *src, size_type n) noexcept
 
static constexpr char_type CR () noexcept
 
static constexpr char_type DecimalSeparator () noexcept
 
static constexpr char_type DoubleQuote () noexcept
 
static constexpr char_type ExponentDelimiter () noexcept
 
static void Fill (char_type *__restrict__ s, char_type c, size_type n) noexcept
 
static constexpr char_type Hyphen () noexcept
 
static constexpr bool IsAlpha (char_type c) noexcept
 
static constexpr bool IsDecimalSeparator (char_type c) noexcept
 
static constexpr bool IsDigit (char_type c) noexcept
 
static constexpr bool IsExponentDelimiter (char_type c) noexcept
 
static constexpr bool IsHexDigit (char_type c) noexcept
 
static constexpr bool IsLowercaseAlpha (char_type c) noexcept
 
static constexpr bool IsNull (char_type c) noexcept
 
static constexpr bool IsSign (char_type c) noexcept
 
static constexpr bool IsSpace (char_type c) noexcept
 
static constexpr bool IsStartingSymbolDigit (char_type c) noexcept
 
static constexpr bool IsSymbolDigit (char_type c) noexcept
 
static constexpr bool IsTrimable (char_type c) noexcept
 
static constexpr bool IsUnderscore (char_type c) noexcept
 
static constexpr bool IsUppercaseAlpha (char_type c) noexcept
 
static constexpr bool IsWildcard (char_type c) noexcept
 
static size_type Length (const char_type *s) noexcept
 
static constexpr char_type LF () noexcept
 
static constexpr char_type MinusSign () noexcept
 
static constexpr char_type Null () noexcept
 
static constexpr char_type PlusSign () noexcept
 
template<typename Ptr1 , typename Ptr2 >
static Ptr1 SearchTrimLeft (Ptr1 i, Ptr2 j) noexcept
 
template<typename Ptr1 , typename Ptr2 >
static Ptr2 SearchTrimRight (Ptr1 i, Ptr2 j) noexcept
 
static constexpr char_type Semicolon () noexcept
 
static constexpr char_type SingleQuote () noexcept
 
static constexpr char_type Tab () noexcept
 
static char_type ToCaseFolded (char_type c) noexcept
 
static void ToLowercase (char_type *__restrict__ s, size_type n) noexcept
 
static constexpr char_type ToLowercase (char_type c) noexcept
 
static void ToUppercase (char_type *__restrict__ s, size_type n) noexcept
 
static constexpr char_type ToUppercase (char_type c) noexcept
 
static constexpr char_type Underscore () noexcept
 
static bool WildMatch (const char_type *__restrict__ t, size_type nt, const char_type *__restrict__ p, size_type np, bool caseSensitive=true) noexcept
 

Detailed Description

template<typename T>
class pcl::GenericCharTraits< T >

GenericCharTraits defines fundamental properties and functionality common to all character types.

The purpose of a character traits class is to characterize a data type to represent a single element of a string, or character. For example, a char traits class must provide primitive routines to copy, compare and classify characters and sequences of characters.

GenericCharTraits is a template class that must be instantiated for suitable data types. Two instantiations of GenericCharTraits, namely for char and char16_type, originate the IsoString and String fundamental PCL classes, respectively. The versatile interface provided by GenericCharTraits makes it possible to implement string classes virtually for any data type with default and copy constructor semantics.

See also
CharTraits, IsoCharTraits, String, IsoString

Definition at line 315 of file CharTraits.h.

Member Typedef Documentation

◆ char_type

template<typename T >
using pcl::GenericCharTraits< T >::char_type = T

Represents the character data type used by this traits class.

Definition at line 322 of file CharTraits.h.

Member Function Documentation

◆ Blank()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::Blank ( )
inlinestaticconstexprnoexcept

Returns the blank space character (white space).

Definition at line 575 of file CharTraits.h.

◆ BytesPerChar()

template<typename T >
static constexpr size_type pcl::GenericCharTraits< T >::BytesPerChar ( )
inlinestaticconstexprnoexcept

Number of bytes per character.

Definition at line 327 of file CharTraits.h.

◆ Colon()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::Colon ( )
inlinestaticconstexprnoexcept

Returns the colon punctuator character ':'.

Definition at line 615 of file CharTraits.h.

◆ Comma()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::Comma ( )
inlinestaticconstexprnoexcept

Returns the comma punctuator character ','.

Definition at line 607 of file CharTraits.h.

◆ Compare()

template<typename T >
static int pcl::GenericCharTraits< T >::Compare ( const char_type *__restrict__  s1,
size_type  n1,
const char_type *__restrict__  s2,
size_type  n2,
bool  caseSensitive = true,
bool  localeAware = true 
)
inlinestaticnoexcept

Lexicographical comparison between two generic strings.

Parameters
s1First string.
n1Length of the first string in characters.
s2Second string.
n2Length of the second string in characters.
caseSensitiveWhen true, a case-sensitive comparison is performed; otherwise the comparison does not distinguish between lowercase and uppercase characters. The default value of this parameter is true.
localeAwareThis parameter is ignored by GenericCharTraits. For locale-aware string comparisons, see the reimplementations of this static function in the IsoCharTraits and CharTraits template class instantiations.

Returns an integer code representing the comparison result:

  • 0 if s1 and s2 are equal
  • -1 if s1 is less than s2
  • +1 if s1 is greater than s2

This default implementation simply calls CompareCodePoints() to compare the numerical values of string characters, so it cannot be localized and can't be aware of user locale settings. For more comprehensive, locale-aware Unicode implementations of this static function, see the IsoCharTraits and CharTraits classes.

Definition at line 456 of file CharTraits.h.

◆ CompareCodePoints()

template<typename T >
static int pcl::GenericCharTraits< T >::CompareCodePoints ( const char_type *__restrict__  s1,
size_type  n1,
const char_type *__restrict__  s2,
size_type  n2,
bool  caseSensitive = true 
)
inlinestaticnoexcept

Compares numeric character values between two strings.

Parameters
s1First string.
n1Length of the first string in characters.
s2Second string.
n2Length of the second string in characters.
caseSensitiveWhen true, a case-sensitive comparison is performed; otherwise the comparison does not distinguish between lowercase and uppercase characters. The default value of this parameter is true.

Returns an integer code representing the comparison result:

  • 0 if s1 and s2 are equal
  • -1 if s1 is less than s2
  • +1 if s1 is greater than s2

This function compares the numerical values of string characters. For case-insensitive comparisons, this generic routine is only valid for the ISO/IEC 8859-1 character set: characters in the ranges 0x41-0x5A, 0xC0-0xD6 and 0xD8-0xDE are considered identical to its counterparts in the ranges 0x61-0x7A, 0xE0-0xF6 and 0xF8-0xFE, respectively.

Definition at line 418 of file CharTraits.h.

◆ Copy()

template<typename T >
static void pcl::GenericCharTraits< T >::Copy ( char_type *__restrict__  dst,
const char_type *__restrict__  src,
size_type  n 
)
inlinestaticnoexcept

Copies a contiguous sequence of characters to a specified location. The source and destination regions do not overlap.

Parameters
dstDestination location where characters will be copied.
srcInitial address of the sequence of source characters.
nNumber of characters to copy.

If the source and destination regions overlap, this routine will produce an unpredictable result. CopyOverlapped() should be used in these cases.

Definition at line 372 of file CharTraits.h.

◆ CopyOverlapped()

template<typename T >
static void pcl::GenericCharTraits< T >::CopyOverlapped ( char_type dst,
const char_type src,
size_type  n 
)
inlinestaticnoexcept

Copies a contiguous sequence of characters to a specified location. The source and destination regions may safely overlap.

Parameters
dstDestination location where characters will be copied.
srcInitial address of the sequence of source characters.
nNumber of characters to copy.

Definition at line 386 of file CharTraits.h.

◆ CR()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::CR ( )
inlinestaticconstexprnoexcept

Returns the carriage return control character '\r'.

Definition at line 591 of file CharTraits.h.

◆ DecimalSeparator()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::DecimalSeparator ( )
inlinestaticconstexprnoexcept

Returns the decimal separator character '.'.

Definition at line 655 of file CharTraits.h.

◆ DoubleQuote()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::DoubleQuote ( )
inlinestaticconstexprnoexcept

Returns the double quote character '"'.

Definition at line 687 of file CharTraits.h.

◆ ExponentDelimiter()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::ExponentDelimiter ( )
inlinestaticconstexprnoexcept

Returns the exponent delimiter character 'e'.

Definition at line 663 of file CharTraits.h.

◆ Fill()

template<typename T >
static void pcl::GenericCharTraits< T >::Fill ( char_type *__restrict__  s,
char_type  c,
size_type  n 
)
inlinestaticnoexcept

Fills a contiguous region of characters with a constant value.

Parameters
sInitial address of a character sequence.
cConstant value to fill with.
nNumber of characters to fill.

Definition at line 354 of file CharTraits.h.

◆ Hyphen()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::Hyphen ( )
inlinestaticconstexprnoexcept

Returns the hyphen punctuator character '-'.

Definition at line 631 of file CharTraits.h.

◆ IsAlpha()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsAlpha ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is in the range [a-zA-Z].

Definition at line 739 of file CharTraits.h.

◆ IsDecimalSeparator()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsDecimalSeparator ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is the decimal separator '.'.

Definition at line 797 of file CharTraits.h.

◆ IsDigit()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsDigit ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is a decimal digit. Decimal digits are in the range [0-9].

Definition at line 721 of file CharTraits.h.

◆ IsExponentDelimiter()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsExponentDelimiter ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is an exponent delimiter. Exponent delimiters are in the range [eEdD]. The [dD] pair allows for FORTRAN compatibility.

Definition at line 807 of file CharTraits.h.

◆ IsHexDigit()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsHexDigit ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is an hexadecimal digit. Hexadecimal digits are in the range [a-fA-F].

Definition at line 730 of file CharTraits.h.

◆ IsLowercaseAlpha()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsLowercaseAlpha ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is in the range [a-z].

Definition at line 747 of file CharTraits.h.

◆ IsNull()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsNull ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is a null string terminator.

Definition at line 695 of file CharTraits.h.

◆ IsSign()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsSign ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is a numerical sign, either '+' or '-'.

Definition at line 789 of file CharTraits.h.

◆ IsSpace()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsSpace ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is a white space character.

Definition at line 703 of file CharTraits.h.

◆ IsStartingSymbolDigit()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsStartingSymbolDigit ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is a valid starting symbol digit. A starting symbol digit is in the range [a-zA-Z_].

Definition at line 781 of file CharTraits.h.

◆ IsSymbolDigit()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsSymbolDigit ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is a valid symbol element. Symbol digits are in the range [a-zA-Z0-9_].

Definition at line 772 of file CharTraits.h.

◆ IsTrimable()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsTrimable ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is a trimable character. Generally equivalent to IsSpace().

Definition at line 712 of file CharTraits.h.

◆ IsUnderscore()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsUnderscore ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is the underscore character '_'.

Definition at line 763 of file CharTraits.h.

◆ IsUppercaseAlpha()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsUppercaseAlpha ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is in the range [A-Z].

Definition at line 755 of file CharTraits.h.

◆ IsWildcard()

template<typename T >
static constexpr bool pcl::GenericCharTraits< T >::IsWildcard ( char_type  c)
inlinestaticconstexprnoexcept

Returns true iff a character c is a wildcard. The wildcards are the asterisk '*' and question mark '?' characters.

Definition at line 816 of file CharTraits.h.

◆ Length()

template<typename T >
static size_type pcl::GenericCharTraits< T >::Length ( const char_type s)
inlinestaticnoexcept

Returns the length of a null-terminated string in characters (not bytes).

The returned value is the length of the initial contiguous sequence of characters that are not equal to Null().

Definition at line 339 of file CharTraits.h.

◆ LF()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::LF ( )
inlinestaticconstexprnoexcept

Returns the line feed control character '\n'.

Definition at line 599 of file CharTraits.h.

◆ MinusSign()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::MinusSign ( )
inlinestaticconstexprnoexcept

Returns the minus sign character '-'.

Definition at line 647 of file CharTraits.h.

◆ Null()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::Null ( )
inlinestaticconstexprnoexcept

Returns the null string termination character '\0'.

Definition at line 567 of file CharTraits.h.

◆ PlusSign()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::PlusSign ( )
inlinestaticconstexprnoexcept

Returns the plus sign character '+'.

Definition at line 639 of file CharTraits.h.

◆ SearchTrimLeft()

template<typename T >
template<typename Ptr1 , typename Ptr2 >
static Ptr1 pcl::GenericCharTraits< T >::SearchTrimLeft ( Ptr1  i,
Ptr2  j 
)
inlinestaticnoexcept

Returns a pointer to the first non-trimmable character in the sequence of contiguous characters defined by the range [i,j) of pointers.

Definition at line 826 of file CharTraits.h.

◆ SearchTrimRight()

template<typename T >
template<typename Ptr1 , typename Ptr2 >
static Ptr2 pcl::GenericCharTraits< T >::SearchTrimRight ( Ptr1  i,
Ptr2  j 
)
inlinestaticnoexcept

Returns a pointer to the character after the last non-trimmable character in the sequence of contiguous characters defined by the range [i,j) of pointers.

If there are no trimmable characters in the specified sequence, this function returns the ending pointer j.

Definition at line 841 of file CharTraits.h.

◆ Semicolon()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::Semicolon ( )
inlinestaticconstexprnoexcept

Returns the semicolon punctuator character ';'.

Definition at line 623 of file CharTraits.h.

◆ SingleQuote()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::SingleQuote ( )
inlinestaticconstexprnoexcept

Returns the single quote character "'".

Definition at line 679 of file CharTraits.h.

◆ Tab()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::Tab ( )
inlinestaticconstexprnoexcept

Returns the horizontal tab control character '\t'.

Definition at line 583 of file CharTraits.h.

◆ ToCaseFolded()

template<typename T >
static char_type pcl::GenericCharTraits< T >::ToCaseFolded ( char_type  c)
inlinestaticnoexcept

Returns the case folded equivalent character for the specified code point c.

Case folding elimitates case differences, which is useful for case-insensitive string comparisons.

This default implementation is only valid for the ISO/IEC-8859-1 character set. For a comprehensive Unicode implementation see the CharTraits class.

Definition at line 503 of file CharTraits.h.

◆ ToLowercase() [1/2]

template<typename T >
static void pcl::GenericCharTraits< T >::ToLowercase ( char_type *__restrict__  s,
size_type  n 
)
inlinestaticnoexcept

Transforms a string to lower case.

This default implementation is only valid for the ISO/IEC-8859-1 character set. For a comprehensive Unicode implementation see the CharTraits class.

Definition at line 543 of file CharTraits.h.

◆ ToLowercase() [2/2]

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::ToLowercase ( char_type  c)
inlinestaticconstexprnoexcept

Returns the lowercase equivalent character for the specified code point.

This default implementation is only valid for the ISO/IEC-8859-1 character set. For a comprehensive Unicode implementation see the CharTraits class.

Definition at line 515 of file CharTraits.h.

◆ ToUppercase() [1/2]

template<typename T >
static void pcl::GenericCharTraits< T >::ToUppercase ( char_type *__restrict__  s,
size_type  n 
)
inlinestaticnoexcept

Transforms a string to upper case.

This default implementation is only valid for the ISO/IEC-8859-1 character set. For a comprehensive Unicode implementation see the CharTraits class.

Definition at line 557 of file CharTraits.h.

◆ ToUppercase() [2/2]

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::ToUppercase ( char_type  c)
inlinestaticconstexprnoexcept

Returns the uppercase equivalent character for the specified code point.

This default implementation is only valid for the ISO/IEC-8859-1 character set. For a comprehensive Unicode implementation see the CharTraits class.

Definition at line 529 of file CharTraits.h.

◆ Underscore()

template<typename T >
static constexpr char_type pcl::GenericCharTraits< T >::Underscore ( )
inlinestaticconstexprnoexcept

Returns the underscore character '_'.

Definition at line 671 of file CharTraits.h.

◆ WildMatch()

template<typename T >
static bool pcl::GenericCharTraits< T >::WildMatch ( const char_type *__restrict__  t,
size_type  nt,
const char_type *__restrict__  p,
size_type  np,
bool  caseSensitive = true 
)
inlinestaticnoexcept

Wildcard string matching algorithm.

Parameters
tThe string to be matched.
ntLength of the string to be matched in characters.
pThe pattern string. May contain multiple instances of the wildcard characters '*' and '?'.
npLength of the pattern string in characters.
caseSensitiveWhen true, a case-sensitive comparison is performed; otherwise the comparison does not distinguish between lowercase and uppercase characters. The default value of this parameter is true.

Returns true iff the string t matches the specified pattern p. If one of the strings is empty, this function always returns false conventionally, even if the pattern is a single asterisk '*'.

Definition at line 484 of file CharTraits.h.


The documentation for this class was generated from the following file: