String processing, number parsing and number formatting
More...
|
#define | CC_XSTR(x) CC_STR(x) |
| Translate a macro expression into a C string.
|
|
|
Format | fout (const String &pattern="") |
| Generate formatted text on the standard output stream.
|
|
Format | ferr (const String &pattern="") |
| Generate formatted text on the standard error stream.
|
|
template<class T > |
T | commonPrefix (const T &a, const T &b) |
| Determine the common prefix between a and b.
|
|
|
template<class T > |
T | toLower (T ch) |
| Convert character ch to the corresponding lower-case character.
|
|
template<class T > |
T | toUpper (T ch) |
| Convert character ch to the corresponding upper-case character.
|
|
template<class T > |
bool | isLower (T ch) |
| Check if ch is a lower-case character.
|
|
template<class T > |
bool | isUpper (T ch) |
| Check if ch is an upper-case character.
|
|
template<class T > |
bool | isSpace (T ch) |
| Check if ch is a space character.
|
|
|
long | scanToken (const String &text, Out< String > token, const char *lt=" \t\n", long i0=0, long i1=-1) |
| Scan for a sub-string up to a lexical termination
|
|
bool | offsetToLinePos (const String &text, long offset, Out< long > line=None{}, Out< long > pos=None{}) |
| Map byte offset to editor coordinates
|
|
bool | linePosToOffset (const String &text, long line, long pos, Out< long > offset=None{}) |
| Map editor coordinates to byte offset
|
|
String | escape (const String &text) |
| Replace all non-printable and non-ASCII characters in text by escape sequences.
|
|
String | normalize (const String &text, bool nameCase=true) |
| Common user input normalization.
|
|
String | xmlEscape (const String &text) |
| Escape all XML tags an entities in text.
|
|
String | xmlSanitize (const String &text) |
| Remove all XML tags and entities in text.
|
|
|
template<class T > |
String | inum (T x, int base=10, int n=-1) |
| Convert an integer value to string.
|
|
template<class T > |
String | dec (T x, int n=-1) |
| Convert an integer to a decimal string.
|
|
template<class T > |
String | hex (T x, int n=-1) |
| Convert an integer to a hexadecimal string.
|
|
String | hex (const Bytes &data, char a='A') |
| Convert data to hexadecimal.
|
|
Bytes | readHex (const String &hex) |
| Convert hexadecimal literal hex to a byte array.
|
|
String | hex (const String &data, char a='A') |
| Convert data to hexadecimal.
|
|
template<class T > |
String | oct (T x, int n=-1) |
| Convert an integer to an octal string.
|
|
template<class T > |
String | bin (T x, int n=-1) |
| Convert an integer to a binary string.
|
|
String | fnum (double x, int precision=16, int base=10, int screen=6) |
| Convert a floating-point number to string.
|
|
String | fixed (double x, int nf) |
| Convert a floating point number to a fixed point notation string.
|
|
String | fixed (double x, int ni, int nf) |
| Convert a floating point number to a fixed point notation string.
|
|
String | sci (float x, int precision=8) |
| Convert a floating point number to a exponential notation string.
|
|
String | sci (double x, int precision=17) |
| Convert a floating point number to a exponential notation string.
|
|
String | dec (float x, int precision=8) |
| Convert a floating point number to decimal string.
|
|
String | dec (double x, int precision=17) |
| Convert a floating point number to decimal string.
|
|
|
String | str (const String &x) |
| Convert x to string.
|
|
String | str (const char *x) |
| Convert x to string.
|
|
String | str (char *x) |
| Convert x to string.
|
|
String | str (bool x) |
| Convert x to string.
|
|
String | str (const void *x) |
| Convert x to string.
|
|
String | str (char x) |
| Convert x to string.
|
|
String | str (char32_t ch) |
| Convert an unicode character to a string.
|
|
String | str (unsigned char x) |
| Convert x to string.
|
|
String | str (unsigned short x) |
| Convert x to string.
|
|
String | str (unsigned int x) |
| Convert x to string.
|
|
String | str (unsigned long x) |
| Convert x to string.
|
|
String | str (unsigned long long x) |
| Convert x to string.
|
|
String | str (short x) |
| Convert x to string.
|
|
String | str (int x) |
| Convert x to string.
|
|
String | str (long x) |
| Convert x to string.
|
|
String | str (long long x) |
| Convert x to string.
|
|
String | str (float x) |
| Convert x to string.
|
|
String | str (double x) |
| Convert x to string.
|
|
template<class T > |
String | str (const List< T > &list) |
| Convert list to string.
|
|
template<class K , class T , class O > |
String | str (const Map< K, T, O > &map) |
| Convert map to string.
|
|
template<class K , class T , class O > |
String | str (const MultiMap< K, T, O > &map) |
| Convert map to string.
|
|
template<class T , class O > |
String | str (const Set< T, O > &set) |
| Convert set to string.
|
|
template<class T , class O > |
String | str (const MultiSet< T, O > &set) |
| Convert set to string.
|
|
String | str (const Range &range) |
| Convert range to string.
|
|
template<class T , unsigned j, unsigned i = j> |
String | str (const Bit< T, j, i > &bit) |
|
String processing, number parsing and number formatting
◆ CC_XSTR
#define CC_XSTR |
( |
| x | ) |
CC_STR(x) |
Translate a macro expression into a C string.
◆ toLower()
Convert character ch to the corresponding lower-case character.
- Template Parameters
-
◆ scanToken()
long scanToken |
( |
const String & | text, |
|
|
Out< String > | token, |
|
|
const char * | lt = " \t\n", |
|
|
long | i0 = 0, |
|
|
long | i1 = -1 ) |
Scan for a sub-string up to a lexical termination
- Parameters
-
text | Input text |
token | Return the scanned sub-string |
lt | Set of lexical termination characters |
i0 | Begin of range to scan (index of first character) |
i1 | End of range to scan (index behind the last charater) |
- Returns
- Final scan position
◆ fout()
Generate formatted text on the standard output stream.
◆ ferr()
Generate formatted text on the standard error stream.
◆ inum()
template<class T >
String inum |
( |
T | x, |
|
|
int | base = 10, |
|
|
int | n = -1 ) |
Convert an integer value to string.
- Template Parameters
-
- Parameters
-
x | Integer value |
base | Number base (2..62) |
n | Maximum number of digits |
- Returns
- Text representation of x
◆ str() [1/24]
◆ commonPrefix()
template<class T >
T commonPrefix |
( |
const T & | a, |
|
|
const T & | b ) |
Determine the common prefix between a and b.
◆ toUpper()
Convert character ch to the corresponding upper-case character.
- Template Parameters
-
◆ isLower()
Check if ch is a lower-case character.
◆ isUpper()
Check if ch is an upper-case character.
◆ isSpace()
Check if ch is a space character.
◆ offsetToLinePos()
bool offsetToLinePos |
( |
const String & | text, |
|
|
long | offset, |
|
|
Out< long > | line = None{}, |
|
|
Out< long > | pos = None{} ) |
Map byte offset to editor coordinates
- Parameters
-
text | Text to scan |
offset | Global byte offset |
line | Returns the line number (starting with 1) |
pos | Returns the byte offset on the target line (starting with 0) |
- Returns
- True if offset is within range
◆ linePosToOffset()
bool linePosToOffset |
( |
const String & | text, |
|
|
long | line, |
|
|
long | pos, |
|
|
Out< long > | offset = None{} ) |
Map editor coordinates to byte offset
- Parameters
-
text | Text to scan |
line | Line number (starting with 1) |
pos | Character offset on the line (starting with 0) |
offset | Retunrs the global byte offset |
- Returns
- True if successful
◆ escape()
Replace all non-printable and non-ASCII characters in text by escape sequences.
◆ normalize()
String normalize |
( |
const String & | text, |
|
|
bool | nameCase = true ) |
Common user input normalization.
- Parameters
-
text | Input text |
nameCase | Make sure the first character is upper case |
- Returns
- Normalized input text
◆ xmlEscape()
Escape all XML tags an entities in text.
◆ xmlSanitize()
Remove all XML tags and entities in text.
◆ dec() [1/3]
template<class T >
String dec |
( |
T | x, |
|
|
int | n = -1 ) |
Convert an integer to a decimal string.
- Parameters
-
x | Integer value |
n | Number of digits |
- Returns
- Text representation of x
◆ hex() [1/3]
template<class T >
String hex |
( |
T | x, |
|
|
int | n = -1 ) |
Convert an integer to a hexadecimal string.
- Parameters
-
x | Integer value |
n | Number of digits |
- Returns
- Text representation of x
◆ hex() [2/3]
Convert data to hexadecimal.
- Todo
- Introduce Byte->Array<uint8_t> and move this function to Bytes::hex()
◆ readHex()
Convert hexadecimal literal hex to a byte array.
◆ hex() [3/3]
Convert data to hexadecimal.
◆ oct()
template<class T >
String oct |
( |
T | x, |
|
|
int | n = -1 ) |
Convert an integer to an octal string.
- Parameters
-
x | Integer value |
n | Number of digits |
- Returns
- Text representation of x
◆ bin()
template<class T >
String bin |
( |
T | x, |
|
|
int | n = -1 ) |
Convert an integer to a binary string.
- Parameters
-
x | Integer value |
n | Number of digits |
- Returns
- Text representation of x
◆ fnum()
String fnum |
( |
double | x, |
|
|
int | precision = 16, |
|
|
int | base = 10, |
|
|
int | screen = 6 ) |
Convert a floating-point number to string.
- Parameters
-
x | Floating-point value |
precision | Number of significiant digits |
base | Number base (2..62) |
screen | Maximum absolute exponent for choosing a non-exponential notation |
- Returns
- Text representation of x
- Todo
- make use of frexp
- Todo
- make use of frexp
◆ fixed() [1/2]
String fixed |
( |
double | x, |
|
|
int | nf ) |
Convert a floating point number to a fixed point notation string.
- Parameters
-
x | Floating point value |
nf | Number of fractional digits |
- Returns
- Text representation of x
◆ fixed() [2/2]
String fixed |
( |
double | x, |
|
|
int | ni, |
|
|
int | nf ) |
Convert a floating point number to a fixed point notation string.
- Parameters
-
x | Floating point value |
ni | Number of integral digits |
nf | Number of fractional digits |
- Returns
- Text representation of x
◆ sci() [1/2]
String sci |
( |
float | x, |
|
|
int | precision = 8 ) |
Convert a floating point number to a exponential notation string.
- Parameters
-
x | Integer value |
precision | Number of significiant digits |
- Returns
- Text representation of x
◆ sci() [2/2]
String sci |
( |
double | x, |
|
|
int | precision = 17 ) |
Convert a floating point number to a exponential notation string.
- Parameters
-
x | Integer value |
precision | Number of significiant digits |
- Returns
- Text representation of x
◆ dec() [2/3]
String dec |
( |
float | x, |
|
|
int | precision = 8 ) |
Convert a floating point number to decimal string.
- Parameters
-
x | Floating point number |
precision | Number of significiant digits |
- Returns
- Text representation of x
◆ dec() [3/3]
String dec |
( |
double | x, |
|
|
int | precision = 17 ) |
Convert a floating point number to decimal string.
- Parameters
-
x | Floating point number |
precision | Number of significiant digits |
- Returns
- Text representation of x
◆ str() [2/24]
◆ str() [3/24]
◆ str() [4/24]
◆ str() [5/24]
◆ str() [6/24]
◆ str() [7/24]
Convert an unicode character to a string.
◆ str() [8/24]
◆ str() [9/24]
String str |
( |
unsigned short | x | ) |
|
◆ str() [10/24]
◆ str() [11/24]
◆ str() [12/24]
String str |
( |
unsigned long long | x | ) |
|
◆ str() [13/24]
◆ str() [14/24]
◆ str() [15/24]
◆ str() [16/24]
◆ str() [17/24]
◆ str() [18/24]
◆ str() [19/24]
◆ str() [20/24]
template<class K , class T , class O >
◆ str() [21/24]
template<class K , class T , class O >
◆ str() [22/24]
template<class T , class O >
◆ str() [23/24]
template<class T , class O >
◆ str() [24/24]