29 #ifndef ACORE_BUFFER_BUILDER_H_ 30 #define ACORE_BUFFER_BUILDER_H_ 115 if (
ac_buffer_data(&pBuilder->ac_buffer) + length > pBuilder->data + pBuilder->size) {
118 pBuilder->ac_buffer.size = length;
145 if (off > pBuilder->size) {
148 if (pBuilder->data + off > pBuilder->ac_buffer.data) {
149 pBuilder->ac_buffer.size = off - (pBuilder->ac_buffer.data - pBuilder->data);
151 pBuilder->ac_buffer.size = 0;
170 if (off > pBuilder->size) {
173 if (pBuilder->data + off < pBuilder->ac_buffer.data + pBuilder->ac_buffer.size) {
174 pBuilder->ac_buffer.size = pBuilder->ac_buffer.data - (pBuilder->data + off);
176 pBuilder->ac_buffer.size = 0;
178 pBuilder->ac_buffer.data = pBuilder->data + off;
187 return &pBuilder->ac_buffer;
void ac_buffer_builder_write_le(ac_buffer_builder_t *pBuilder, const uint8_t *buf, size_t size)
Write data to little endian ac_buffer (on a LE architecture, byte order will be preserved) ...
static void ac_buffer_builder_write_nu64(ac_buffer_builder_t *pBuilder, uint64_t hu64)
Write 64-bit value in ac_buffer builder.
static size_t ac_buffer_builder_read_offset(ac_buffer_builder_t *pBuilder)
Get ac_buffer builder's read offset.
static size_t ac_buffer_size(const ac_buffer_t *pBuf)
Get buffer's size.
static void ac_buffer_builder_write_nu24_at(ac_buffer_builder_t *pBuilder, size_t off, uint32_t hu24)
Write 24-bit value in ac_buffer builder at specified position.
static ac_buffer_t * ac_buffer_builder_buffer(ac_buffer_builder_t *pBuilder)
Get ac_buffer builder's underlying ac_buffer.
static void ac_buffer_builder_write_nu32(ac_buffer_builder_t *pBuilder, uint32_t hu32)
Write 32-bit value in ac_buffer builder.
static size_t ac_buffer_builder_length(ac_buffer_builder_t *pBuilder)
Get ac_buffer builder's length.
static void ac_buffer_builder_write_nu24(ac_buffer_builder_t *pBuilder, uint32_t hu24)
Write 24-bit value in ac_buffer builder.
static void ac_buffer_builder_write_nu16(ac_buffer_builder_t *pBuilder, uint16_t hu16)
Write 16-bit value in ac_buffer builder.
void ac_buffer_builder_reset(ac_buffer_builder_t *pBuilder)
Reset ac_buffer builder.
static void ac_buffer_builder_write_nu8_at(ac_buffer_builder_t *pBuilder, size_t off, uint8_t hu8)
Write 8-bit value in ac_buffer builder at specified position.
void ac_buffer_builder_write_be_at(ac_buffer_builder_t *pBuilder, size_t pos, const uint8_t *buf, size_t size)
Write data to big endian ac_buffer at specific position (on a LE architecture, byte order will be swa...
static void ac_buffer_builder_write_nu16_at(ac_buffer_builder_t *pBuilder, size_t off, uint16_t hu16)
Write 16-bit value in ac_buffer builder at specified position.
void ac_buffer_builder_init(ac_buffer_builder_t *pBuilder, uint8_t *data, size_t size)
Initialize ac_buffer builder.
static bool ac_buffer_builder_empty(ac_buffer_builder_t *pBuilder)
Is ac_buffer builder empty.
void ac_buffer_builder_from_buffer(ac_buffer_builder_t *pBuilder)
Initialize ac_buffer builder from underlying ac_buffer.
static void ac_buffer_builder_set_write_offset(ac_buffer_builder_t *pBuilder, size_t off)
Set ac_buffer builder's write offset.
static size_t ac_buffer_builder_write_offset(ac_buffer_builder_t *pBuilder)
Get ac_buffer builder's write offset.
void ac_buffer_builder_compact(ac_buffer_builder_t *pBuilder)
Compact builder Will move underlying buffer's byte to start of allocated buffer.
void ac_buffer_builder_write_n_skip(ac_buffer_builder_t *pBuilder, size_t size)
Skip n-bytes in ac_buffer builder.
static size_t ac_buffer_builder_writable(ac_buffer_builder_t *pBuilder)
Get number of writable bytes in ac_buffer builder.
static void ac_buffer_builder_write_nu64_at(ac_buffer_builder_t *pBuilder, size_t off, uint64_t hu64)
Write 64-bit value in ac_buffer builder at specified position.
static const uint8_t * ac_buffer_data(const ac_buffer_t *pBuf)
Get buffer's underlying byte array.
static void ac_buffer_builder_set_read_offset(ac_buffer_builder_t *pBuilder, size_t off)
Set ac_buffer builder's read offset.
static void ac_buffer_builder_set_length(ac_buffer_builder_t *pBuilder, size_t length)
Set ac_buffer builder's length.
static void ac_buffer_builder_write_n_bytes(ac_buffer_builder_t *pBuilder, const uint8_t *data, size_t size)
Write n-bytes value in ac_buffer builder.
void ac_buffer_builder_write_be(ac_buffer_builder_t *pBuilder, const uint8_t *buf, size_t size)
Write data to big endian ac_buffer (on a LE architecture, byte order will be swapped) ...
static void ac_buffer_builder_write_nu8(ac_buffer_builder_t *pBuilder, uint8_t hu8)
Write 8-bit value in ac_buffer builder.
static bool ac_buffer_full(ac_buffer_builder_t *pBuilder)
Is ac_buffer builder full.
void ac_buffer_builder_set_full(ac_buffer_builder_t *pBuilder)
Set ac_buffer builder's ac_buffer to full size.
static void ac_buffer_builder_write_n_bytes_at(ac_buffer_builder_t *pBuilder, size_t off, const uint8_t *data, size_t size)
Write n-bytes value in ac_buffer builder at specified position.
static size_t ac_buffer_builder_space(ac_buffer_builder_t *pBuilder)
Get space in ac_buffer builder.
void ac_buffer_builder_copy_n_bytes(ac_buffer_builder_t *pBuilderOut, ac_buffer_t *pBufIn, size_t size)
Copy n bytes from buffer to builder.
static uint8_t * ac_buffer_builder_write_position(ac_buffer_builder_t *pBuilder)
Get ac_buffer builder's pointer to write position.
void ac_buffer_builder_write_le_at(ac_buffer_builder_t *pBuilder, size_t pos, const uint8_t *buf, size_t size)
Write data to little endian ac_buffer at specific position (on a LE architecture, byte order will be ...
static void ac_buffer_builder_write_nu32_at(ac_buffer_builder_t *pBuilder, size_t off, uint32_t hu32)
Write 32-bit value in ac_buffer builder at specified position.