Parsing integers, booleans and characters v0.1.0

Source
Reading an integer of any width and base, a boolean or one character from text.

ParseUint8

pub func ParseUint8(str: char8[..]) -> uint8 ! ParseError
pub func ParseUint8(str: StringView) -> uint8 ! ParseError

Parses a uint8: an optional +, an optional base prefix, and digits. Reports Overflow for a value the width cannot hold, InvalidCharacter at the first byte that is not part of the grammar — a - included, since no unsigned value is negative.

OverloadSummary
pub func ParseUint8(str: char8[..]) -> uint8 ! ParseErrorParses a uint8: an optional +, an optional base prefix, and digits.
pub func ParseUint8(str: StringView) -> uint8 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseInt8

pub func ParseInt8(str: char8[..]) -> int8 ! ParseError
pub func ParseInt8(str: StringView) -> int8 ! ParseError

Parses an int8: an optional sign, an optional base prefix, and digits. The negative bound is one larger than the positive one, because the most negative value has no positive counterpart: the value one past the largest positive fits only with its sign.

OverloadSummary
pub func ParseInt8(str: char8[..]) -> int8 ! ParseErrorParses an int8: an optional sign, an optional base prefix, and digits.
pub func ParseInt8(str: StringView) -> int8 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseUint16

pub func ParseUint16(str: char8[..]) -> uint16 ! ParseError
pub func ParseUint16(str: StringView) -> uint16 ! ParseError

Parses a uint16: an optional +, an optional base prefix, and digits. Reports Overflow for a value the width cannot hold, InvalidCharacter at the first byte that is not part of the grammar — a - included, since no unsigned value is negative.

OverloadSummary
pub func ParseUint16(str: char8[..]) -> uint16 ! ParseErrorParses a uint16: an optional +, an optional base prefix, and digits.
pub func ParseUint16(str: StringView) -> uint16 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseInt16

pub func ParseInt16(str: char8[..]) -> int16 ! ParseError
pub func ParseInt16(str: StringView) -> int16 ! ParseError

Parses an int16: an optional sign, an optional base prefix, and digits. The negative bound is one larger than the positive one, because the most negative value has no positive counterpart: the value one past the largest positive fits only with its sign.

OverloadSummary
pub func ParseInt16(str: char8[..]) -> int16 ! ParseErrorParses an int16: an optional sign, an optional base prefix, and digits.
pub func ParseInt16(str: StringView) -> int16 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseUint32

pub func ParseUint32(str: char8[..]) -> uint32 ! ParseError
pub func ParseUint32(str: StringView) -> uint32 ! ParseError

Parses a uint32: an optional +, an optional base prefix, and digits. Reports Overflow for a value the width cannot hold, InvalidCharacter at the first byte that is not part of the grammar — a - included, since no unsigned value is negative.

OverloadSummary
pub func ParseUint32(str: char8[..]) -> uint32 ! ParseErrorParses a uint32: an optional +, an optional base prefix, and digits.
pub func ParseUint32(str: StringView) -> uint32 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseInt32

pub func ParseInt32(str: char8[..]) -> int32 ! ParseError
pub func ParseInt32(str: StringView) -> int32 ! ParseError

Parses an int32: an optional sign, an optional base prefix, and digits. The negative bound is one larger than the positive one, because the most negative value has no positive counterpart: the value one past the largest positive fits only with its sign.

OverloadSummary
pub func ParseInt32(str: char8[..]) -> int32 ! ParseErrorParses an int32: an optional sign, an optional base prefix, and digits.
pub func ParseInt32(str: StringView) -> int32 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseUint64

pub func ParseUint64(str: char8[..]) -> uint64 ! ParseError
pub func ParseUint64(str: StringView) -> uint64 ! ParseError

Parses a uint64: an optional +, an optional base prefix, and digits. Reports Overflow for a value the width cannot hold, InvalidCharacter at the first byte that is not part of the grammar — a - included, since no unsigned value is negative.

OverloadSummary
pub func ParseUint64(str: char8[..]) -> uint64 ! ParseErrorParses a uint64: an optional +, an optional base prefix, and digits.
pub func ParseUint64(str: StringView) -> uint64 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseInt64

pub func ParseInt64(str: char8[..]) -> int64 ! ParseError
pub func ParseInt64(str: StringView) -> int64 ! ParseError

Parses an int64: an optional sign, an optional base prefix, and digits. The negative bound is one larger than the positive one, because the most negative value has no positive counterpart: the value one past the largest positive fits only with its sign.

OverloadSummary
pub func ParseInt64(str: char8[..]) -> int64 ! ParseErrorParses an int64: an optional sign, an optional base prefix, and digits.
pub func ParseInt64(str: StringView) -> int64 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseUint128

