v0.4.0

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 throws ParseError
pub func ParseUint8(str: StringView) -> uint8 throws 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 throws ParseErrorParses a uint8: an optional +, an optional base prefix, and digits.
pub func ParseUint8(str: StringView) -> uint8 throws 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 throws ParseError
pub func ParseInt8(str: StringView) -> int8 throws 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 throws ParseErrorParses an int8: an optional sign, an optional base prefix, and digits.
pub func ParseInt8(str: StringView) -> int8 throws 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 throws ParseError
pub func ParseUint16(str: StringView) -> uint16 throws 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 throws ParseErrorParses a uint16: an optional +, an optional base prefix, and digits.
pub func ParseUint16(str: StringView) -> uint16 throws 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 throws ParseError
pub func ParseInt16(str: StringView) -> int16 throws 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 throws ParseErrorParses an int16: an optional sign, an optional base prefix, and digits.
pub func ParseInt16(str: StringView) -> int16 throws 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 throws ParseError
pub func ParseUint32(str: StringView) -> uint32 throws 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 throws ParseErrorParses a uint32: an optional +, an optional base prefix, and digits.
pub func ParseUint32(str: StringView) -> uint32 throws 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 throws ParseError
pub func ParseInt32(str: StringView) -> int32 throws 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 throws ParseErrorParses an int32: an optional sign, an optional base prefix, and digits.
pub func ParseInt32(str: StringView) -> int32 throws 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 throws ParseError
pub func ParseUint64(str: StringView) -> uint64 throws 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 throws ParseErrorParses a uint64: an optional +, an optional base prefix, and digits.
pub func ParseUint64(str: StringView) -> uint64 throws 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 throws ParseError
pub func ParseInt64(str: StringView) -> int64 throws 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 throws ParseErrorParses an int64: an optional sign, an optional base prefix, and digits.
pub func ParseInt64(str: StringView) -> int64 throws 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 throws ParseError
pub func ParseUint128(str: StringView) -> uint128 throws 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 throws ParseErrorParses a uint128: an optional +, an optional base prefix, and digits.
pub func ParseUint128(str: StringView) -> uint128 throws 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 throws ParseError
pub func ParseInt128(str: StringView) -> int128 throws 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 throws ParseErrorParses an int128: an optional sign, an optional base prefix, and digits.
pub func ParseInt128(str: StringView) -> int128 throws 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 throws ParseError
pub func ParseUint256(str: StringView) -> uint256 throws 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 throws ParseErrorParses a uint256: an optional +, an optional base prefix, and digits.
pub func ParseUint256(str: StringView) -> uint256 throws 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 throws ParseError
pub func ParseInt256(str: StringView) -> int256 throws 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 throws ParseErrorParses an int256: an optional sign, an optional base prefix, and digits.
pub func ParseInt256(str: StringView) -> int256 throws 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 throws ParseError
pub func ParseUint512(str: StringView) -> uint512 throws 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 throws ParseErrorParses a uint512: an optional +, an optional base prefix, and digits.
pub func ParseUint512(str: StringView) -> uint512 throws 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 throws ParseError
pub func ParseInt512(str: StringView) -> int512 throws 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 throws ParseErrorParses an int512: an optional sign, an optional base prefix, and digits.
pub func ParseInt512(str: StringView) -> int512 throws 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 throws ParseError
pub func ParseBool(str: StringView) -> bool throws 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 throws ParseErrorParses true or false, exactly.
pub func ParseBool(str: StringView) -> bool throws 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 throws ParseError
pub func ParseChar(str: StringView) -> char32 throws 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 throws ParseErrorParses exactly one character.
pub func ParseChar(str: StringView) -> char32 throws 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