dpp::etf_parser
etf.h
uint8_t * uint8_t* dpp::etf_parser::data data dpp::etf_parser::data

Pointer to binary ETF data to be decoded.

size_t size_t dpp::etf_parser::offset offset dpp::etf_parser::offset

Current offset into binary data.

size_t size_t dpp::etf_parser::size size dpp::etf_parser::size

Current size of binary data.

void void dpp::etf_parser::append_atom (etf_buffer *b, const char *bytes, size_t size) append_atom dpp::etf_parser::append_atom etf_buffer * b const char * bytes size_t size

Append atom value to ETF buffer.

b

buffer to append to

bytes

pointer to string to append

size

size of string to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_atom_utf8 (etf_buffer *b, const char *bytes, size_t size) append_atom_utf8 dpp::etf_parser::append_atom_utf8 etf_buffer * b const char * bytes size_t size

Append utf8 atom value to ETF buffer.

b

buffer to append to

bytes

pointer to string to append

size

size of string to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_binary (etf_buffer *b, const char *bytes, size_t size) append_binary dpp::etf_parser::append_binary etf_buffer * b const char * bytes size_t size

Append binary value to ETF buffer.

b

buffer to append to

bytes

pointer to string to append

size

size of string to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_double (etf_buffer *b, double f) append_double dpp::etf_parser::append_double etf_buffer * b double f

Append double value to ETF buffer.

b

buffer to append to

f

double to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_false (etf_buffer *b) append_false dpp::etf_parser::append_false etf_buffer * b

Append false value to ETF buffer.

b

buffer to append to

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_integer (etf_buffer *b, int32_t d) append_integer dpp::etf_parser::append_integer etf_buffer * b int32_t d

Append integer value to ETF buffer.

b

buffer to append to

d

integer to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_list_header (etf_buffer *b, size_t size) append_list_header dpp::etf_parser::append_list_header etf_buffer * b size_t size

Append a list header value to ETF buffer.

b

buffer to append to

size

size of values to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_long_long (etf_buffer *b, long long d) append_long_long dpp::etf_parser::append_long_long etf_buffer * b long long d

Append 64 bit integer value to ETF buffer.

b

buffer to append to

d

integer to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_map_header (etf_buffer *b, size_t size) append_map_header dpp::etf_parser::append_map_header etf_buffer * b size_t size

Append a map header value to ETF buffer.

b

buffer to append to

size

size of values to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_nil (etf_buffer *b) append_nil dpp::etf_parser::append_nil etf_buffer * b

Append nil value to ETF buffer.

b

buffer to append to

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_nil_ext (etf_buffer *b) append_nil_ext dpp::etf_parser::append_nil_ext etf_buffer * b

Append list terminator to ETF buffer.

b

buffer to append to

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_small_integer (etf_buffer *b, unsigned char d) append_small_integer dpp::etf_parser::append_small_integer etf_buffer * b unsigned char d

Append small integer value to ETF buffer.

b

buffer to append to

d

double to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_string (etf_buffer *b, const char *bytes, size_t size) append_string dpp::etf_parser::append_string etf_buffer * b const char * bytes size_t size

Append string value to ETF buffer.

b

buffer to append to

bytes

pointer to string to append

size

size of string to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_true (etf_buffer *b) append_true dpp::etf_parser::append_true etf_buffer * b

Append true value to ETF buffer.

b

buffer to append to

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_tuple_header (etf_buffer *b, size_t size) append_tuple_header dpp::etf_parser::append_tuple_header etf_buffer * b size_t size

Append tuple value to ETF buffer.

b

buffer to append to

size

size of value to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_unsigned_long_long (etf_buffer *b, unsigned long long d) append_unsigned_long_long dpp::etf_parser::append_unsigned_long_long etf_buffer * b unsigned long long d

Append 64 bit integer value to ETF buffer.

b

buffer to append to

d

integer to append

std::exception

Buffer cannot be extended

void void dpp::etf_parser::append_version (etf_buffer *b) append_version dpp::etf_parser::append_version etf_buffer * b

Append version number to ETF buffer.

b

buffer to append to

std::exception

Buffer cannot be extended

void void dpp::etf_parser::buffer_write (etf_buffer *pk, const char *bytes, size_t l) buffer_write dpp::etf_parser::buffer_write etf_buffer * pk const char * bytes size_t l

Write to output buffer for creation of ETF from JSON.

pk

buffer struct

bytes

byte buffer to write

l

number of bytes to write

