libcommonc++  0.7
CharOps Class Reference

UTF-16 character array operations. More...

#include <CharOps.h++>

Static Public Member Functions

static int compare (const char16_t *a, const char16_t *b, bool ignoreCase=false)
 Compare two UTF-16 character arrays. More...
 
static int compare (const char16_t a, const char16_t b, bool ignoreCase=false)
 Compare two UTF-16 characters. More...
 
static int compare (const char16_t *a, const char16_t *b, uint_t n, bool ignoreCase=false)
 Compare two UTF-16 character arrays. More...
 
static char16_tmove (char16_t *dest, char16_t *src, uint_t n)
 Move an array of UTF-16 characters to another, possibly overlapping array. More...
 
static const char16_tfind (const char16_t *str, char16_t c, uint_t len=0)
 Find a UTF-16 character in a UTF-16 character array. More...
 
static char16_tfind (char16_t *str, char16_t c, uint_t len=0)
 Find a UTF-16 character in a UTF-16 character array. More...
 
static const char16_tfind (const char16_t *str, const char16_t *s)
 Find a UTF-16 character sequence in a UTF-16 character array. More...
 
static char16_tfind (char16_t *str, const char16_t *s)
 Find a UTF-16 character sequence in a UTF-16 character array. More...
 
static const char16_tfindLast (const char16_t *str, char16_t c, uint_t fromIndex=END)
 Find the last occurrence of a UTF-16 character in a UTF-16 character array. More...
 
static char16_tfindLast (char16_t *str, char16_t c, uint_t fromIndex=END)
 Find the last occurrence of a UTF-16 character in a UTF-16 character array. More...
 
static const char16_tfindLast (const char16_t *str, const char16_t *s, uint_t fromIndex=END)
 Find the last occurrence of a UTF-16 character sequence in a UTF-16 character* array. More...
 
static char16_tfindLast (char16_t *str, const char16_t *s, uint_t fromIndex=END)
 Find the last occurrence of a UTF-16 character sequence in a UTF-16 character* array. More...
 
static uint_t length (const char16_t *str)
 Calculate the length (in characters) of a UTF-16 character array. More...
 
static char16_tcopy (char16_t *dest, const char16_t *src, uint_t n)
 Copy at most n unicode characters from one UTF-16 character array to another. More...
 
static char16_tcopyRaw (char16_t *dest, const char16_t *src, uint_t n)
 Copy exactly n unicode characters from one UTF-16 character array to another, without regard for NUL characters. More...
 
static int32_t toLong (const char16_t *str, int base=10)
 Parse a 32-bit integer value from a UTF-16 character array. More...
 
static uint32_t toULong (const char16_t *str, int base=10)
 Parse an unsigned 32-bit integer value from a UTF-16 character array. More...
 
static int64_t toLongLong (const char16_t *str, int base=10)
 Parse a 64-bit integer value from a UTF-16 character array. More...
 
static uint64_t toULongLong (const char16_t *str, int base=10)
 Parse an unsigned 64-bit integer value from a UTF-16 character array. More...
 
static float toFloat (const char16_t *str)
 Parse a floating point value from a UTF-16 character array. More...
 
static double toDouble (const char16_t *str)
 Parse a double-precision floating point value from a UTF-16 character array. More...
 

Static Public Attributes

static const uint_t END = ~0
 A pseudo-index indicating the end of a UTF-16 character array. More...
 
static const char16_t TRUE_REP []
 
static const char16_t FALSE_REP []
 
static const char16_t DIGITS []
 

Detailed Description

UTF-16 character array operations.

Unless stated otherwise, all methods assume that UTF-16 character array arguments are NUL-terminated.

Author
Mark Lindner

Member Function Documentation

◆ compare() [1/3]

int compare ( const char16_t a,
const char16_t b,
bool  ignoreCase = false 
)
static

Compare two UTF-16 character arrays.

Parameters
aThe first array.
bThe second array.
ignoreCaseWhether the comparison should be case-insensitive.
Returns
A value less than 0 if a is lexicographically less than b, a value greater than 0 if it a is lexicographically greater than b, or 0 if the arrays are equal.

