object: start implement bit-buffer data structure

This commit is contained in:
2025-04-11 13:56:26 +01:00
parent 0ddfb2ee3c
commit eb7e88d9fa
3 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
#ifndef BLUE_OBJECT_BITBUFFER_H_
#define BLUE_OBJECT_BITBUFFER_H_
#include <blue/object/object.h>
#define B_BITBUFFER(p) ((b_bitbuffer *)(p))
typedef struct b_bitbuffer b_bitbuffer;
BLUE_API b_bitbuffer *b_bitbuffer_create(void);
static inline b_bitbuffer *b_bitbuffer_retain(b_bitbuffer *buf)
{
return B_BITBUFFER(b_retain(B_OBJECT(buf)));
}
static inline void b_bitbuffer_release(b_bitbuffer *buf)
{
b_release(B_OBJECT(buf));
}
BLUE_API b_status b_bitbuffer_put_bit(b_bitbuffer *buf, int bit);
BLUE_API b_status b_bitbuffer_put_bool(b_bitbuffer *buf, bool b);
BLUE_API b_status b_bitbuffer_put_int(
b_bitbuffer *buf, uint64_t v, unsigned int nr_bits);
BLUE_API b_status b_bitbuffer_put_bytes(
b_bitbuffer *buf, const void *p, size_t len, size_t bits_per_byte);
BLUE_API b_status b_bitbuffer_put_string(
b_bitbuffer *buf, const char *p, size_t len, size_t bits_per_char);
#endif