std::exception

Buffer cannot be extended

nlohmann::json nlohmann::json dpp::etf_parser::decode_array (uint32_t length) decode_array dpp::etf_parser::decode_array uint32_t length

Decode an array of values.

nlohmann::json values converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_atom () decode_atom dpp::etf_parser::decode_atom

Decode an 'atom' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_bigint (uint32_t digits) decode_bigint dpp::etf_parser::decode_bigint uint32_t digits

Decode a 'bigint' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_bigint_large () decode_bigint_large dpp::etf_parser::decode_bigint_large

Decode a large 'bigint' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_bigint_small () decode_bigint_small dpp::etf_parser::decode_bigint_small

Decode a small 'bigint' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_binary () decode_binary dpp::etf_parser::decode_binary

Decode a binary value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_compressed () decode_compressed dpp::etf_parser::decode_compressed

Decode a compressed value. This is a zlib-compressed binary blob which contains another ETF object.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_export () decode_export dpp::etf_parser::decode_export

Decode an 'export' value. Erlang expects this to be supported, in practice Discord doesn't send these right now.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_float () decode_float dpp::etf_parser::decode_float

Decode a floating point numeric value. (depreciated in erlang but still expected to be supported).

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_integer () decode_integer dpp::etf_parser::decode_integer

Decode an integer value (-MAXINT -> MAXINT-1).

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_list () decode_list dpp::etf_parser::decode_list

Decode a list of values.

nlohmann::json values converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_map () decode_map dpp::etf_parser::decode_map

Decode a map (object) value. Will recurse to evaluate each member variable.

nlohmann::json values converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_new_float () decode_new_float dpp::etf_parser::decode_new_float

Decode a floating type numeric value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_new_reference () decode_new_reference dpp::etf_parser::decode_new_reference

Decode a 'new reference' value. Erlang expects this to be supported, in practice Discord doesn't send these right now.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_nil () decode_nil dpp::etf_parser::decode_nil

Decode a nil 'atom' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_pid () decode_pid dpp::etf_parser::decode_pid

Decode a 'PID' value. Erlang expects this to be supported, in practice Discord doesn't send these right now.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_port () decode_port dpp::etf_parser::decode_port

Decode a 'port' value. Erlang expects this to be supported, in practice Discord doesn't send these right now.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_reference () decode_reference dpp::etf_parser::decode_reference

Decode a 'reference' value. Erlang expects this to be supported, in practice Discord doesn't send these right now.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_small_atom () decode_small_atom dpp::etf_parser::decode_small_atom

Decode a small 'atom' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_small_integer () decode_small_integer dpp::etf_parser::decode_small_integer

Decode a small integer value (0-255).

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_string () decode_string dpp::etf_parser::decode_string

Decode a string value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_string_as_list () decode_string_as_list dpp::etf_parser::decode_string_as_list

Decode a string list value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_tuple (uint32_t length) decode_tuple dpp::etf_parser::decode_tuple uint32_t length

Decode a 'tuple' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_tuple_large () decode_tuple_large dpp::etf_parser::decode_tuple_large

Decode a 'large tuple' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

nlohmann::json nlohmann::json dpp::etf_parser::decode_tuple_small () decode_tuple_small dpp::etf_parser::decode_tuple_small

Decode a 'small tuple' value.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

void void dpp::etf_parser::inner_build (const nlohmann::json *j, etf_buffer *b) inner_build dpp::etf_parser::inner_build const nlohmann::json * j etf_buffer * b

Build ETF buffer.

j

JSON object to build from

b

Buffer to append to

std::exception

Buffer cannot be extended

nlohmann::json nlohmann::json dpp::etf_parser::inner_parse () inner_parse dpp::etf_parser::inner_parse

Parse a single value, and if that value contains other values (e.g. an array or map) then call itself recursively.

nlohmann::json JSON value from the ETF

nlohmann::json nlohmann::json dpp::etf_parser::process_atom (const char *atom, uint16_t length) process_atom dpp::etf_parser::process_atom const char * atom uint16_t length

Process an 'atom' value. An atom is a "label" or constant value within the data, such as a key name, nullptr, or false.

nlohmann::json value converted to JSON

dpp::exception

Data stream isn't long enough to fetch requested bits

uint16_t uint16_t dpp::etf_parser::read_16_bits () read_16_bits dpp::etf_parser::read_16_bits

Read 16 bits of data from the buffer.

uint16_t data retrieved

dpp::exception

