My chelTypes C++ library provides many functionalities. Note though that all of it is still in the works and subject to change.

A unique attribute of the library is that it uses the experimental C++20 concepts feature, as implemented in the latest versions of the GCC, to efficiently define functionality which ought to be shared by many types.

The reasoning behind my creation of it is more or less based on my dissatisfaction of other libraries. The Standard C++ Template library, in my experience, is over-engineered (an intellisense pop-up for a simple array access could be several lines long, unreadable). The Visual C++ libraries are less portable, closed-source, and closed to convenient extension. My library, on the other hand, will be open-source, well-documented, portable, and full of easy to understand functionality.


Partial Outline of library


Templates

CUrDblLkLst<T, int N>
Premiere list type of the library; the most efficient. It is an unrolled doubly-linked list of objects of type T, with each node containing N elements. It is essentially a doubly-linked list with improved cache performance and faster traversal. Random access is linear yet still fast. Iterative access is constant. Push/pop from ends is constant. Iterative add/remove is constant. Random add/remove is linear yet still fast.

CDynLst<T>
Main contiguous memory list type for any type T. Reserves space on both ends of itself, to allow room for new elements. Manual functions for memory management are available for such situations where using them could improve performance. Random access is constant. Iterative access is constant. Push/Pop from ends is constant if memory is available, otherwise reallocates. Add/Remove is linear on half the size of the list.

Ptr<T>
Performs automatic memory management for heap-allocated objects of type T. It is thread-safe. It does this by reference counting across all threads. The heap-allocated object is destroyed when there are no more references to it. Useful for complex algorithms which need heap-allocated objects, or for people who like Java. Access and modification take constant time.

CField<T>
Manages a fixed-size 2-dimensional array of elements of type T. Simple, no questions asked.

CHMap<K,V>
Uses hashing to map values of class K to type V. Multiples keys can have the same value. The type K must implement the IIHashable concept; it must have members .hashSource and .hashLength . Random access is linear on the size of the map, but as with all hash-based maps it is still very fast. Add/remove performs similarly.

CHArithmeticMap<K, V>
Uses hashing to map values of arithmetic type K to type V. Multiples keys can have the same value. The type K must be one of the pre-defined integral, floating-point, or pointer type. Random access is linear on the size of the map, but as with all hash-based maps it is still very fast. Add/remove performs similarly.

CTree<T>
Provides a generic tree structure, with each node containing a value of type T. A tree must have a root node with a value. Each node can have multiple children, which are indexed. Provides functions for calling anonymous functions on children, among other functionality. A CTree cannot be constructed directly; use HTree. Add/Remove child takes linear time on the current number of direct children.

HTree<T>
Constructs and manages the memory of CTree<T> ; Every root of a CTree has a handle like this. The entire tree structure is freed from memory when its HTree is destroyed. Via implicit conversion operators, all functions of CTree can be called on HTree.


Strings & Streams

Character
This is a namespace; contains functions for analyzing individuals characters.

String
Simple string type inherits from CDynLst<char>. As such all functions of CDynLst<char> are accessible to String. Overloaded operators allow for concatenation of String with multiple types. Implicitly convertible to const char*, automatically adding null termination characters. Has the performance characteristics of CDynLst<char>.

WString
Identical to String, except that it inherits from CDynLst<wchar>.

Stream
Simple stream interface inherits from CUrDblLkLst<char>, although the functionality of CUrDblLkLst is not directly accessible from outside the IStream class. Declares simple functions for handling a Stream.

WStream
Identical to IStream, except that it inherits from CUrDblLkLst<wchar>.


Console Features

IConsole
An interface which defines simple console functions. The interface is defined such that it can call, access, and manipulate console variables and console commands. A global pointer to an instance of such a console is g_pConsole . This is the console to which the global scope variadic Msg(…) and DevMsg(…) functions call to.

CON_COMMAND(…)
A simple macro which can be used in any namespace scope to define a command which can be called by the g_pConsole. The definition of the command, in curly braces, immediately follows.

ConVar
This class represents a single variable accessible to the g_pConsole. In the console, the values of these variables can be accessed and manipulated. The values can be similarly accessed and manipulated from the code; this allows the user to create settings and conditions for changing how the program runs.


Style Guide

These are descriptions which will help those using and editing the library to understand it all.

File Extensions

  • .h – denotes every-day include file which contain context-free declarations of functions, classes, structs, enums, namespaces, externals, etc.
  • .hpp – denotes an include file which contains the definitions of functions used by class templates.
  • .cpp – denotes source file which contains definitions for concrete class’ functions, global objects, and anything which could otherwise appear in a .h file.
  • .i – denotes a context-sensitive header file which declares functions, sub-classses, member variables, etc. to be included from within the declaration of a class, struct, namespace, enum, etc. Definition of a macro may be required prior to inclusion. Useful for having different classes share code.
  • .ipp denotes a context-sensitive “source” file which contains definitions for classes, functions, etc., as meant to be included from a .cpp file. Definition of a macro may be required prior to inclusion. Useful for having different classes share code.

Type Prefixes

N – Denotes a namespace composed of functions which operate on a single concept. This allows for multiple classes which implement a concept to share code.
C – All concrete classes and class templates start with C, distinguishing them from interfaces or concepts. One exception to this rule is for classes which are so common or intuitive such that the distinction is not necessary. Ex. “String” or “WString”. The other exception is for when a class fills a category below.
E – Enumerated values start with E, although enforcement of this rule is loose, especially for scoped enumerations.
I – Interfaces and concepts start with I.
H – Defines a handle to an instance of another class. A handle manages the storage duration of the object. The storage duration is unique for each type of handle. Some may do reference counting, others will destroy the object upon their own destruction. Ex. “HTree” handles a tree structure with nodes of type T.

Variable Prefixes

All member variables are prefixed with m_ . This is shorter and less context-sensitive than using “this->”, and also allows for quick auto-complete access of members variables.

Class-scoped static variables are prefixed with g_ if they are public or with s_ if they are protected or private.

Global variables are prefixed with g_ .

Post-prefixes for such variables are added to denote type and purpose.

Local variables do not follow strict conventions.