BasicCharTraits< T > Struct Template Reference

Character traits. More...

#include <BasicCharTraits.h++>

List of all members.

Static Public Member Functions

static size_t length (const T *str) throw ()
 Get the length of a string.
static T * copy (T *dest, const T *src, size_t n) throw ()
 Copy a string.
static T * rawCopy (T *dest, const T *src, size_t n) throw ()
 Copy a fixed number of characters.
static T * concat (T *dest, const T *src, size_t n) throw ()
 Concatenate a string onto another string.
static T * move (T *dest, T *src, size_t n) throw ()
 Copy a string to a possibly overlapping destination string.
static int compare (const T *str1, const T *str2, bool ignoreCase=false) throw ()
 Compare two strings.
static int rawCompare (const T *str1, const T *str2, size_t n) throw ()
 Compare two strings.
static int collate (const T *str1, const T *str2) throw ()
 Lexicographically compare two strings based on the collation rules of the current locale.
static int compare (const T *str1, const T *str2, size_t n, bool ignoreCase=false) throw ()
 Compare two strings.
static int compare (T c1, T c2, bool ignoreCase=false) throw ()
 Compare two characters.
static size_t span (const T *str, const T *accept) throw ()
 Calculate the length of the initial segment of a string which consists entirely of characters in the given set.
static int32_t toLong (const T *str, T **endptr=NULL, int base=10) throw ()
 Parse a long integer value from the string.
static uint32_t toULong (const T *str, T **endptr=NULL, int base=10) throw ()
 Parse an unsigned long integer value from the string.
static int64_t toLongLong (const T *str, T **endptr=NULL, int base=10) throw ()
 Parse a long long integer value from the string.
static uint64_t toULongLong (const T *str, T **endptr=NULL, int base=10) throw ()
 Parse an unsigned long long integer value from the string.
static float toFloat (const T *str, T **endptr=NULL) throw ()
 Parse a floating-point value from the string.
static double toDouble (const T *str, T **endptr=NULL) throw ()
 Parse a double-precision floating point value from the string.
static T * find (T *str, T c, size_t len=0) throw ()
 Find the first occurrence of a character in a string.
static const T * find (const T *str, T c, size_t len=0) throw ()
 Find the first occurrence of a character in a string.
static T * findLast (T *str, T c, uint_t fromIndex=END) throw ()
 Find the last occurrence of a character in a string.
static const T * findLast (const T *str, T c, uint_t fromIndex=END) throw ()
 Find the last occurrence of a character in a string.
static T * find (T *str, const T *s) throw ()
 Find the first occurrence of a substring in a string.
static const T * find (const T *str, const T *s) throw ()
 Find the first occurrence of a substring in a string.
static T * findLast (T *str, const T *s, uint_t fromIndex=END) throw ()
 Find the last occurrence of a substring in a string.
static const T * findLast (const T *str, const T *s, uint_t fromIndex=END) throw ()
 Find the last occurrence of a substring in a string.
static int printf (T *str, size_t len, const T *format,...) throw ()
 Write a formatted string.
static int vprintf (T *str, size_t len, const T *format, va_list vp) throw ()
 Write a formatted string.
static T nul () throw ()
 Return the NUL character.
static T plus () throw ()
 Return the '+' character.
static T minus () throw ()
 Return the '-' character.
static const T * null () throw ()
 Return a null string.
static const T * empty () throw ()
 Return an empty string.
static const T * whitespace () throw ()
 Return an array containing the set of whitespace characters.
static const T * digits () throw ()
 Return an array containing the set of digits used to represent numbers in base 2 through base 36 ('0' - '9' and 'A' - 'Z').
static const T * nullRep () throw ()
 Return a string representation of the null string.
static const T * trueRep () throw ()
 Return a string representation of the boolean value true.
static const T * falseRep () throw ()
 Return a string representation of the boolean value false.
static const T * intFormat () throw ()
 Return the format string for integers.
static const T * uintFormat () throw ()
 Return the format string for unsigned integers.
static const T * int64Format () throw ()
 Return the compiler-specific format string for 64-bit integers.
static const T * uint64Format () throw ()
 Return the compiler-specific format string for unsigned 64-bit integers.
static const T * doubleFormat () throw ()
 Return the format string for double-precision floating point numbers with a parameterized precision.
