|
static int | characterToDigit (char character, int base) |
|
static int | parseDouble (double *result, const bsl::string_view &inputString) |
|
static int | parseDouble (double *result, bsl::string_view *remainder, const bsl::string_view &inputString) |
|
static int | parseInt (int *result, const bsl::string_view &inputString, int base=10) |
|
static int | parseInt (int *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base=10) |
|
static int | parseInt64 (bsls::Types::Int64 *result, const bsl::string_view &inputString, int base=10) |
|
static int | parseInt64 (bsls::Types::Int64 *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base=10) |
|
static int | parseShort (short *result, const bsl::string_view &inputString, int base=10) |
|
static int | parseShort (short *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base=10) |
|
static int | parseUint (unsigned int *result, const bsl::string_view &inputString, int base=10) |
|
static int | parseUint (unsigned int *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base=10) |
|
static int | parseUint64 (bsls::Types::Uint64 *result, const bsl::string_view &inputString, int base=10) |
|
static int | parseUint64 (bsls::Types::Uint64 *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base=10) |
|
static int | parseUshort (unsigned short *result, const bsl::string_view &inputString, int base=10) |
|
static int | parseUshort (unsigned short *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base=10) |
|
static int | parseSignedInteger (bsls::Types::Int64 *result, const bsl::string_view &inputString, int base, const bsls::Types::Int64 minValue, const bsls::Types::Int64 maxValue) |
|
static int | parseSignedInteger (bsls::Types::Int64 *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base, const bsls::Types::Int64 minValue, const bsls::Types::Int64 maxValue) |
|
static int | parseUnsignedInteger (bsls::Types::Uint64 *result, const bsl::string_view &inputString, int base, const bsls::Types::Uint64 maxValue) |
|
static int | parseUnsignedInteger (bsls::Types::Uint64 *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base, const bsls::Types::Uint64 maxValue) |
|
static int | parseUnsignedInteger (bsls::Types::Uint64 *result, const bsl::string_view &inputString, int base, const bsls::Types::Uint64 maxValue, int maxNumDigits) |
|
static int | parseUnsignedInteger (bsls::Types::Uint64 *result, bsl::string_view *remainder, const bsl::string_view &inputString, int base, const bsls::Types::Uint64 maxValue, int maxNumDigits) |
|
This struct
provides a namespace for a suite of stateless procedures that perform parsing functionality for numbers.
Parse the specified inputString
for a sequence of characters matching the production rule <DOUBLE> (see {Grammar Production Rules}) and place into the specified result
the corresponding value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. Return zero on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs unless it is a range error (value ERANGE
from <cerrno>
). In case of ERANGE
return value result
will be set to zero on underflow and infinity in case of overflow, with the appropriate sign. The behavior is undefined unless the current numeric locale is the "C"
locale, such that strcmp(setlocale(LC_NUMERIC, 0), "C") == 0
. For more information see {Floating Point Values}.
int bdlb::NumericParseUtil::parseInt |
( |
int * |
result, |
|
|
const bsl::string_view & |
inputString, |
|
|
int |
base = 10 |
|
) |
| |
|
inlinestatic |
Parse the specified inputString
for the maximal sequence of characters forming an <INT> (see {Grammar Production Rules}) in the optionally specified base
or in base 10 if base
is not specified, and place into the specified result
the corresponding value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. If the parsed number is outside of the [INT_MIN .. INT_MAX]
range the result
will be the longest number that does not over/underflow and remainder
start at the first digit that would make the number too large/small. Return zero on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs. The behavior is undefined unless 2 <= base
and base <= 36
(i.e., bases where digits are representable by characters in the range [0
-9
], [a
-z
], or [A
-Z
]).
Parse the specified inputString
for the maximal sequence of characters forming a valid <INT64> (see {Grammar Production Rules}) in the optionally specified base
or in base 10 if base
is not specified, and place into the specified result
the corresponding value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. If the parsed number is outside of the [-0x8000000000000000uLL .. 0x7FFFFFFFFFFFFFFFull]
range the result
will be the longest number that does not over/underflow and remainder
will start at the first digit that would make the number too large/small. Return zero on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs. The behavior is undefined unless 2 <= base
and base <= 36
(i.e., bases where digits are representable by characters in the range [0
-9
], [a
-z
], or [A
-Z
]).
int bdlb::NumericParseUtil::parseShort |
( |
short * |
result, |
|
|
const bsl::string_view & |
inputString, |
|
|
int |
base = 10 |
|
) |
| |
|
inlinestatic |
Parse the specified inputString
for the maximal sequence of characters forming a valid <SHORT> (see {Grammar Production Rules}) in the optionally specified base
or in base 10 if base
is not specified, and place into the specified result
the corresponding value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. If the parsed number is outside of the [SHRT_MIN .. SHRT_MAX]
range the result
will be the longest number that does not over/underflow and remainder
will start at the first digit that would make the number too large/small. Return zero on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs. The behavior is undefined unless 2 <= base
and base <= 36
(i.e., bases where digits are representable by characters in the range [0
-9
], [a
-z
] or [A
-Z
]).
Parse the specified inputString
for an optional sign followed by a sequence of characters representing digits in the specified base
, consuming the maximum that will form a number whose value is less than or equal to the specified maxValue
and greater than or equal to the specified minValue
. Place into the specified result
the extracted value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. Return 0 on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs. The behavior is undefined unless maxValue
a positive integer, and minValue
is negative (this is required to allow for efficient implementation). The behavior is also undefined unless 2 <= base
and base <= 36
, (i.e., bases where digits are representable by characters [ 0 .. 9 ]
, [ a .. z ]
or [ A .. Z ]
).
int bdlb::NumericParseUtil::parseUint |
( |
unsigned int * |
result, |
|
|
const bsl::string_view & |
inputString, |
|
|
int |
base = 10 |
|
) |
| |
|
inlinestatic |
Parse the specified inputString
for the maximal sequence of characters forming an <UNSIGNED> (see {Grammar Production Rules}) in the optionally specified base
or in base 10 if base
is not specified, and place into the specified result
the corresponding value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. If the parsed number is outside of the [0 .. UINT_MAX]
range the result
will be the longest number that does not overflow and remainder
will start at the first digit that would make the number too large. Return zero on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs. The behavior is undefined unless 2 <= base
and base <= 36
(i.e., bases where digits are representable by characters in the range [0
-9
], [a
-z
], or [A
-Z
]).
Parse the specified inputString
for the maximal sequence of characters forming a valid <UNSIGNED64> (see {Grammar Production Rules}) in the optionally specified base
or in base 10 if base
is not specified, and place into the specified result
the corresponding value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. If the parsed number is outside of the [0 .. 0XFFFFFFFFFFFFFFFF]
range the result
will be the longest number that does not overflow and remainder
will start at the first digit that would make the number too large. Return zero on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs. The behavior is undefined unless 2 <= base
and base <= 36
(i.e., bases where digits are representable by characters in the range [0
-9
], [a
-z
], or [A
-Z
]).
Parse the specified inputString
for a sequence of characters representing digits in the specified base
, consuming the maximum up to the optionally specified maxNumDigits
that form a number whose value does not exceed the specified maxValue
. Place into the specified result
the extracted value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. Return 0 on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs. If maxNumDigits
is not specified, it defaults to a number larger than the number of possible digits in an unsigned 64-bit integer. The behavior is undefined unless 2 < = base
and base <= 36
(i.e., bases where digits are representable by characters [ 0 .. 9 ]
, [ a .. z ]
or [ A .. Z ]
).
int bdlb::NumericParseUtil::parseUshort |
( |
unsigned short * |
result, |
|
|
const bsl::string_view & |
inputString, |
|
|
int |
base = 10 |
|
) |
| |
|
inlinestatic |
Parse the specified inputString
for the maximal sequence of characters forming a valid <USHORT> (see {Grammar Production Rules}) in the optionally specified base
or in base 10 if base
is not specified, and place into the specified result
the corresponding value. Optionally specify remainder
, in which to store the remainder of the inputString
immediately following the successfully parsed text, or the position at which a parse failure was detected. If the parsed number is outside of the [0 .. USHRT_MAX]
range the result
will be the longest number that does not over/underflow and remainder
will start at the first digit that would make the number too large/small. Return zero on success, and a non-zero value otherwise. The value of result
is unchanged if a parse failure occurs. The behavior is undefined unless 2 <= base
and base <= 36
(i.e., bases where digits are representable by characters in the range [0
-9
], [a
-z
] or [A
-Z
]).