|
SofaBuffers C/C++ 0.12.0
API Documentation
|
SofaBuffers C - Output stream encoder for Sofab messages. More...
#include <stdlib.h>#include <stdint.h>#include <stdbool.h>#include <string.h>#include "sofab/sofab.h"Go to the source code of this file.
Data Structures | |
| struct | sofab_ostream |
Macros | |
| #define | SOFAB_OSTREAM_EXTERN extern |
| #define | SOFAB_LAZY_SEQ_DEPTH 8 |
| Sofab output stream context. | |
Typedefs | |
| typedef struct sofab_ostream | sofab_ostream_t |
| Opaque Sofab output stream context. | |
| typedef void(* | sofab_ostream_flush_cb_t) (sofab_ostream_t *ctx, const uint8_t *data, size_t len, void *usrptr) |
| Output stream flush callback type. | |
Functions | |
| void | sofab_ostream_init (sofab_ostream_t *ctx, uint8_t *buffer, size_t buflen, size_t offset, sofab_ostream_flush_cb_t flush, void *usrptr) |
| Initialize an Sofab output stream context. | |
| size_t | sofab_ostream_flush (sofab_ostream_t *ctx) |
| Flush any pending bytes from the output stream. | |
| size_t | sofab_ostream_bytes_used (sofab_ostream_t *ctx) |
| Get the number of bytes used in the current buffer. | |
| void | sofab_ostream_buffer_set (sofab_ostream_t *ctx, uint8_t *buffer, size_t buflen, size_t offset) |
| Replace the active buffer used by the output stream. | |
| sofab_ret_t | sofab_ostream_write_unsigned (sofab_ostream_t *ctx, sofab_id_t id, sofab_unsigned_t value) |
| Write an unsigned integer field. | |
| sofab_ret_t | sofab_ostream_write_signed (sofab_ostream_t *ctx, sofab_id_t id, sofab_signed_t value) |
| Write a signed integer field. | |
| sofab_ret_t | sofab_ostream_write_fixlen (sofab_ostream_t *ctx, sofab_id_t id, const void *data, int32_t datalen, sofab_fixlentype_t type) |
| Write a fixed-length field. | |
| static sofab_ret_t | sofab_ostream_write_boolean (sofab_ostream_t *ctx, sofab_id_t id, bool value) |
| Write a boolean value (1 byte). | |
| static sofab_ret_t | sofab_ostream_write_fp32 (sofab_ostream_t *ctx, sofab_id_t id, float value) |
| Write a 32-bit floating-point value. | |
| static sofab_ret_t | sofab_ostream_write_fp64 (sofab_ostream_t *ctx, sofab_id_t id, double value) |
| Write a 64-bit floating-point value. | |
| static sofab_ret_t | sofab_ostream_write_string (sofab_ostream_t *ctx, sofab_id_t id, const char *text) |
| Write a null-terminated string. | |
| static sofab_ret_t | sofab_ostream_write_blob (sofab_ostream_t *ctx, sofab_id_t id, const void *data, size_t size) |
| Write a binary blob field. | |
| sofab_ret_t | sofab_ostream_write_array_of_unsigned (sofab_ostream_t *ctx, sofab_id_t id, const void *data, int32_t element_count, int32_t element_size) |
| Write an array of unsigned integers. | |
| sofab_ret_t | sofab_ostream_write_array_of_signed (sofab_ostream_t *ctx, sofab_id_t id, const void *data, int32_t element_count, int32_t element_size) |
| Write an array of signed integers. | |
| sofab_ret_t | sofab_ostream_write_array_of_fixlen (sofab_ostream_t *ctx, sofab_id_t id, const void *data, int32_t element_count, int32_t element_size, sofab_fixlentype_t type) |
| Write an array of fixed-length elements. | |
| static sofab_ret_t | sofab_ostream_write_array_of_i8 (sofab_ostream_t *ctx, sofab_id_t id, const int8_t *var, int32_t element_count) |
| Writes an array of 8-bit signed integers. | |
| static sofab_ret_t | sofab_ostream_write_array_of_u8 (sofab_ostream_t *ctx, sofab_id_t id, const uint8_t *var, int32_t element_count) |
| Writes an array of 8-bit unsigned integers. | |
| static sofab_ret_t | sofab_ostream_write_array_of_i16 (sofab_ostream_t *ctx, sofab_id_t id, const int16_t *var, int32_t element_count) |
| Writes an array of 16-bit signed integers. | |
| static sofab_ret_t | sofab_ostream_write_array_of_u16 (sofab_ostream_t *ctx, sofab_id_t id, const uint16_t *var, int32_t element_count) |
| Writes an array of 16-bit unsigned integers. | |
| static sofab_ret_t | sofab_ostream_write_array_of_i32 (sofab_ostream_t *ctx, sofab_id_t id, const int32_t *var, int32_t element_count) |
| Writes an array of 32-bit signed integers. | |
| static sofab_ret_t | sofab_ostream_write_array_of_u32 (sofab_ostream_t *ctx, sofab_id_t id, const uint32_t *var, int32_t element_count) |
| Writes an array of 32-bit unsigned integers. | |
| static sofab_ret_t | sofab_ostream_write_array_of_i64 (sofab_ostream_t *ctx, sofab_id_t id, const int64_t *var, int32_t element_count) |
| Writes an array of 64-bit signed integers. | |
| static sofab_ret_t | sofab_ostream_write_array_of_u64 (sofab_ostream_t *ctx, sofab_id_t id, const uint64_t *var, int32_t element_count) |
| Writes an array of 64-bit unsigned integers. | |
| static sofab_ret_t | sofab_ostream_write_array_of_fp32 (sofab_ostream_t *ctx, sofab_id_t id, const float *data, int32_t element_count) |
| Write an array of 32-bit floating-point values. | |
| static sofab_ret_t | sofab_ostream_write_array_of_fp64 (sofab_ostream_t *ctx, sofab_id_t id, const double *data, int32_t element_count) |
| Write an array of 64-bit floating-point values. | |
| sofab_ret_t | sofab_ostream_write_sequence_begin (sofab_ostream_t *ctx, sofab_id_t id) |
| Begin encoding a nested sequence (start marker). | |
| sofab_ret_t | sofab_ostream_write_sequence_begin_lazy (sofab_ostream_t *ctx, sofab_id_t id) |
| Begin a nested sequence whose header is held back until it has content. | |
| sofab_ret_t | sofab_ostream_write_sequence_end_keep (sofab_ostream_t *ctx) |
| End a nested sequence, keeping its frame even without content. | |
| sofab_ret_t | sofab_ostream_write_sequence_end (sofab_ostream_t *ctx) |
| End encoding a nested sequence (end marker). | |
SofaBuffers C - Output stream encoder for Sofab messages.
This module implements a streaming encoder for SofaBuffers (Sofab), a compact, TLV-like (Type-Length-Value) binary message format. The encoder writes fields into a user-provided buffer and calls a user-supplied flush callback when the buffer is full or when the user explicitly requests a flush.
Typical usage:
Ownership and semantics (brief):
SPDX-License-Identifier: MIT
Definition in file ostream.h.