Venom.Parser (venom v0.1.0)

This module largely contains functions designed for internal use. You're probably better off using the functions defined in Venom, unless you need to perform some specific NBT parsing yourself.

Summary

Functions

Parse a byte (8 bits) from a binary, returning any remaining data.

Parse an i32-length-prefixed array of bytes from a binary, returning any remaining data.

Parse a double (64 bits) from a binary, returning any remaining data.

Parse a float (32 bits) from a binary, returning any remaining data.

Parse an int (32 bits) from a binary, returning any remaining data.

Parse an i32-length-prefixed array of 32-bit signed ints from a binary, returning any remaining data.

Parse a long (64 bits) from a binary, returning any remaining data.

Parse an i32-length-prefixed array of 64-bit signed longs from a binary, returning any remaining data.

Entry-point for parsing a full NBT tag. Ensures a single-keyed compound.

Parse a short (16 bits) from a binary, returning any remaining data.

Parse a string from a binary, returning any remaining data.

Parse a tag type from a binary, returning any remaining data.

Functions

Link to this function

parse_byte!(data)

Parse a byte (8 bits) from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_byte!(<<5, 0xAA, 0xBB>>)
{5, <<0xAA, 0xBB>>}
Link to this function

parse_byte_array!(data)

Parse an i32-length-prefixed array of bytes from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_byte_array!(<<0, 0, 0, 4, 1, 2, 3, 4, 0xAA, 0xBB>>)
{[1, 2, 3, 4], <<0xAA, 0xBB>>}
Link to this function

parse_double!(data)

Parse a double (64 bits) from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_double!(<<25, 25, 25, 25, 25, 25, 25, 25, 0xAA, 0xBB>>)
{9.01285756841504e-188, <<0xAA, 0xBB>>}
Link to this function

parse_float!(data)

Parse a float (32 bits) from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_float!(<<25, 25, 25, 25, 0xAA, 0xBB>>)
{7.914983038854372e-24, <<0xAA, 0xBB>>}
Link to this function

parse_int!(data)

Parse an int (32 bits) from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_int!(<<0, 0, 0, 5, 0xAA, 0xBB>>)
{5, <<0xAA, 0xBB>>}
Link to this function

parse_int_array!(data)

Parse an i32-length-prefixed array of 32-bit signed ints from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_int_array!(<<0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 2, 0xAA, 0xBB>>)
{[1, 2], <<0xAA, 0xBB>>}
Link to this function

parse_list!(data)

Link to this function

parse_long!(data)

Parse a long (64 bits) from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_long!(<<0, 0, 0, 0, 0, 0, 0, 5, 0xAA, 0xBB>>)
{5, <<0xAA, 0xBB>>}
Link to this function

parse_long_array!(data)

Parse an i32-length-prefixed array of 64-bit signed longs from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_long_array!(<<0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0xAA, 0xBB>>)
{[1, 2], <<0xAA, 0xBB>>}
Link to this function

parse_root!(data)

Entry-point for parsing a full NBT tag. Ensures a single-keyed compound.

Link to this function

parse_short!(data)

Parse a short (16 bits) from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_short!(<<0, 5, 0xAA, 0xBB>>)
{5, <<0xAA, 0xBB>>}
Link to this function

parse_string!(data)

Parse a string from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_string!(<<0, 5, "abcde", 0xAA, 0xBB>>)
{"abcde", <<0xAA, 0xBB>>}
Link to this function

parse_tag_type!(data)

Parse a tag type from a binary, returning any remaining data.

Examples

iex> Venom.Parser.parse_tag_type!(<<5, 0xAA, 0xBB>>)
{5, <<0xAA, 0xBB>>}