This is a detail namespace of module ALib Strings.
|
template<typename TChar > |
ALIB_API uint64_t | ParseBin (const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API uint64_t | ParseDec (const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
uint64_t | ParseDecDigits (const TString< TChar > &src, integer &idx) |
|
template<typename TChar > |
ALIB_API double | ParseFloat (const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API uint64_t | ParseHex (const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API int64_t | ParseInt (const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API uint64_t | ParseOct (const TString< TChar > &src, integer &idx, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API integer | WriteBin (uint64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API integer | WriteDecSigned (int64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API integer | WriteDecUnsigned (uint64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API integer | WriteFloat (double value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API integer | WriteHex (uint64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf) |
|
template<typename TChar > |
ALIB_API integer | WriteOct (uint64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf) |
|
template<typename TChar >
Reads an unsigned integral value in binary format from the given character array at the given position.
Sign literals '-'
or '+'
are not accepted and parsing will fail if found. Whitespace and grouping characters, as defined in fields Whitespaces, BinNibbleGroupChar, BinByteGroupChar BinWordGroupChar and BinWord32GroupChar of the NumberFormat object given with nf, will be ignored (tolerated), regardless on their position between digits. To suppress the parsing of group characters, set the fields to '\0'
. To suppress whitespace consumption, set field Whitespaces to nulled or empty string.
- Template Parameters
-
TChar | The character type of the string to parse from. |
- Parameters
-
| src | The string to read the value from. |
[in,out] | idx | The start point for parsing within src. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found. |
| nf | The number format to use. |
- Returns
- The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.
template<typename TChar >
Reads a floating point value from the given character array at the given position.
Sign literals '-'
or '+'
are not accepted and parsing will fail if found.
If the strings defined in fields NANLiteral and INFLiteral are found in the NumberFormat object given with nf, the corresponding double constant (not a number, positive/negative infinity) will be returned.
- Template Parameters
-
TChar | The character type of the string to parse from. |
- Parameters
-
| src | The string to read the value from. |
[in,out] | idx | The start point for parsing within src. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found. |
| nf | The number format to use. |
- Returns
- The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.
template<typename TChar >
Reads an unsigned integral value in hexadecimal format from the given character array at the given position.
Sign literals '-'
or '+'
are not accepted and parsing will fail if found. Whitespace and grouping characters, as defined in fields Whitespaces, HexByteGroupChar, HexWordGroupChar and HexWord32GroupChar of the NumberFormat object given with nf, will be ignored (tolerated) regardless of their position between digits. To suppress the parsing of group characters, set the fields to '\0'
. To suppress whitespace consumption, set field Whitespaces to nulled or empty string.
Letters 'a' to 'f' are parsed ignoring their case. This is independent of the setting of flag HexLowerCase in field Flags of given nf.
- Template Parameters
-
TChar | The character type of the string to parse from. |
- Parameters
-
| src | The string to read the value from. |
[in,out] | idx | The start point for parsing within src. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found. |
| nf | The number format to use. |
- Returns
- The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.
template<typename TChar >
Parses signed integer numbers, optionally in binary, hexadecimal or octal format.
Leading characters defined in field Whitespaces of the NumberFormat object given with nf are ignored. An optional sign character '+'
or '-'
is parsed. If found, again whitespace characters may follow behind such sign and are ignored.
Then, the function detects any literal prefixes as defined in fields BinLiteralPrefix, HexLiteralPrefix and OctLiteralPrefix (usually 0b
, 0x
and 0o
) and invokes one of the functions ParseDec, ParseBin, ParseHex or ParseOct.
- Template Parameters
-
TChar | The character type of the string to parse from. |
- Parameters
-
| src | The string to read the value from. |
[in,out] | idx | The start point for parsing within src. Will be set to point behind the last character consumed. If unchanged, this indicates that no parsable number was found. |
| nf | The number format to use. |
- Returns
- The parsed value. In addition, on success, parameter idx is moved to point to the first character behind the parsed number.
template<typename TChar >
Converts the given long value to a string representation in binary format.
The maximum number of digits written is 64. In addition, grouping characters may be written according the settings of flags WriteGroupChars, BinNibbleGroupChar, BinByteGroupChar, BinWordGroupChar, BinWord32GroupChar and LeadingGroupCharReplacement
of the NumberFormat object given with nf.
The minimum width of the output is taken from field BinFieldWidth unless overwritten by parameter minWidth. If the width is greater than digits found in value, '0'
digits are prepended. The width is taking group characters into account.
- Attention
- The function does not (and cannot) check an overflow of the given character buffer when writing.
-
If the value is greater than can be represented by the output width, these greater digits are cut. This is true for this function as well as for WriteHex and WriteOct. The rationale behind this is that this way, larger numbers do not need to be masked before writing. (In other words: it is assumed that there is a reason for providing the width).
- Note
- The literal prefix found in field BinLiteralPrefix of nf is not written. The field is only used for detecting formats with function ParseInt.
- Template Parameters
-
TChar | The character type of the string to write into. |
- Parameters
-
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
minWidth | The minimum width of the output. If 0 , the value of BinFieldWidth of argument nf is used. |
nf | Number format definitions. |
- Returns
- The index pointing to behind the last character written in buffer.
template<typename TChar >
Converts the given long value to a string representation in decimal format.
The maximum number of digits written is 20. In addition, grouping characters may be written according the flags WriteGroupChars, ThousandsGroupChar and LeadingGroupCharReplacement
in field Flags of given nf.
The minimum width of the output is taken from field DecMinimumFieldWidth unless overwritten by parameter minWidth. If the minimum width is greater than the sum of digits and* grouping characters needed to write value, then '0'
digits are prepended between the sign and the number.
- Attention
- The function does not (and cannot) check an overflow of the given character buffer when writing.
- See also
- Function WriteDecSigned to write signed decimals.
- Template Parameters
-
TChar | The character type of the string to write into. |
- Parameters
-
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
minWidth | The minimum width of the output. If 0 , the value of DecMinimumFieldWidth of argument nf is used. |
nf | Number format definitions. |
- Returns
- The index pointing to behind the last character written in buffer.
template<typename TChar >
Writes a string representation of the given double
value.
Grouping characters are written according the settings of flags alib::strings;NumberFormatFlags;;WriteGroupChars "strings;NumberFormatFlags;;WriteGroupChars", alib::strings;NumberFormatFlags;;ThousandsGroupChar "strings;NumberFormatFlags;;ThousandsGroupChar" and alib::strings;NumberFormatFlags;;LeadingGroupCharReplacement "strings;NumberFormatFlags;;LeadingGroupCharReplacement"
of field Flags in given nf.
The minimum width of the integral part of the output is taken from field IntegralPartMinimumWidth unless overwritten by parameter minWidth. If the width is greater than integral digits found in value, '0'
digits are prepended. The width is taking group characters into account.
If field FractionalPartWidth as well as the width of the integral part (provided or set) equals -1
the function may choose scientific notation. This is done for numbers smaller than 10E-4
or larger than 10E+6
.
If the given value is not a number, NANLiteral is written. If infinite, INFLiteral.
The output format is dependent on various further settings provided in field Flags of given nf. Those are DecimalPointChar, ExponentSeparator, ForceDecimalPoint, WriteExponentPlusSign and ForceScientific.
- Attention
- The function does not (and cannot) check an overflow of the given character buffer when writing.
- Template Parameters
-
TChar | The character type of the string to write into. |
- Parameters
-
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
minWidth | The minimum width of the integral part of the output. If 0 , the value of IntegralPartMinimumWidth of argument nf is used. |
nf | Number format definitions. |
- Returns
- The index pointing to behind the last character written in buffer.
template<typename TChar >
Converts the given long value to a string representation in hexadecimal format.
The maximum number of digits written is 16. In addition, grouping characters may be written according the settings of flags WriteGroupChars, HexByteGroupChar, HexWordGroupChar, HexWord32GroupChar and LeadingGroupCharReplacement
in field Flags of given nf.
The minimum width of the output is taken from field HexFieldWidth unless overwritten by parameter minWidth. If the width is greater than digits found in value, '0'
digits are prepended. The width is taking group characters into account.
- Attention
- The function does not (and cannot) check an overflow of the given character buffer when writing.
-
If the value is greater than can be represented by the output width, these greater digits are cut. This is true for this function as well as WriteBin and writeOct. The rationale behind this is that this way, larger numbers do not need to be masked before writing. (In other words: it is assumed that there is a reason for providing the width).
- Note
- The literal prefix found in field HexLiteralPrefix of nf is not written. The field is only used for detecting formats with function ParseInt.
- Template Parameters
-
TChar | The character type of the string to write into. |
- Parameters
-
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
minWidth | The minimum width of the output. If 0 , the value of HexFieldWidth of argument nf is used. |
nf | Number format definitions. |
- Returns
- The index pointing to behind the last character written in buffer.
template<typename TChar >
Converts the given long value to a string representation in octal format.
The maximum number of digits written is 64. In addition, grouping characters may be written according the settings of flags WriteGroupChars, OctGroupChar and LeadingGroupCharReplacement.
in field* Flags of given nf.
The minimum width of the output is taken from field OctFieldWidth unless overwritten by parameter minWidth. If the width is greater than digits found in value, '0'
digits are prepended. The width is taking group characters into account.
- Attention
- The function does not (and cannot) check an overflow of the given character buffer when writing.
-
If the value is greater than can be represented by the output width, these greater digits are cut. This is true for this function as well as WriteBin and writeHex. The rationale behind this is that this way, larger numbers do not need to be masked before writing. (In other words: it is assumed that there is a reason for providing the width).
- Note
- The literal prefix found in field OctLiteralPrefix of nf is not written. The field is only used for detecting formats with function ParseInt.
- Template Parameters
-
TChar | The character type of the string to write into. |
- Parameters
-
value | The value to write. |
buffer | The character array to write the value to. Needs to be long enough (after idx) to carry the string written. |
idx | The index within buffer to start writing. |
minWidth | The minimum width of the output. If 0 , the value of OctFieldWidth of argument nf is used. |
nf | Number format definitions. |
- Returns
- The index pointing to behind the last character written in buffer.