C/C++ code preprocessor generating code of containers. Generated code is based on marks found in processed code.
Following container types are supported:
struct
- Simple structure composed from contained elements.array
- Array of contained elements.queue
- One direction queue of contained elements.list
- List of contained elements.rb_tree
- Red-black tree of contained elements.
Data of contained elements are stored in continuous block of memory. Memory block is resized when its size is not sufficient for requested count of elements. Copying of memory block while resizing is performed by realloc, no knowledge of objects structure other than its size is required.
Elements inside containers are identified by indexes (unsigned int) which are persistent and cannot be invalidated by any operation other than removal of this particular element. This allows usage of element indexes as members in other structures related to container, rather than pointers.
C++ Constructors and destructors are not used by generated structures.
Methods init
and clear
are instead used for object initialization and
clear.
init
- After creation of object (allocation on heap, or on stack) it must be
initialized by method init
or related metods (init_size
).
clear
- Clears object content, release allocated resources and reset object
state to initialized state. Object is not invalidated by clear
method.
Containers code is generated to .cc
file. Generated code can be read, modified,
or copied and used in another projects.
Enter build directory build
.
cd build
Process cmake source.
cmake ..
Build container generator.
make -j$(nproc)
Examples of container generator usage are presented in directory: cont/examples
.