Elementa  v3.0.0
Minimalistic library for any C++ application (C++11 and up)
The Elementa library for C++

This library contains a number of minimal extensions of the C++ base language that have proven useful in many applications. This version can be used with C++11 and newer standards (C++14, C++17, ...), and is self-contained (no external libraries needed).

Its main features are:

  • An extension of enum classes that allows for getting the string name of any ID, enumeration of all IDs, counting the IDs and creating combinations (sets) of IDs.
  • An exception system that allows for concatenating exceptions and including the place and time of their occurence, if needed.
  • A debugging system based on preprocessor macros that allows for including and activating/deactivating traces in std::cout format within the code, both at function and file scopes, using, at will, place and time in those traces.
  • Some useful ADTs (abstract data types) such as graphs, trees and Finite State Machines.
  • Multiple iterators, i.e., iterators that can have diverse iteration behaviours on the same container.
  • (Maybe the most developed and important) A serialization system with serial_channels entirely compatible with std streams that, using their minimal set of functionalities, extends then to provide multiple independent and multiple serializers for a given type, serial channels associated to containers (vector, strings,...), and special channels to produce a constant value indefinitely, to absorb any input indefinitely (with or without counting/buffering), to multiplex multiple input channels into one or to divert (copy) the data from an input channel into an output channel. Basic serializers that work with these channels are also provided (numbers, strings, tokens).
  • An optional parsing module able to deal with general, imperative language expressions (in post-, mid- and pre-fix notation) and also with context-free grammars, particularly with LL(1) grammars.
  • An optional operating system module to provide some functionality when running under an OS, such as the management of command line parameters.

It has the following requirements to compile:

  • It must compile with a C++11 -enabled compiler. It has been tested with g++ 8.3.0 and VStudio Community 2017.
  • The target system must have some integral type of exactly 8 bits. Notice that if the target has such a type, it will be equivalent to char / unsigned char, since no integral type in C++ can be shorter than 8 bits and char is the shortest integral type; thus, it is a matter of declaring intentions whether you write char or int8_t in your code, because they will be equivalent in the context of Elementa.

The functionality of the library is grouped into modules that you can browse in the leftside menu of this page. Its minimalistic core is defined in Base modules.

elementa.h is the only header you need to include in your source code.

You can download the source of the last version. It comes with minimalistic cmake files for Linux that create the library and some unit tests within the same directory (i.e., no installation in the system or preparation for including Elementa directories in other applications is automatically performed). The way to use them is to go to the "build" directory, then do "cmake ..", then do "make".

Author
Juan-Antonio Fernandez-Madrigal. http://jafma.net
Date
Although you see a small version number above in this page, Elementa has been my personal library since 1997, when I wrote it in C and did not have that name. The port to C++98 occurred around 2000, and the C++11 version, much smaller and the first with the minimalistic goal in mind, was created from that in Aug-Nov 2016. (Yes, I like it slow; I do not like to grab the lattest version of any language just to look trendy).