static bool isAlpha (T c) throw ()
 Test if a character is alphabetic.
static bool isAlphaNumeric (T c) throw ()
 Test if a character is alphanumeric.
static bool isWhitespace (T c) throw ()
 Test if a character is whitespace.
static bool isPrintable (T c) throw ()
 Test if a character is printable.
static bool isGraphical (T c) throw ()
 Test if a character is graphical.
static bool isNul (T c) throw ()
 Test if a character is Nul.
static bool isControl (T c) throw ()
 Test if a character is a control character.
static bool isDigit (T c) throw ()
 Test if a character is a digit.
static bool isSign (T c) throw ()
 Test if a character is a sign symbol ('+' or '-').
static bool isHexDigit (T c) throw ()
 Test if a character is a hexadecimal digit.
static bool isLowerCase (T c) throw ()
 Test if a character is lowercase.
static bool isUpperCase (T c) throw ()
 Test if a character is uppercase.
static T toUpperCase (T c) throw ()
 Get the uppercase equivalent of a character.
static T toLowerCase (T c) throw ()
 Get the lowercase equivalent of a character.
static T fromInt (int v) throw ()
 Convert an integer value in the range 0 - 9 to the corresponding digit character '0' - '9'.
static int toInt (T c) throw ()
 Convert a digit character in the range '0' - '9' to the corresponding integer value 0 - 9.
static const char * encoding () throw ()
 Get the character encoding used for the internal representation of a BasicString<T>.

Static Public Attributes

static const uint_t END = 0xFFFFFFFF
 Pseudo-index indicating the end of the string.


Detailed Description

template<typename T>
struct ccxx::BasicCharTraits< T >

Character traits.

This class is a collection of functions for performing various low level character-string operations.

Author:
Mark Lindner

Member Function Documentation

static int collate ( const T *  str1,
const T *  str2 
) throw () [static]

Lexicographically compare two strings based on the collation rules of the current locale.

Parameters:
str1 The first string.
str2 The second string.
Returns:
A negative value if str1 < str2, a positive value if str1 > str2, and zero if the two strings are equal.

static int compare ( c1,
c2,
bool  ignoreCase = false 
) throw () [static]

Compare two characters.

Parameters:
c1 The first character.
c2 The second character.
ignoreCase A flag indicating whether the comparison should be case-sensitive.
Returns:
A negative value if c1 < c2, a positive value if c1 > c2, and zero if the two characters are equal.

static int compare ( const T *  str1,
const T *  str2,
size_t  n,
bool  ignoreCase = false 
) throw () [static]

Compare two strings.

Parameters:
str1 The first string.
str2 The second string.
n The maximum number of characters to compare.
ignoreCase A flag indicating whether the comparison should be case-sensitive.
Returns:
A negative value if str1 < str2, a positive value if str1 > str2, and zero if the two strings are equal.

static int compare ( const T *  str1,
const T *  str2,
bool  ignoreCase = false 
) throw () [static]

Compare two strings.

Parameters:
str1 The first string.
str2 The second string.
ignoreCase A flag indicating whether the comparison should be case-sensitive.
Returns:
A negative value if str1 < str2, a positive value if str1 > str2, and zero if the two strings are equal.

static T* concat ( T *  dest,
const T *  src,
size_t  n 
) throw () [static]

Concatenate a string onto another string.

Parameters:
dest The destination string.
src The source string.
n The maximum number of characters to concatenate.
Returns:
The destination string.

static T* copy ( T *  dest,
const T *  src,
size_t  n 
) throw () [static]

Copy a string.

Parameters:
dest The destination string.
src The source string.
n The maximum number of characters to copy.
Returns:
The destination string.

static const T* digits (  )  throw () [static]

Return an array containing the set of digits used to represent numbers in base 2 through base 36 ('0' - '9' and 'A' - 'Z').

static const T* doubleFormat (  )  throw () [static]

Return the format string for double-precision floating point numbers with a parameterized precision.

Returns the string "%.*f".

static const T* empty (  )  throw () [static]

Return an empty string.

static const char* encoding (  )  throw () [static]

Get the character encoding used for the internal representation of a BasicString<T>.

static const T* falseRep (  )  throw () [static]

Return a string representation of the boolean value false.

Returns the string "false".

static const T* find ( const T *  str,
const T *  s 
) throw () [static]

