Git Product home page Git Product logo

cont's Introduction

cont - container generator

Build Status CI

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.

Motivation for container generator

Every container is based on continuous memory block

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.

Persistent unsigned indexes instead of iterators

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.

Constructor/destructor not used at all

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.

Generated code is human readable and accessible

Containers code is generated to .cc file. Generated code can be read, modified, or copied and used in another projects.

Build container generator

Enter build directory build.

cd build

Process cmake source.

cmake ..

Build container generator.

make -j$(nproc)

Examples

Examples of container generator usage are presented in directory: cont/examples.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.