pub func ParseUint128(str: char8[..]) -> uint128 ! ParseError
pub func ParseUint128(str: StringView) -> uint128 ! ParseError

Parses a uint128: an optional +, an optional base prefix, and digits. Reports Overflow for a value the width cannot hold, InvalidCharacter at the first byte that is not part of the grammar — a - included, since no unsigned value is negative.

OverloadSummary
pub func ParseUint128(str: char8[..]) -> uint128 ! ParseErrorParses a uint128: an optional +, an optional base prefix, and digits.
pub func ParseUint128(str: StringView) -> uint128 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseInt128

pub func ParseInt128(str: char8[..]) -> int128 ! ParseError
pub func ParseInt128(str: StringView) -> int128 ! ParseError

Parses an int128: an optional sign, an optional base prefix, and digits. The negative bound is one larger than the positive one, because the most negative value has no positive counterpart: the value one past the largest positive fits only with its sign.

OverloadSummary
pub func ParseInt128(str: char8[..]) -> int128 ! ParseErrorParses an int128: an optional sign, an optional base prefix, and digits.
pub func ParseInt128(str: StringView) -> int128 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseUint256

pub func ParseUint256(str: char8[..]) -> uint256 ! ParseError
pub func ParseUint256(str: StringView) -> uint256 ! ParseError

Parses a uint256: an optional +, an optional base prefix, and digits. Reports Overflow for a value the width cannot hold, InvalidCharacter at the first byte that is not part of the grammar — a - included, since no unsigned value is negative.

OverloadSummary
pub func ParseUint256(str: char8[..]) -> uint256 ! ParseErrorParses a uint256: an optional +, an optional base prefix, and digits.
pub func ParseUint256(str: StringView) -> uint256 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseInt256

pub func ParseInt256(str: char8[..]) -> int256 ! ParseError
pub func ParseInt256(str: StringView) -> int256 ! ParseError

Parses an int256: an optional sign, an optional base prefix, and digits. The negative bound is one larger than the positive one, because the most negative value has no positive counterpart: the value one past the largest positive fits only with its sign.

OverloadSummary
pub func ParseInt256(str: char8[..]) -> int256 ! ParseErrorParses an int256: an optional sign, an optional base prefix, and digits.
pub func ParseInt256(str: StringView) -> int256 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseUint512

pub func ParseUint512(str: char8[..]) -> uint512 ! ParseError
pub func ParseUint512(str: StringView) -> uint512 ! ParseError

Parses a uint512: an optional +, an optional base prefix, and digits. Reports Overflow for a value the width cannot hold, InvalidCharacter at the first byte that is not part of the grammar — a - included, since no unsigned value is negative.

OverloadSummary
pub func ParseUint512(str: char8[..]) -> uint512 ! ParseErrorParses a uint512: an optional +, an optional base prefix, and digits.
pub func ParseUint512(str: StringView) -> uint512 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseInt512

pub func ParseInt512(str: char8[..]) -> int512 ! ParseError
pub func ParseInt512(str: StringView) -> int512 ! ParseError

Parses an int512: an optional sign, an optional base prefix, and digits. The negative bound is one larger than the positive one, because the most negative value has no positive counterpart: the value one past the largest positive fits only with its sign.

OverloadSummary
pub func ParseInt512(str: char8[..]) -> int512 ! ParseErrorParses an int512: an optional sign, an optional base prefix, and digits.
pub func ParseInt512(str: StringView) -> int512 ! ParseErrorThe same grammar for a view, which is what a caller holding text has.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseBool

pub func ParseBool(str: char8[..]) -> bool ! ParseError
pub func ParseBool(str: StringView) -> bool ! ParseError

Parses true or false, exactly. Reports Empty for no bytes and InvalidCharacter at the start for anything else, including a correct word with trailing bytes.

OverloadSummary
pub func ParseBool(str: char8[..]) -> bool ! ParseErrorParses true or false, exactly.
pub func ParseBool(str: StringView) -> bool ! ParseErrorThe same words for a view.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at

ParseChar

pub func ParseChar(str: char8[..]) -> char32 ! ParseError
pub func ParseChar(str: StringView) -> char32 ! ParseError

Parses exactly one character. Reports Empty for no bytes, and InvalidCharacter for bytes that are not one whole scalar value — ill-formed UTF-8 at zero, a second character at its own index.

OverloadSummary
pub func ParseChar(str: char8[..]) -> char32 ! ParseErrorParses exactly one character.
pub func ParseChar(str: StringView) -> char32 ! ParseErrorThe same single character for a view.

Source

Parameters

NameTypeDescription
strchar8[..] / StringViewthe text to parse

Returns: the value, or the failure and the byte offset it was found at