23#ifndef SOFAB_ISTREAM_H
24#define SOFAB_ISTREAM_H
35#ifndef SOFAB_ISTREAM_C
36# define SOFAB_ISTREAM_EXTERN extern
38# define SOFAB_ISTREAM_EXTERN
62#define SOFAB_ISTREAM_OPT_FIELDTYPE(type) ((type) & 0x07)
63#define SOFAB_ISTREAM_OPT_FIXLENTYPE(type) (((type) & 0x07) << 3)
64#define SOFAB_ISTREAM_OPT_STRINGTERM (0x40)
68#define SOFAB_ISTREAM_OPT_BOOLEAN (0x80)
165#if !defined(SOFAB_DISABLE_SEQUENCE_SUPPORT)
171#if SOFAB_SKIP_COUNTER
293#if SOFAB_SKIP_COUNTER
387#if !defined(SOFAB_DISABLE_INT64_SUPPORT)
433#if !defined(SOFAB_DISABLE_FIXLEN_SUPPORT)
447#if !defined(SOFAB_DISABLE_FP64_SUPPORT)
512#if !defined(SOFAB_DISABLE_ARRAY_SUPPORT)
523 sofab_istream_t *ctx,
void *var,
size_t element_count,
size_t element_size, uint8_t opt);
528#if !defined(SOFAB_DISABLE_ARRAY_SUPPORT)
631#if !defined(SOFAB_DISABLE_INT64_SUPPORT)
661#if !defined(SOFAB_DISABLE_FIXLEN_SUPPORT)
677#if !defined(SOFAB_DISABLE_FP64_SUPPORT)
698#if !defined(SOFAB_DISABLE_SEQUENCE_SUPPORT)
static void sofab_istream_read_string(sofab_istream_t *ctx, char *var, size_t varlen)
Reads a string of fixed maximum size.
static void sofab_istream_read_blob(sofab_istream_t *ctx, void *var, size_t varlen)
Reads a binary blob of fixed maximum size.
static void sofab_istream_read_array_of_i16(sofab_istream_t *ctx, int16_t *var, size_t element_count)
Reads an array of 16-bit signed integers.
static void sofab_istream_read_array_of_u64(sofab_istream_t *ctx, uint64_t *var, size_t element_count)
Reads an array of 64-bit unsigned integers.
#define SOFAB_ISTREAM_OPT_STRINGTERM
static void sofab_istream_read_u16(sofab_istream_t *ctx, uint16_t *var)
Reads a 16-bit unsigned integer.
void sofab_istream_invalidate(sofab_istream_t *ctx)
Reject the message in progress from within a field callback.
void sofab_istream_read_field(sofab_istream_t *ctx, void *var, size_t varlen, uint8_t opt)
Number of fields skipped because their wire type contradicted the destination a field callback bound.
void sofab_istream_read_sequence(sofab_istream_t *ctx, sofab_istream_decoder_t *decoder, sofab_istream_field_cb_t field_callback, void *usrptr)
Begins decoding a nested Sofab sequence.
struct sofab_istream_decoder sofab_istream_decoder_t
Decoder context used for Sofab sequences.
static void sofab_istream_read_i64(sofab_istream_t *ctx, int64_t *var)
Reads a 64-bit signed integer.
static void sofab_istream_read_fp64(sofab_istream_t *ctx, double *var)
Reads a 64-bit floating-point value.
void(* sofab_istream_field_cb_t)(sofab_istream_t *ctx, sofab_id_t id, size_t size, size_t count, void *usrptr)
Field callback invoked whenever a new field ID is decoded.
static void sofab_istream_read_u64(sofab_istream_t *ctx, uint64_t *var)
Reads a 64-bit unsigned integer.
static void sofab_istream_read_u8(sofab_istream_t *ctx, uint8_t *var)
Reads an 8-bit unsigned integer.
#define SOFAB_ISTREAM_OPT_FIELDTYPE(type)
#define SOFAB_ISTREAM_OPT_FIXLENTYPE(type)
uint32_t sofab_id_t
Field identifier type.
static void sofab_istream_read_array_of_bool(sofab_istream_t *ctx, bool *var, size_t element_count)
Reads an array of booleans.
static void sofab_istream_read_array_of_i32(sofab_istream_t *ctx, int32_t *var, size_t element_count)
Reads an array of 32-bit signed integers.
static void sofab_istream_read_array_of_i64(sofab_istream_t *ctx, int64_t *var, size_t element_count)
Reads an array of 64-bit signed integers.
uint64_t sofab_unsigned_t
Scalar varint value types.
static void sofab_istream_read_string_noterm(sofab_istream_t *ctx, char *var, size_t varlen)
Reads a string of fixed maximum size.
static void sofab_istream_read_array_of_u32(sofab_istream_t *ctx, uint32_t *var, size_t element_count)
Reads an array of 32-bit unsigned integers.
static void sofab_istream_read_fp32(sofab_istream_t *ctx, float *var)
Reads a 32-bit floating-point value.
#define SOFAB_ISTREAM_OPT_BOOLEAN
static void sofab_istream_read_bool(sofab_istream_t *ctx, bool *var)
Reads a boolean value.
static void sofab_istream_read_array_of_u16(sofab_istream_t *ctx, uint16_t *var, size_t element_count)
Reads an array of 16-bit unsigned integers.
sofab_ret_t
Return status codes.
void sofab_istream_init(sofab_istream_t *ctx, sofab_istream_field_cb_t field_callback, void *usrptr)
Initializes a Sofab input stream context.
static void sofab_istream_read_i16(sofab_istream_t *ctx, int16_t *var)
Reads a 16-bit signed integer.
static void sofab_istream_read_array_of_fp32(sofab_istream_t *ctx, float *var, size_t element_count)
Reads an array of 32-bit floating-point values.
void sofab_istream_read_array(sofab_istream_t *ctx, void *var, size_t element_count, size_t element_size, uint8_t opt)
Reads an array of elements.
static void sofab_istream_read_i32(sofab_istream_t *ctx, int32_t *var)
Reads a 32-bit signed integer.
static void sofab_istream_read_i8(sofab_istream_t *ctx, int8_t *var)
Reads an 8-bit signed integer.
static void sofab_istream_read_array_of_i8(sofab_istream_t *ctx, int8_t *var, size_t element_count)
Reads an array of 8-bit signed integers.
static void sofab_istream_read_u32(sofab_istream_t *ctx, uint32_t *var)
Reads a 32-bit unsigned integer.
static void sofab_istream_read_array_of_fp64(sofab_istream_t *ctx, double *var, size_t element_count)
Reads an array of 64-bit floating-point values.
sofab_ret_t sofab_istream_feed(sofab_istream_t *ctx, const void *data, size_t datalen)
Feeds raw Sofab-encoded bytes into the input stream.
static void sofab_istream_read_array_of_u8(sofab_istream_t *ctx, uint8_t *var, size_t element_count)
Reads an array of 8-bit unsigned integers.
@ SOFAB_FIXLENTYPE_STRING
@ SOFAB_TYPE_VARINTARRAY_SIGNED
@ SOFAB_TYPE_VARINT_SIGNED
@ SOFAB_TYPE_VARINT_UNSIGNED
@ SOFAB_TYPE_VARINTARRAY_UNSIGNED
SofaBuffers C - Type definitions and constants.
Decoder context used for Sofab sequences.
struct sofab_istream_decoder * parent
sofab_istream_field_cb_t field_callback
Internal state of the Sofab input stream.
sofab_unsigned_t varint_value
sofab_istream_decoder_t default_decoder
sofab_istream_decoder_t * decoder