Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

C++ Utilities Library for compilers or various projects

License

Notifications You must be signed in to change notification settings

MorganCaron/CppUtils

Repository files navigation

CppUtils

C++ Utilities Library

Project Health


Project Activity

Library Features

Containers

  • BidirectionalMap - Two-way key-value mapping
  • BTree - Balanced tree for large sorted datasets with efficient range queries and low memory access
  • DependencyGraph - Dependency graph for managing dependencies between objects
  • MeshNetwork - Graph of shared objects without hierarchy
  • Size - Semantic wrapper around std::size_t for representing 2D (Size2: width/height) and 3D (Size3: width/height/depth) sizes
  • Stack - Type-specific stack without predefined type list (unlike TypedStack)
  • Tree - Hierarchical node structure with parent-child links
  • TypedStack - Multi-type stack with exact object size layout, suitable for argument passing and VM stacks
  • Vec2 / Vec3 - 2D/3D math vectors with operators and common functions

Execution

  • Event - An event for thread synchronization
  • EventDispatcher - Event system to subscribe functions and trigger actions by event name
  • EventQueue - Thread-safe event queue running on a dedicated thread for asynchronous event processing (preserves event order)
  • ScopeGuard - RAII utility to execute a function when leaving a scope, ensuring resource cleanup

File System

  • Watcher - File modification watcher

Functional

  • LambdaCalculus - Compile-time utilities for lambda calculus manipulation

Languages (Parsers, Compilers, VM)

  • Tools to create parsers and compilers (CSS, INI, HTML, JSON, Markdown, XML) (work in progress )
  • CSV Mapping - Type-safe CSV to struct mapping with support for custom conversion functions
  • CLikeCompiler - Compiler for C-inspired language
  • GrammarParser - A parser for defining and interpreting custom grammars, used for building language parsers
  • MetaEvaluator - Homoiconic meta-circular evaluator with extensible reflexivity
  • ASTParser - AST parser (work in progress )
  • VirtualMachine - Generic virtual machine

Logging & Benchmarking

  • Logger - Asynchronous, configurable and formattable logger with support for colors and customizable log types
  • FileSink - Pluggable sink for automated file logging with integrated rotation and file size management
  • LogRotate - Log file rotation based on maximum file size
  • ChronoLogger - RAII timer that logs elapsed time at scope exit

Math

  • Easing - Collection of easing functions for smooth animation
  • Random - Pseudorandom number generation
  • Utility - Floating-point comparison with epsilon tolerance

String

  • Encoding - UTF-8 and UTF-32 conversion and character display width utilities
  • Hash - Hashing utilities for strings

Networking

  • Client - TCP client with synchronous and asynchronous modes
  • Server - TCP server with multi-client support

Patterns

  • Singleton - Generic Meyers Singleton implementation (thread-safe and lazy)
  • Multiton - Generic Multiton implementation based on the Meyers Singleton

Terminal

  • Canvas - Terminal-based 2D drawing surface
  • Cursor - Terminal cursor manipulation
  • Primitive - Basic drawing primitives for terminal (lines, rectangles, circles, ellipses)
  • ProgressBar - Dynamically updating terminal progress bar
  • RawTerminal - Raw input handling (no buffering or echo)
  • Size - Terminal size utilities
  • TextColor - Terminal text color utilities
  • TextModifier - Utilities to style and color terminal text
  • Title - Terminal title utilities

Multithreading & Synchronization

  • Scheduler - Simple scheduler to run delayed functions on separate thread
  • ScheduledEventDispatcher - Dispatches events asynchronously with timed (delay/when) execution
  • AsyncEventDispatcher - Event dispatcher that uses a ThreadPool for immediate asynchronous event execution
  • ThreadLoop - Thread loop with exception handling
  • ThreadPool - Fixed-size thread pool for parallel task execution
  • TryAsync - Launches a function asynchronously, forwards exception to caller
  • UniqueLocker - RAII wrapper holding a value with exclusive access
  • SharedLocker - RAII wrapper holding a value with shared/exclusive access
  • Accessor - RAII accessor for reading/writing an UniqueLocker or exclusive access to a SharedLocker
  • ReadOnlyAccessor - RAII accessor for shared (non-exclusive) reading of a SharedLocker, allowing parallel access
  • MultipleAccessor - RAII accessor for multiple lockers, safely acquiring them to avoid deadlocks and data races

Type

  • Concept - Extensions to and providing additional compile-time checks and utilities
  • Enum - Generic enum-to-string conversion
  • Mapping - Generic compile-time mapping between values
  • Tuple - Visitor for std::tuple
  • VariadicTemplate - Metaprogramming on variadic parameters
  • Variant - Generic print and comparison operators for std::variant

Unit Testing

  • DummyObject - Dummy object that prints construction, destruction, copy and move operations, while counting copies and moves for test verification
  • UnitTest - Minimal test framework with assertions and filters

Miscellaneous

  • Many other functions

Getting Started

This library is used in my C++ projects, but you can also use it in your projects. Just follow the installation steps and consult the documentation for each feature you need.

Prerequisites

  • A C++26 compliant compiler with std module support
  • XMake

Installation

In your XMake projects:

add_repositories("xmake-repo git@github.com:MorganCaron/xmake-repo.git")
add_requires("CppUtils")

target("YourProject", function()
add_packages("CppUtils", {public = true})
end)

Configure the build via the xmake menu

xmake f [--toolchain=llvm] --runtimes="c++_shared" [--sdk=/opt/llvm-git] --menu

Configure the build manually

xmake f [--toolchain=llvm] --runtimes="c++_shared" [--sdk=/opt/llvm-git] [-y|--yes] [--enable_tests=y] [--sanitize_memory=y] [--sanitize_thread=y]

Build command

xmake [b|build] [-vD]

Build & Run tests

xmake [r|run] [-d|--debug]

Watch tests

xmake watch -r [-d|--debug]

Contribute


About

C++ Utilities Library for compilers or various projects

Topics

Resources

Readme

License

LGPL-3.0 license

Code of conduct

Code of conduct

Contributing

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 2

Languages