◆ compare() [2/3]

int compare ( const char16_t  a,
const char16_t  b,
bool  ignoreCase = false 
)
static

Compare two UTF-16 characters.

Parameters
aThe first character.
bThe second character.
ignoreCaseWhether the comparison should be case-insensitive.
Returns
A value less than 0 if a is lexicographically less than b, a value greater than 0 if it a is lexicographically greater than b, or 0 if the characters are equal.

◆ compare() [3/3]

int compare ( const char16_t a,
const char16_t b,
uint_t  n,
bool  ignoreCase = false 
)
static

Compare two UTF-16 character arrays.

Parameters
aThe first character.
bThe second character.
nThe number of characters to compare.
ignoreCaseWhether the comparison should be case-insensitive.
Returns
A value less than 0 if a is lexicographically less than b, a value greater than 0 if it a is lexicographically greater than b, or 0 if the character arrays are equal.

◆ copy()

char16_t * copy ( char16_t dest,
const char16_t src,
uint_t  n 
)
static

Copy at most n unicode characters from one UTF-16 character array to another.

Parameters
destThe destination array.
srcThe sourcde array.
nThe maximum number of unicode characters to copy.
Returns
The destination array.

◆ copyRaw()

char16_t * copyRaw ( char16_t dest,
const char16_t src,
uint_t  n 
)
static

Copy exactly n unicode characters from one UTF-16 character array to another, without regard for NUL characters.

Parameters
destThe destination array.
srcThe sourcde array.
nThe exact number of unicode characters to copy.
Returns
The destination array.

◆ find() [1/4]

const char16_t * find ( const char16_t str,
char16_t  c,
uint_t  len = 0 
)
static

Find a UTF-16 character in a UTF-16 character array.

Parameters
strThe array to search.
cThe character to find.
lenThe length of the array to search.
Returns
A pointer to the character, if found, otherwise NULL.

◆ find() [2/4]

char16_t * find ( char16_t str,
char16_t  c,
uint_t  len = 0 
)
static

Find a UTF-16 character in a UTF-16 character array.

Parameters
strThe array to search.
cThe character to find.
lenThe length of the array to search.
Returns
A pointer to the character, if found, otherwise NULL.

◆ find() [3/4]

const char16_t * find ( const char16_t str,
const char16_t s 
)
static

Find a UTF-16 character sequence in a UTF-16 character array.

Parameters
strThe array to search.
sThe NUL-terminated character sequence to find.
Returns
A pointer to the beginning of the sequence, if found; otherwise NULL.

◆ find() [4/4]

char16_t * find ( char16_t str,
const char16_t s 
)
static

Find a UTF-16 character sequence in a UTF-16 character array.

Parameters
strThe array to search.
sThe NUL-terminated character sequence to find.
Returns
A pointer to the beginning of the sequence, if found; otherwise NULL.

◆ findLast() [1/4]

const char16_t * findLast ( const char16_t str,
char16_t  c,
uint_t  fromIndex = END 
)
static

Find the last occurrence of a UTF-16 character in a UTF-16 character array.

Parameters
strThe array to search.
cThe character to find.
fromIndexThe end index from which to start the (reverse) search, or END to start from the end of the array.
Returns
A pointer to the character, if found, otherwise NULL.

◆ findLast() [2/4]

char16_t * findLast ( char16_t str,
char16_t  c,
uint_t  fromIndex = END 
)
static

Find the last occurrence of a UTF-16 character in a UTF-16 character array.

Parameters
strThe array to search.
cThe character to find.
fromIndexThe end index from which to start the (reverse) search, or END to start from the end of the array.
Returns
A pointer to the character, if found, otherwise NULL.

◆ findLast() [3/4]

const char16_t * findLast ( const char16_t str,
const char16_t s,
uint_t  fromIndex = END 
)
static

Find the last occurrence of a UTF-16 character sequence in a UTF-16 character* array.

Parameters
strThe array to search.
sThe character sequence to find.
fromIndexThe end index from which to start the (reverse) search, or END to start from the end of the array.
Returns
A pointer to the beginning of the sequence, if found, otherwise NULL.

