combine v0.10.0 Combine.Parsers.Binary View Source
This module defines common raw binary parsers, i.e. bits, bytes, uint, etc.
To use them, just add import Combine.Parsers.Binary
to your module, or
reference them directly.
All of these parsers operate on, and return bitstrings as their results.
Link to this section Summary
Functions
This parser parses N bits from the input
This parser parses N bytes from the input
This parser parses a n-bit floating point number from the input
This parser parses a signed, n-bit integer from the input with the given endianness
This parser parses an unsigned, n-bit integer from the input with the given endianness
Link to this section Types
Link to this section Functions
bits(previous_parser, pos_integer) :: parser
This parser parses N bits from the input.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse("Hi", bits(8))
["H"]
...> Combine.parse("Hi", bits(8) |> bits(8))
["H", "i"]
bytes(previous_parser, pos_integer) :: parser
This parser parses N bytes from the input.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse("Hi", bytes(1))
["H"]
...> Combine.parse("Hi", bytes(1) |> bytes(1))
["H", "i"]
float(previous_parser, 32 | 64) :: parser
This parser parses a n-bit floating point number from the input.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse(<<2.50::float-size(32)>>, float(32))
[2.5]
int(previous_parser, pos_integer, :be | :le) :: parser
This parser parses a signed, n-bit integer from the input with the given endianness.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse(<<-85::big-signed-size(16),"-90"::binary>>, int(16, :be))
[-85]
uint(previous_parser, pos_integer, :be | :le) :: parser
This parser parses an unsigned, n-bit integer from the input with the given endianness.
Example
iex> import Elixir.Combine.Parsers.Binary
...> Combine.parse(<<85::big-unsigned-size(16), "-90"::binary>>, uint(16, :be))
[85]