InStream/OutStream
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#ifndef INCLUDED_C_BINARYINSTREAM_H
|
||||
#define INCLUDED_C_BINARYINSTREAM_H
|
||||
|
||||
#ifndef INCLUDED_C_INSTREAM_H
|
||||
#include <c_InStream.h>
|
||||
#endif /*INCLUDED_C_INSTREAM_H*/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
|
||||
typedef struct {
|
||||
c_InStream_t* base_io; /* Underlying core polymorphically bound I/O driver ports backend link */
|
||||
int buffer; /* 8-bit cache buffer of bits read in */
|
||||
int n; /* Number of bits currently remaining active/unread in buffer */
|
||||
} c_BinaryInStream_t;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
c_err_t c_BinaryInStream_Init(c_BinaryInStream_t* self, c_InStream_t* underlying_io_port);
|
||||
|
||||
c_err_t c_BinaryInStream_ReadBits(c_BinaryInStream_t* self, int bit_count, uint32_t* out_value);
|
||||
c_err_t c_BinaryInStream_ReadBit(c_BinaryInStream_t* self, int* out_bit);
|
||||
c_err_t c_BinaryInStream_ReadByte(c_BinaryInStream_t* self, int* out_byte);
|
||||
c_err_t c_BinaryInStream_ReadChar(c_BinaryInStream_t* self, char* out_char);
|
||||
c_err_t c_BinaryInStream_ReadUInt16(c_BinaryInStream_t* self, uint16_t* out_x);
|
||||
c_err_t c_BinaryInStream_ReadUInt32(c_BinaryInStream_t* self, uint32_t* out_x);
|
||||
c_err_t c_BinaryInStream_ReadUInt64(c_BinaryInStream_t* self, uint64_t* out_x);
|
||||
c_err_t c_BinaryInStream_ReadFloat(c_BinaryInStream_t* self, float* out_x);
|
||||
c_err_t c_BinaryInStream_ReadDouble(c_BinaryInStream_t* self, double* out_x);
|
||||
|
||||
/**
|
||||
* @brief Reads a null-terminated string out from the binary stream.
|
||||
* @param buffer_cap Maximum threshold size limit matching out_buffer allocation bounds to prevent overflows.
|
||||
*/
|
||||
c_err_t c_BinaryInStream_ReadString(c_BinaryInStream_t* self, char* out_buffer, c_size_t buffer_cap);
|
||||
|
||||
|
||||
#endif /*INCLUDED_C_BINARYINSTREAM_H*/
|
||||
Reference in New Issue
Block a user