34 #define DB_ERR_NONE 0x00
35 #define DB_ERR_INVALID_BUFFER 0x01
36 #define DB_ERR_END_OF_BUFFER 0x02
37 #define DB_ERR_NOT_SUPPORTED 0x03
40 #define DB_STR_OVERHEAD 2
63 #define DB_BUF_INIT(PTR, LEN) { .start = PTR, .cur = PTR, .end = PTR + LEN, .error = DB_ERR_NONE }
85 return (uint32_t) ( buf->
cur - buf->
start );
97 return (uint32_t) ( buf->
end - buf->
cur );
121 return (uint32_t) ( buf->
end - buf->
start );
267 *
boolean = byte == 1 ?
true :
false;
bool dbReadF64(DataBuffer *buf, f64_t *flt)
Reads an 64-bit floating point.
bool dbReadU8(DataBuffer *buf, uint8_t *byte)
Reads an unsigned byte.
bool dbReadString(DataBuffer *buf, char *s, int size)
Reads a string from the stream.
bool dbSkip(DataBuffer *buf, size_t skipSize)
Skips a number of bytes in the buffer.
bool dbWriteI16(DataBuffer *buf, int16_t i)
Writes a short (16 bits signed) integer.
static bool dbWriteBool(DataBuffer *buf, bool boolean)
Writes a boolean.
bool dbReadU16(DataBuffer *buf, uint16_t *u)
Reads a unsigned short (16 bits unsigned) integer.
bool dbWriteI32(DataBuffer *buf, int32_t i)
Writes an 32 bits signed integer.
bool dbWriteI8(DataBuffer *buf, int8_t byte)
Writes a byte.
Special library for primitive IEEE 754 floating point handling without dragging all float support alo...
bool dbReadF32(DataBuffer *buf, f32_t *flt)
Reads an 32-bit floating point.
uint8_t * end
End Pointer.
uint8_t * start
Start Pointer.
static void dbReset(DataBuffer *buf)
Resets the buffer to its initial state.
Defines a DataBuffer structure.
static uint32_t dbFree(DataBuffer *buf)
Returns the number of bytes still free in the buffer.
static bool dbReadBool(DataBuffer *buf, bool *boolean)
Reads a boolean.
static uint32_t dbLength(DataBuffer *buf)
Returns the lenght of the current buffer.
bool dbReadI64(DataBuffer *buf, int64_t *i)
Reads an 64 bits signed integer.
bool dbWriteF64(DataBuffer *buf, f64_t flt)
Writes a 64-bit floating point.
uint32_t f32_t
32 bit representation for float.
bool dbWriteF32(DataBuffer *buf, f32_t flt)
Writes a 32-bit floating point.
uint64_t f64_t
642 bit representation for float
bool dbWriteU8(DataBuffer *buf, uint8_t byte)
Writes a unsigned byte.
bool dbReadI8(DataBuffer *buf, int8_t *byte)
Reads an byte.
bool dbWriteU64(DataBuffer *buf, uint64_t i)
Writes an 64 bits unsigned integer.
bool dbReadU32(DataBuffer *buf, uint32_t *u)
Reads an 32 bits unsigned integer.
bool dbWrite(DataBuffer *buf, uint8_t *buffer, int len)
Writes the given buffer with the specified length.
bool dbWriteI64(DataBuffer *buf, int64_t i)
Writes an 64 bits signed integer.
bool dbWriteString(DataBuffer *buf, const char *s, int max)
Writes a String as 'sort of' UTF-8 encoding, as defined in the Java DataOuput and DataInput writeUTF ...
static uint32_t dbSize(DataBuffer *buf)
Returns the total size of the buffer.
bool dbReadI32(DataBuffer *buf, int32_t *i)
Reads an 32 bits signed integer.
bool dbRead(DataBuffer *buf, uint8_t *buffer, int len)
Reads into given buffer with the specified length.
bool dbReadI16(DataBuffer *buf, int16_t *i)
Reads a short (16 bits signed) integer.
uint8_t * cur
Current Pointer.
bool dbWriteU32(DataBuffer *buf, uint32_t u)
Writes an 32 bits unsigned integer.
bool dbWriteU16(DataBuffer *buf, uint16_t u)
Writes a unsigned short (16 bits unsigned) integer.
bool dbReadU64(DataBuffer *buf, uint64_t *i)
Reads an 64 bits unsigned integer.