54#ifndef CCC_FLAT_BUFFER_H
55#define CCC_FLAT_BUFFER_H
61#include "private/private_flat_buffer.h"
93#define CCC_flat_buffer_default(type_name) \
94 CCC_private_flat_buffer_default(type_name)
126#define CCC_flat_buffer_for(type_name, capacity, count, data_pointer...) \
127 CCC_private_flat_buffer_for(type_name, capacity, count, data_pointer)
183#define CCC_flat_buffer_from( \
184 allocator, optional_capacity, compound_literal_array... \
186 CCC_private_flat_buffer_from( \
187 allocator, optional_capacity, compound_literal_array \
218#define CCC_flat_buffer_with_capacity(type_name, allocator, capacity) \
219 CCC_private_flat_buffer_with_capacity(type_name, allocator, capacity)
240#define CCC_flat_buffer_with_storage(count, compound_literal_array...) \
241 CCC_private_flat_buffer_with_storage(count, compound_literal_array)
360#define CCC_flat_buffer_emplace_back( \
361 flat_buffer_pointer, allocator_pointer, type_compound_literal... \
363 CCC_private_flat_buffer_emplace_back( \
364 flat_buffer_pointer, allocator_pointer, type_compound_literal \
453#define CCC_flat_buffer_as(flat_buffer_pointer, type_name, index) \
454 ((type_name *)CCC_flat_buffer_at(flat_buffer_pointer, index))
477#define CCC_flat_buffer_back_as(flat_buffer_pointer, type_name) \
478 ((type_name *)CCC_flat_buffer_back(flat_buffer_pointer))
491#define CCC_flat_buffer_front_as(flat_buffer_pointer, type_name) \
492 ((type_name *)CCC_flat_buffer_front(flat_buffer_pointer))
538#define CCC_flat_buffer_emplace( \
539 flat_buffer_pointer, index, type_compound_literal... \
541 CCC_private_flat_buffer_emplace( \
542 flat_buffer_pointer, index, type_compound_literal \
561 CCC_Flat_buffer const *buffer,
void *temp,
size_t index,
size_t swap_index
763#ifdef FLAT_BUFFER_USING_NAMESPACE_CCC
766# define flat_buffer_default(argument) CCC_flat_buffer_default(argument)
767# define flat_buffer_for(arguments...) CCC_flat_buffer_for(arguments)
768# define flat_buffer_with_storage(arguments...) \
769 CCC_flat_buffer_with_storage(arguments)
770# define flat_buffer_with_allocator(arguments...) \
771 CCC_flat_buffer_with_allocator(arguments)
772# define flat_buffer_with_capacity(arguments...) \
773 CCC_flat_buffer_with_capacity(arguments)
774# define flat_buffer_from(arguments...) CCC_flat_buffer_from(arguments)
775# define flat_buffer_allocate(arguments...) \
776 CCC_flat_buffer_allocate(arguments)
777# define flat_buffer_reserve(arguments...) CCC_flat_buffer_reserve(arguments)
778# define flat_buffer_copy(arguments...) CCC_flat_buffer_copy(arguments)
779# define flat_buffer_clear(arguments...) CCC_flat_buffer_clear(arguments)
780# define flat_buffer_clear_and_free(arguments...) \
781 CCC_flat_buffer_clear_and_free(arguments)
782# define flat_buffer_count(arguments...) CCC_flat_buffer_count(arguments)
783# define flat_buffer_count_bytes(arguments...) \
784 CCC_flat_buffer_count_bytes(arguments)
785# define flat_buffer_count_plus(arguments...) \
786 CCC_flat_buffer_count_plus(arguments)
787# define flat_buffer_count_minus(arguments...) \
788 CCC_flat_buffer_count_minus(arguments)
789# define flat_buffer_count_set(arguments...) \
790 CCC_flat_buffer_count_set(arguments)
791# define flat_buffer_capacity(arguments...) \
792 CCC_flat_buffer_capacity(arguments)
793# define flat_buffer_capacity_bytes(arguments...) \
794 CCC_flat_buffer_capacity_bytes(arguments)
795# define flat_buffer_sizeof_type(arguments...) \
796 CCC_flat_buffer_sizeof_type(arguments)
797# define flat_buffer_index(arguments...) CCC_flat_buffer_index(arguments)
798# define flat_buffer_is_full(arguments...) CCC_flat_buffer_is_full(arguments)
799# define flat_buffer_is_empty(arguments...) \
800 CCC_flat_buffer_is_empty(arguments)
801# define flat_buffer_at(arguments...) CCC_flat_buffer_at(arguments)
802# define flat_buffer_as(arguments...) CCC_flat_buffer_as(arguments)
803# define flat_buffer_back(arguments...) CCC_flat_buffer_back(arguments)
804# define flat_buffer_back_as(arguments...) CCC_flat_buffer_back_as(arguments)
805# define flat_buffer_front(arguments...) CCC_flat_buffer_front(arguments)
806# define flat_buffer_front_as(arguments...) \
807 CCC_flat_buffer_front_as(arguments)
808# define flat_buffer_allocate_back(arguments...) \
809 CCC_flat_buffer_allocate_back(arguments)
810# define flat_buffer_emplace(arguments...) CCC_flat_buffer_emplace(arguments)
811# define flat_buffer_emplace_back(arguments...) \
812 CCC_flat_buffer_emplace_back(arguments)
813# define flat_buffer_push_back(arguments...) \
814 CCC_flat_buffer_push_back(arguments)
815# define flat_buffer_pop_back(arguments...) \
816 CCC_flat_buffer_pop_back(arguments)
817# define flat_buffer_pop_back_n(arguments...) \
818 CCC_flat_buffer_pop_back_n(arguments)
819# define flat_buffer_move(arguments...) CCC_flat_buffer_move(arguments)
820# define flat_buffer_swap(arguments...) CCC_flat_buffer_swap(arguments)
821# define flat_buffer_write(arguments...) CCC_flat_buffer_write(arguments)
822# define flat_buffer_erase(arguments...) CCC_flat_buffer_erase(arguments)
823# define flat_buffer_insert(arguments...) CCC_flat_buffer_insert(arguments)
824# define flat_buffer_begin(arguments...) CCC_flat_buffer_begin(arguments)
825# define flat_buffer_next(arguments...) CCC_flat_buffer_next(arguments)
826# define flat_buffer_end(arguments...) CCC_flat_buffer_end(arguments)
827# define flat_buffer_reverse_begin(arguments...) \
828 CCC_flat_buffer_reverse_begin(arguments)
829# define flat_buffer_reverse_next(arguments...) \
830 CCC_flat_buffer_reverse_next(arguments)
831# define flat_buffer_reverse_end(arguments...) \
832 CCC_flat_buffer_reverse_end(arguments)
833# define flat_buffer_data(arguments...) CCC_flat_buffer_data(arguments)
CCC_Result CCC_flat_buffer_pop_back(CCC_Flat_buffer *buffer)
pop the back element from the Flat_buffer according to size.
CCC_Count CCC_flat_buffer_count_bytes(CCC_Flat_buffer const *buffer)
Return the bytes in the Flat_buffer given the current count of active elements.
CCC_Result CCC_flat_buffer_clear(CCC_Flat_buffer *buffer, CCC_Destructor const *destructor)
Set size of buffer to 0 and call destroy on each element if needed. O(1) if no destroy is provided,...
CCC_Result CCC_flat_buffer_allocate(CCC_Flat_buffer *buffer, size_t capacity, CCC_Allocator const *allocator)
allocates the Flat_buffer to the specified size according to the user defined allocation function.
CCC_Result CCC_flat_buffer_count_minus(CCC_Flat_buffer *buffer, size_t count)
Subtract count from the size of the buffer.
CCC_Count CCC_flat_buffer_index(CCC_Flat_buffer const *buffer, void const *slot)
return the index of an element known to be in the buffer.
CCC_Result CCC_flat_buffer_reserve(CCC_Flat_buffer *buffer, size_t to_add, CCC_Allocator const *allocator)
Reserves space for at least to_add more elements.
CCC_Tribool CCC_flat_buffer_is_full(CCC_Flat_buffer const *buffer)
return true if the size of the Flat_buffer equals capacity.
CCC_Result CCC_flat_buffer_write(CCC_Flat_buffer const *buffer, size_t index, void const *data)
write data to Flat_buffer at slot at index index according to capacity.
void * CCC_flat_buffer_push_back(CCC_Flat_buffer *buffer, void const *data, CCC_Allocator const *allocator)
return the newly pushed data into the last slot of the buffer according to size.
void * CCC_flat_buffer_at(CCC_Flat_buffer const *buffer, size_t index)
return the element at slot index in buf.
CCC_Tribool CCC_flat_buffer_is_empty(CCC_Flat_buffer const *buffer)
return true if the size of the Flat_buffer is 0.
void * CCC_flat_buffer_reverse_end(CCC_Flat_buffer const *buffer)
return the reverse_end position of the buffer.
void * CCC_flat_buffer_insert(CCC_Flat_buffer *buffer, size_t index, void const *data, CCC_Allocator const *allocator)
insert data at slot index according to size of the Flat_buffer maintaining contiguous storage of elem...
CCC_Result CCC_flat_buffer_swap(CCC_Flat_buffer const *buffer, void *temp, size_t index, size_t swap_index)
swap elements at index and swap_index according to capacity of the bufer.
CCC_Result CCC_flat_buffer_copy(CCC_Flat_buffer *destination, CCC_Flat_buffer const *source, CCC_Allocator const *allocator)
Copy the buffer from source to newly initialized destination.
CCC_Result CCC_flat_buffer_clear_and_free(CCC_Flat_buffer *buffer, CCC_Destructor const *destructor, CCC_Allocator const *allocator)
Set size of buffer to 0 and call destroy on each element if needed. Free the underlying Flat_buffer s...
void * CCC_flat_buffer_front(CCC_Flat_buffer const *buffer)
return the first element in the Flat_buffer at index 0.
void * CCC_flat_buffer_end(CCC_Flat_buffer const *buffer)
return the end position of the Flat_buffer according to size.
void * CCC_flat_buffer_next(CCC_Flat_buffer const *buffer, void const *iterator)
advance the iterator to the next slot in the Flat_buffer according to size.
void * CCC_flat_buffer_allocate_back(CCC_Flat_buffer *buffer, CCC_Allocator const *allocator)
allocates a new slot from the Flat_buffer at the end of the contiguous array. A slot is equivalent to...
void * CCC_flat_buffer_data(CCC_Flat_buffer const *buffer)
return a reference to the underlying data of the buffer.
void * CCC_flat_buffer_back(CCC_Flat_buffer const *buffer)
return the final element in the Flat_buffer according the current size.
CCC_Count CCC_flat_buffer_capacity(CCC_Flat_buffer const *buffer)
Return the current capacity of total possible slots.
CCC_Result CCC_flat_buffer_erase(CCC_Flat_buffer *buffer, size_t index)
erase element at slot index according to size of the Flat_buffer maintaining contiguous storage of el...
void * CCC_flat_buffer_reverse_begin(CCC_Flat_buffer const *buffer)
obtain the address of the last element in the Flat_buffer in preparation for iteration according to s...
CCC_Count CCC_flat_buffer_capacity_bytes(CCC_Flat_buffer const *buffer)
Return the bytes in the Flat_buffer given the current capacity elements.
void * CCC_flat_buffer_move(CCC_Flat_buffer const *buffer, size_t destination, size_t source)
Move data at index source to destination according to capacity.
CCC_Count CCC_flat_buffer_sizeof_type(CCC_Flat_buffer const *buffer)
The size of the type being stored contiguously in the buffer.
CCC_Result CCC_flat_buffer_pop_back_n(CCC_Flat_buffer *buffer, size_t count)
pop count elements from the back of the Flat_buffer according to size.
void * CCC_flat_buffer_begin(CCC_Flat_buffer const *buffer)
obtain the base address of the Flat_buffer in preparation for iteration.
CCC_Result CCC_flat_buffer_count_plus(CCC_Flat_buffer *buffer, size_t count)
add count to the size of the buffer.
CCC_Result CCC_flat_buffer_count_set(CCC_Flat_buffer *buffer, size_t count)
Set the Flat_buffer size to n.
void * CCC_flat_buffer_reverse_next(CCC_Flat_buffer const *buffer, void const *iterator)
advance the iterator to the next slot in the Flat_buffer according to size and in reverse order.
CCC_Count CCC_flat_buffer_count(CCC_Flat_buffer const *buffer)
obtain the count of Flat_buffer active slots.
The type passed by reference to any container function that may need to allocate memory....
Definition: types.h:369
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:243
The type passed by reference to any container function that may need to destroy elements....
Definition: types.h:457
Definition: private_flat_buffer.h:32
void * data
Definition: private_flat_buffer.h:34
size_t capacity
Definition: private_flat_buffer.h:38
size_t count
Definition: private_flat_buffer.h:36
The C Container Collection Fundamental Types.
CCC_Tribool
A three state boolean to allow for an error state. Error is -1, False is 0, and True is 1.
Definition: types.h:178
CCC_Result
A result of actions on containers.
Definition: types.h:192