Data stream isn't long enough to fetch requested bits

uint32_t uint32_t dpp::etf_parser::read_32_bits () read_32_bits dpp::etf_parser::read_32_bits

Read 32 bits of data from the buffer.

uint32_t data retrieved

dpp::exception

Data stream isn't long enough to fetch requested bits

uint64_t uint64_t dpp::etf_parser::read_64_bits () read_64_bits dpp::etf_parser::read_64_bits

Read 64 bits of data from the buffer.

uint64_t data retrieved

dpp::exception

Data stream isn't long enough to fetch requested bits

uint8_t uint8_t dpp::etf_parser::read_8_bits () read_8_bits dpp::etf_parser::read_8_bits

Read 8 bits of data from the buffer.

uint8_t data retrieved

dpp::exception

Data stream isn't long enough to fetch requested bits

const char * const char * dpp::etf_parser::read_string (uint32_t length) read_string dpp::etf_parser::read_string uint32_t length

Read string data from the buffer.

length

Length of string to retrieve

const char* data retrieved

dpp::exception

Data stream isn't long enough to fetch requested bits

dpp::etf_parser::etf_parser
()
etf_parser
dpp::etf_parser::etf_parser

Construct a new etf parser object.

dpp::etf_parser::~etf_parser
()
~etf_parser
dpp::etf_parser::~etf_parser

Destroy the etf parser object.

nlohmann::json nlohmann::json dpp::etf_parser::parse (const std::string &in) parse dpp::etf_parser::parse const std::string & in

Convert ETF binary content to nlohmann::json.

in

Raw binary ETF data (generally from a websocket)

nlohmann::json JSON data for use in the library

dpp::exception

Malformed or otherwise invalid ETF content

The etf_parser class can serialise and deserialise ETF (Erlang Term Format) into and out of an nlohmann::json object, so that layers above the websocket don't have to be any different for handling ETF.

- dpp::etf_parser
  append_atom
- dpp::etf_parser
  append_atom_utf8
- dpp::etf_parser
  append_binary
- dpp::etf_parser
  append_double
- dpp::etf_parser
  append_false
- dpp::etf_parser
  append_integer
- dpp::etf_parser
  append_list_header
- dpp::etf_parser
  append_long_long
- dpp::etf_parser
  append_map_header
- dpp::etf_parser
  append_nil
- dpp::etf_parser
  append_nil_ext
- dpp::etf_parser
  append_small_integer
- dpp::etf_parser
  append_string
- dpp::etf_parser
  append_true
- dpp::etf_parser
  append_tuple_header
- dpp::etf_parser
  append_unsigned_long_long
- dpp::etf_parser
  append_version
- dpp::etf_parser
  buffer_write
- dpp::etf_parser
  data
- dpp::etf_parser
  decode_array
- dpp::etf_parser
  decode_atom
- dpp::etf_parser
  decode_bigint
- dpp::etf_parser
  decode_bigint_large
- dpp::etf_parser
  decode_bigint_small
- dpp::etf_parser
  decode_binary
- dpp::etf_parser
  decode_compressed
- dpp::etf_parser
  decode_export
- dpp::etf_parser
  decode_float
- dpp::etf_parser
  decode_integer
- dpp::etf_parser
  decode_list
- dpp::etf_parser
  decode_map
- dpp::etf_parser
  decode_new_float
- dpp::etf_parser
  decode_new_reference
- dpp::etf_parser
  decode_nil
- dpp::etf_parser
  decode_pid
- dpp::etf_parser
  decode_port
- dpp::etf_parser
  decode_reference
- dpp::etf_parser
  decode_small_atom
- dpp::etf_parser
  decode_small_integer
- dpp::etf_parser
  decode_string
- dpp::etf_parser
  decode_string_as_list
- dpp::etf_parser
  decode_tuple
- dpp::etf_parser
  decode_tuple_large
- dpp::etf_parser
  decode_tuple_small
- dpp::etf_parser
  etf_parser
- dpp::etf_parser
  inner_build
- dpp::etf_parser
  inner_parse
- dpp::etf_parser
  offset
- dpp::etf_parser
  parse
- dpp::etf_parser
  process_atom
- dpp::etf_parser
  read_16_bits
- dpp::etf_parser
  read_32_bits
- dpp::etf_parser
  read_64_bits
- dpp::etf_parser
  read_8_bits
- dpp::etf_parser
  read_string
- dpp::etf_parser
  size
- dpp::etf_parser
  ~etf_parser