◆ findLast() [4/4]

char16_t * findLast ( char16_t str,
const char16_t s,
uint_t  fromIndex = END 
)
static

Find the last occurrence of a UTF-16 character sequence in a UTF-16 character* array.

Parameters
strThe array to search.
sThe character sequence to find.
fromIndexThe end index from which to start the (reverse) search, or END to start from the end of the array.
Returns
A pointer to the beginning of the sequence, if found, otherwise NULL.

◆ length()

uint_t length ( const char16_t str)
static

Calculate the length (in characters) of a UTF-16 character array.

Parameters
strThe array.
Returns
The length of the array, in unicode characters.

◆ move()

char16_t * move ( char16_t dest,
char16_t src,
uint_t  n 
)
static

Move an array of UTF-16 characters to another, possibly overlapping array.

Parameters
destThe destination array.
srcThe source array.
nThe number of characters to move.
Returns
The destination array.

◆ toDouble()

double toDouble ( const char16_t str)
static

Parse a double-precision floating point value from a UTF-16 character array.

Parameters
strThe array to parse.
Returns
The parsed value, or 0.0 if a valid value could not be parsed.

◆ toFloat()

float toFloat ( const char16_t str)
static

Parse a floating point value from a UTF-16 character array.

Parameters
strThe array to parse.
Returns
The parsed value, or 0.0f if a valid value could not be parsed.

◆ toLong()

int32_t toLong ( const char16_t str,
int  base = 10 
)
static

Parse a 32-bit integer value from a UTF-16 character array.

Parameters
strThe array to parse.
baseThe base of the numeric value.
Returns
The parsed value, or 0 if a valid value could not be parsed.

◆ toLongLong()

int64_t toLongLong ( const char16_t str,
int  base = 10 
)
static

Parse a 64-bit integer value from a UTF-16 character array.

Parameters
strThe array to parse.
baseThe base of the numeric value.
Returns
The parsed value, or 0 if a valid value could not be parsed.

◆ toULong()

uint32_t toULong ( const char16_t str,
int  base = 10 
)
static

Parse an unsigned 32-bit integer value from a UTF-16 character array.

Parameters
strThe array to parse.
baseThe base of the numeric value.
Returns
The parsed value, or 0 if a valid value could not be parsed.

◆ toULongLong()

uint64_t toULongLong ( const char16_t str,
int  base = 10 
)
static

Parse an unsigned 64-bit integer value from a UTF-16 character array.

Parameters
strThe array to parse.
baseThe base of the numeric value.
Returns
The parsed value, or 0 if a valid value could not be parsed.

Member Data Documentation

◆ DIGITS

const char16_t DIGITS
static
Initial value:
= { char16_t('0'), char16_t('1'),
char16_t('2'), char16_t('3'),
char16_t('4'), char16_t('5'),
char16_t('6'), char16_t('7'),
char16_t('8'), char16_t('9'),
char16_t('A'), char16_t('B'),
char16_t('C'), char16_t('D'),
char16_t('E'), char16_t('F'),
char16_t('G'), char16_t('H'),
char16_t('I'), char16_t('J'),
char16_t('K'), char16_t('L'),
char16_t('M'), char16_t('N'),
char16_t('O'), char16_t('P'),
char16_t('Q'), char16_t('R'),
char16_t('S'), char16_t('T'),
char16_t('U'), char16_t('V'),
char16_t('W'), char16_t('X'),
char16_t('Y'), char16_t('Z'), 0 }

◆ END

const uint_t END = ~0
static

A pseudo-index indicating the end of a UTF-16 character array.

◆ FALSE_REP

const char16_t FALSE_REP
static
Initial value:
= { char16_t('f'), char16_t('a'),
char16_t('l'), char16_t('s'),
char16_t('e'), 0 }

◆ TRUE_REP

const char16_t TRUE_REP
static
Initial value:
= { char16_t('t'), char16_t('r'),
char16_t('u'), char16_t('e'), 0 }

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