Skip to content

MorganCaron/CppUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

CppUtils

Logo CppUtils

C++ Utilities Library

Github Stars Github Forks Top Language Discord License GitHub Sponsors

Project Health

CI Windows CI Windows MSYS2 CI Linux CI MacOS

Codacy grade


Project Activity

Alt

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

  • EventSystem - Event system to subscribe functions and trigger actions by event name
  • Planner - Simple scheduler to run delayed functions on separate threads

๐Ÿ“ 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 )
  • CLikeCompiler - Compiler for C-inspired language
  • TreeParser - Tree parser (work in progress )
  • VirtualMachine - Generic virtual machine

๐Ÿ“ Logging & Benchmarking

  • Logger - Formattable logger with customizable log types and appearances
  • LogRotate - Log file rotation based on maximum file size
  • ChronoLogger - RAII timer that logs elapsed time at scope exit

๐Ÿงฎ Math

  • Float - Floating-point comparison with epsilon tolerance
  • Random - Pseudorandom number generation

๐Ÿ”  String

  • Hash - Hashing utilities for strings

๐ŸŒ Networking

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

๐Ÿ’ป Terminal

  • Canvas - Terminal-based 2D drawing surface
  • Cursor - Terminal cursor manipulation
  • 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

  • Event - An event for thread synchronization
  • 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 <type_traits> and <concepts> providing additional compile-time checks and utilities
  • Enum - Generic enum-to-string conversion
  • Mapping - Static reflection on members (pre-C++26)
  • 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 [email protected]: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

Contribute


About

C++ Utilities Library for compilers or various projects

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •  

Languages