Find the first occurrence of a substring in a string.

Parameters:
str The string.
s The substring.
Returns:
A pointer to the substring, or NULL if the substring was not found.

static T* find ( T *  str,
const T *  s 
) throw () [static]

Find the first occurrence of a substring in a string.

Parameters:
str The string.
s The substring.
Returns:
A pointer to the substring, or NULL if the substring was not found.

static const T* find ( const T *  str,
c,
size_t  len = 0 
) throw () [static]

Find the first occurrence of a character in a string.

Parameters:
str The string.
c The character.
len The number of characters in the string to scan, or 0 to scan the entire string (up to the NUL terminator).
Returns:
A pointer to the character, or NULL if the character was not found.

static T* find ( T *  str,
c,
size_t  len = 0 
) throw () [static]

Find the first occurrence of a character in a string.

Parameters:
str The string.
c The character.
len The number of characters in the string to scan, or 0 to scan the entire string (up to the NUL terminator).
Returns:
A pointer to the character, or NULL if the character was not found.

static const T* findLast ( const T *  str,
const T *  s,
uint_t  fromIndex = END 
) throw () [static]

Find the last occurrence of a substring in a string.

Parameters:
str The string.
s The substring.
fromIndex The index to begin searching backwards from.
Returns:
A pointer to the substring, or NULL if the substring was not found.

static T* findLast ( T *  str,
const T *  s,
uint_t  fromIndex = END 
) throw () [static]

Find the last occurrence of a substring in a string.

Parameters:
str The string.
s The substring.
fromIndex The index to begin searching backwards from.
Returns:
A pointer to the substring, or NULL if the substring was not found.

static const T* findLast ( const T *  str,
c,
uint_t  fromIndex = END 
) throw () [static]

Find the last occurrence of a character in a string.

Parameters:
str The string.
c The character.
fromIndex The index to begin searching backwards from.
Returns:
A pointer to the character, or NULL if the character was not found.

static T* findLast ( T *  str,
c,
uint_t  fromIndex = END 
) throw () [static]

Find the last occurrence of a character in a string.

Parameters:
str The string.
c The character.
fromIndex The index to begin searching backwards from.
Returns:
A pointer to the character, or NULL if the character was not found.

static T fromInt ( int  v  )  throw () [static]

Convert an integer value in the range 0 - 9 to the corresponding digit character '0' - '9'.

If the value is outside the acceptable range, the character '0' is returned.

static const T* int64Format (  )  throw () [static]

Return the compiler-specific format string for 64-bit integers.

static const T* intFormat (  )  throw () [static]

Return the format string for integers.

Returns the string "%d".

static bool isAlpha ( c  )  throw () [static]

Test if a character is alphabetic.

static bool isAlphaNumeric ( c  )  throw () [static]

Test if a character is alphanumeric.

static bool isControl ( c  )  throw () [static]

Test if a character is a control character.

static bool isDigit ( c  )  throw () [static]

Test if a character is a digit.

static bool isGraphical ( c  )  throw () [static]

Test if a character is graphical.

static bool isHexDigit ( c  )  throw () [static]

Test if a character is a hexadecimal digit.

static bool isLowerCase ( c  )  throw () [static]

Test if a character is lowercase.

static bool isNul ( c  )  throw () [static]

Test if a character is Nul.

static bool isPrintable ( c  )  throw () [static]

Test if a character is printable.

static bool isSign ( c  )  throw () [static]

Test if a character is a sign symbol ('+' or '-').

static bool isUpperCase ( c  )  throw () [static]

Test if a character is uppercase.

static bool isWhitespace ( c  )  throw () [static]

Test if a character is whitespace.

static size_t length ( const T *  str  )  throw () [static]

Get the length of a string.

Parameters:
str The string.
Returns:
The length of the string, in characters.

static T minus (  )  throw () [static]

Return the '-' character.

static T* move ( T *  dest,
T *  src,
size_t  n 
) throw () [static]

Copy a string to a possibly overlapping destination string.

Parameters:
dest The destination string.
src The source string.
n The number of characters to copy.
Returns:
The destination string.

static T nul (  )  throw () [static]

Return the NUL character.

static const T* null (  )  throw () [static]

Return a null string.

static const T* nullRep (  )  throw () [static]

Return a string representation of the null string.

Returns the string "(null)".

static T plus (  )  throw () [static]

