BloombergLP::bdlb::NumericParseUtil::parseInt64

Parse a 64-bit signed integer from the leading characters of a string.

Synopsis

Declared in <bdlb_numericparseutil.h>

static
int
parseInt64(
    bsls::Types::Int64* result,
    std::string_view const& inputString,
    int base = 10);

Description

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]).

A parse failure can occur for the following reasons: 1. The inputString is empty. 2. The first character of inputString is not a valid digit in base, or an optional sign followed by a valid digit.

Return Value

0 on success, and a non-zero value otherwise

Parameters

NameDescription
resultlocation to store the parsed value
inputStringtext to parse
basenumeric base in [2 .. 36] (default 10)