Return the '+' character.

static int printf ( T *  str,
size_t  len,
const T *  format,
  ... 
) throw () [static]

Write a formatted string.

Parameters:
str The string to write to.
len The maximum length of the string.
format The format string.
Returns:
The number of characters written, or -1 if there was not enough space available and/or the output was truncated.

static int rawCompare ( const T *  str1,
const T *  str2,
size_t  n 
) throw () [static]

Compare two strings.

This method differs from compare() in that it compares exactly the number of characters requested, without regard to nul terminators.

Parameters:
str1 The first string.
str2 The second string.
n The number of characters to compare.
Returns:
A negative value if str1 < str2, a positive value if str1 > str2, and zero if the two strings are equal.

static T* rawCopy ( T *  dest,
const T *  src,
size_t  n 
) throw () [static]

Copy a fixed number of characters.

This method differs from copy() in that it copies exactly the number of characters requested, without regard to nul terminators.

Parameters:
dest The destination string.
src The source string.
n The maximum number of characters to copy.
Returns:
The destination string.

static size_t span ( const T *  str,
const T *  accept 
) throw () [static]

Calculate the length of the initial segment of a string which consists entirely of characters in the given set.

Parameters:
str The string.
accept The set of characters.
Returns:
The length of the span.

static double toDouble ( const T *  str,
T **  endptr = NULL 
) throw () [static]

Parse a double-precision floating point value from the string.

Parameters:
str The string.
endptr A pointer at which to store a pointer to the first non-parsed character.
Returns:
The parsed value.

static float toFloat ( const T *  str,
T **  endptr = NULL 
) throw () [static]

Parse a floating-point value from the string.

Parameters:
str The string.
endptr A pointer at which to store a pointer to the first non-parsed character.
Returns:
The parsed value.

static int toInt ( c  )  throw () [static]

Convert a digit character in the range '0' - '9' to the corresponding integer value 0 - 9.

If the character is not a digit, 0 is returned.

static int32_t toLong ( const T *  str,
T **  endptr = NULL,
int  base = 10 
) throw () [static]

Parse a long integer value from the string.

Parameters:
str The string.
endptr A pointer at which to store a pointer to the first non-parsed character.
base The numeric base.
Returns:
The parsed value.

static int64_t toLongLong ( const T *  str,
T **  endptr = NULL,
int  base = 10 
) throw () [static]

Parse a long long integer value from the string.

Parameters:
str The string.
endptr A pointer at which to store a pointer to the first non-parsed character.
base The numeric base.
Returns:
The parsed value.

static T toLowerCase ( c  )  throw () [static]

Get the lowercase equivalent of a character.

static uint32_t toULong ( const T *  str,
T **  endptr = NULL,
int  base = 10 
) throw () [static]

Parse an unsigned long integer value from the string.

Parameters:
str The string.
endptr A pointer at which to store a pointer to the first non-parsed character.
base The numeric base.
Returns:
The parsed value.

static uint64_t toULongLong ( const T *  str,
T **  endptr = NULL,
int  base = 10 
) throw () [static]

Parse an unsigned long long integer value from the string.

Parameters:
str The string.
endptr A pointer at which to store a pointer to the first non-parsed character.
base The numeric base.
Returns:
The parsed value.

static T toUpperCase ( c  )  throw () [static]

Get the uppercase equivalent of a character.

static const T* trueRep (  )  throw () [static]

Return a string representation of the boolean value true.

Returns the string "true".

static const T* uint64Format (  )  throw () [static]

Return the compiler-specific format string for unsigned 64-bit integers.

static const T* uintFormat (  )  throw () [static]

Return the format string for unsigned integers.

Returns the string "%u".

static int vprintf ( T *  str,
size_t  len,
const T *  format,
va_list  vp 
) throw () [static]

Write a formatted string.

Parameters:
str The string to write to.
len The maximum length of the string.
format The format string.
vp The varargs list.
Returns:
The number of characters written, or -1 if there was not enough space available and/or the output was truncated.

static const T* whitespace (  )  throw () [static]

Return an array containing the set of whitespace characters.


Member Data Documentation

const uint_t END = 0xFFFFFFFF [static]

Pseudo-index indicating the end of the string.


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

Generated on Sat Apr 17 23:03:07 2010 for libcommonc++ by  doxygen 1.5.9