Skip to content

Commit 527dd48

Browse files
committed
Update README & moving files
1 parent bbb11ec commit 527dd48

10 files changed

Lines changed: 107 additions & 52 deletions

File tree

README.md

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,90 @@
2525

2626
![Alt](https://repobeats.axiom.co/api/embed/5ee3902d41c9a270bed3f8aa8dba9dd6298fd5ef.svg "Repobeats analytics image")
2727

28-
### In this library you can find:
29-
30-
- Additional containers ([bidirectional map](modules/Container/BidirectionalMap.mpp), [b-tree](modules/Container/BTree.mpp), [meshes](modules/Container/MeshNetwork.mpp), [stacks](modules/Container/TypedStack.mpp), [trees](modules/Container/Tree.mpp))
31-
- A [file modification listener](modules/FileSystem/Watcher.mpp)
32-
- Tools for creating parsers and compilers (Work in progress <img src="resources/loading.gif" width="12" height="12"/> )
33-
- Parsers and compilers for popular languages (CSS, INI, HTML, JSON, Markdown, XML) (Work in progress <img src="resources/loading.gif" width="12" height="12"/> )
34-
- A [logger](modules/Log/Logger.mpp) with a [file rotation system](modules/Log/LogRotate.mpp)
35-
- [Benchmark tools](modules/Log/ChronoLogger.mpp)
36-
- [Hashing functions](modules/String/Hash.mpp)
37-
- Networking functions ([Server](modules/Network/Server.mpp)/[Client](modules/Network/Client.mpp))
38-
- Terminal UI tools ([canvas](modules/Terminal/Canvas.mpp), [input](modules/Terminal/RawTerminal.mpp), [colors/style](modules/Terminal/TextModifier.mpp))
39-
- Utilities for securing multithreaded accesses ([UniqueLocker](modules/Thread/UniqueLocker.mpp), [SharedLocker](modules/Thread/SharedLocker.mpp))
40-
- A [ThreadPool](modules/Thread/ThreadPool.mpp)
41-
- [Tools for writing unit tests](modules/UnitTest/UnitTest.mpp)
42-
- [STL polyfills](include/Stl)
28+
## Library Features
29+
30+
### 📦 Containers
31+
- [`BidirectionalMap`](modules/Container/BidirectionalMap.mpp) - Two-way key-value mapping
32+
- [`BTree`](modules/Container/BTree.mpp) - Balanced tree for large sorted datasets with efficient range queries and low memory access
33+
- [`DependencyGraph`](modules/Container/DependencyGraph.mpp) - Dependency graph for managing dependencies between objects
34+
- [`MeshNetwork`](modules/Container/MeshNetwork.mpp) - Graph of shared objects without hierarchy
35+
- [`Size`](modules/Container/Size.mpp) - Semantic wrapper around `std::size_t` for representing 2D (`Size2`: width/height) and 3D (`Size3`: width/height/depth) sizes
36+
- [`Stack`](modules/Container/Stack.mpp) - Type-specific stack without predefined type list (unlike [`TypedStack`](modules/Container/TypedStack.mpp))
37+
- [`Tree`](modules/Container/Tree.mpp) - Hierarchical node structure with parent-child links
38+
- [`TypedStack`](modules/Container/TypedStack.mpp) - Multi-type stack with exact object size layout, suitable for argument passing and VM stacks
39+
- [`Vec2`](modules/Container/Vec2.mpp) / [`Vec3`](modules/Container/Vec3.mpp) - 2D/3D math vectors with operators and common functions
40+
41+
### 📁 File System
42+
- [`Watcher`](modules/FileSystem/Watcher.mpp) - File modification watcher
43+
44+
### 🧠 Functional
45+
- [`LambdaCalculus`](modules/Functional/LambdaCalculus.mpp) - Compile-time utilities for lambda calculus manipulation
46+
47+
### 🔣 Languages (Parsers, Compilers, VM)
48+
- Tools to create parsers and compilers (CSS, INI, HTML, JSON, Markdown, XML) (work in progress <img src="resources/loading.gif" width="12" height="12"/>)
49+
- [`CLikeCompiler`](modules/Language/CLikeCompiler.mpp) - Compiler for C-inspired language
50+
- [`TreeParser`](modules/Language/TreeParser.mpp) - Tree parser (work in progress <img src="resources/loading.gif" width="12" height="12"/>)
51+
- [`VirtualMachine`](modules/Language/VirtualMachine.mpp) - Generic virtual machine
52+
53+
### 📝 Logging & Benchmarking
54+
- [`Logger`](modules/Log/Logger.mpp) - Formattable logger with customizable log types and appearances
55+
- [`LogRotate`](modules/Log/LogRotate.mpp) - Log file rotation based on maximum file size
56+
- [`ChronoLogger`](modules/Log/ChronoLogger.mpp) - RAII timer that logs elapsed time at scope exit
57+
58+
### 🧮 Math
59+
- [`Float`](modules/Math/Float.mpp) - Floating-point comparison with epsilon tolerance
60+
- [`Random`](modules/Math/Random.mpp) - Pseudorandom number generation
61+
62+
### 🔠 String
63+
- [`Hash`](modules/String/Hash.mpp) - Hashing utilities for strings
64+
65+
### 🌐 Networking
66+
- [`Client`](modules/Network/Client.mpp) - TCP client with synchronous and asynchronous modes
67+
- [`Server`](modules/Network/Server.mpp) - TCP server with multi-client support
68+
69+
### 💻 Terminal
70+
- [`Canvas`](modules/Terminal/Canvas.mpp) - Terminal-based 2D drawing surface
71+
- [`Cursor`](modules/Terminal/Cursor.mpp) - Terminal cursor manipulation
72+
- [`ProgressBar`](modules/Terminal/ProgressBar.mpp) - Dynamically updating terminal progress bar
73+
- [`RawTerminal`](modules/Terminal/RawTerminal.mpp) - Raw input handling (no buffering or echo)
74+
- [`Size`](modules/Terminal/Size.mpp) - Terminal size utilities
75+
- [`TextColor`](modules/Terminal/TextColor.mpp) - Terminal text color utilities
76+
- [`TextModifier`](modules/Terminal/TextModifier.mpp) - Utilities to style and color terminal text
77+
- [`Title`](modules/Terminal/Title.mpp) - Terminal title utilities
78+
79+
### 🚦 Multithreading & Synchronization
80+
- [`Event`](modules/Thread/Event.mpp) - An event for thread synchronization
81+
- [`SharedLocker`](modules/Thread/SharedLocker.mpp) - Scoped lock wrapper with shared or exclusive mode
82+
- [`ThreadLoop`](modules/Thread/ThreadLoop.mpp) - Thread loop with exception propagation
83+
- [`ThreadPool`](modules/Thread/ThreadPool.mpp) - Fixed-size thread pool for parallel task execution
84+
- [`TryAsync`](modules/Thread/TryAsync.mpp) - Launches a function asynchronously, forwards exception to caller
85+
- [`UniqueLocker`](modules/Thread/UniqueLocker.mpp) - Scoped exclusive lock wrapper
86+
87+
### 🏷️ Type
88+
- [`Concept`](modules/Type/Concept.mpp) - Extensions to `<type_traits>` and `<concepts>` providing additional compile-time checks and utilities
89+
- [`Enum`](modules/Type/Enum.mpp) - Generic enum-to-string conversion
90+
- [`Mapping`](modules/Type/ObjectMapping.mpp) - Static reflection on members (pre-C++26)
91+
- [`Tuple`](modules/Type/Tuple.mpp) - Visitor for `std::tuple`
92+
- [`VariadicTemplate`](modules/Type/VariadicTemplate.mpp) - Metaprogramming on variadic parameters
93+
- [`Variant`](modules/Type/Variant.mpp) - Generic print and comparison operators for `std::variant`
94+
95+
### 🧪 Unit Testing
96+
- [`DummyObject`](modules/UnitTest/DummyObject.mpp) - Dummy object that prints construction, destruction, copy and move operations, while counting copies and moves for test verification
97+
- [`UnitTest`](modules/UnitTest/UnitTest.mpp) - Minimal test framework with assertions and filters
98+
99+
### 🧩 Miscellaneous
43100
- Many other functions
44101

45-
The [unit tests](tests) serve as examples of how to use these functions.
102+
---
46103

47104
## Getting Started
48105

49-
A C++26 compliant compiler with std module support and XMake is needed to build CppUtils
106+
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.
107+
108+
### Prerequisites
50109

51-
This library is used in my C++ projects, but you can also use it in your projects.
52-
Just follow the installation steps and consult the documentation for each feature you need.
110+
- A C++26 compliant compiler with std module support
111+
- XMake
53112

54113
### Installation
55114

modules/CppUtils.mpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ export import CppUtils.Language;
1010
export import CppUtils.ChronoLogger;
1111
export import CppUtils.Logger;
1212
export import CppUtils.LogRotate;
13-
export import CppUtils.Math.Concept;
14-
export import CppUtils.Math.Float;
1513
export import CppUtils.Math;
1614
export import CppUtils.Memory;
1715
export import CppUtils.Network;
18-
export import CppUtils.Random;
1916
export import CppUtils.String;
2017
export import CppUtils.System;
2118
export import CppUtils.Terminal;

modules/Math/Float.mpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
export module CppUtils.Math.Float;
22

33
import std;
4-
import CppUtils.Math;
54

65
export namespace CppUtils::Math
76
{
7+
// Plus utile en C++23 (std::abs constexpr)
8+
[[nodiscard]] inline constexpr auto absolute(auto number) -> decltype(auto)
9+
{
10+
if constexpr (std::unsigned_integral<decltype(number)>)
11+
return number;
12+
else if constexpr (std::floating_point<decltype(number)>)
13+
return number < 0 ? -number : number;
14+
else
15+
return number < 0 ?
16+
static_cast<std::make_unsigned_t<decltype(number)>>(-number) :
17+
static_cast<std::make_unsigned_t<decltype(number)>>(number);
18+
}
19+
820
template<std::floating_point Float>
921
[[nodiscard]] inline constexpr auto isEqual(Float lhs, Float rhs, Float epsilon = std::numeric_limits<Float>::epsilon()) noexcept -> bool
1022
{

modules/Math/Math.mpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
export module CppUtils.Math;
22

3-
import std;
4-
5-
export namespace CppUtils::Math
6-
{
7-
// Plus utile en C++23 (std::abs constexpr)
8-
[[nodiscard]] inline constexpr auto absolute(auto number) -> decltype(auto)
9-
{
10-
if constexpr (std::unsigned_integral<decltype(number)>)
11-
return number;
12-
else if constexpr (std::floating_point<decltype(number)>)
13-
return number < 0 ? -number : number;
14-
else
15-
return number < 0 ?
16-
static_cast<std::make_unsigned_t<decltype(number)>>(-number) :
17-
static_cast<std::make_unsigned_t<decltype(number)>>(number);
18-
}
19-
}
3+
export import CppUtils.Math.Concept;
4+
export import CppUtils.Math.Float;
5+
export import CppUtils.Math.Random;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export module CppUtils.Random;
1+
export module CppUtils.Math.Random;
22

33
import std;
44

5-
export namespace CppUtils::Random
5+
export namespace CppUtils::Math
66
{
77
template<std::integral Integer>
88
inline auto getRandomNumberInInterval(Integer min, Integer max) -> Integer
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
export module CppUtils.Language.Mapping;
1+
export module CppUtils.Type.ObjectMapping;
22

33
import std;
44

55
import CppUtils.String;
66

7-
export namespace CppUtils::Language::Mapping
7+
export namespace CppUtils::Type::ObjectMapping
88
{
99
template<class Object, class Property>
1010
struct Attribute final

modules/Type/Type.mpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export import CppUtils.Type.Callable;
44
export import CppUtils.Type.Concept;
55
export import CppUtils.Type.Enum;
66
export import CppUtils.Type.Mapping;
7+
export import CppUtils.Type.ObjectMapping;
78
export import CppUtils.Type.MemberFunction;
89
export import CppUtils.Type.Tuple;
910
export import CppUtils.Type.Utility;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
export module CppUtils.UnitTests.Random;
1+
export module CppUtils.UnitTests.Math.Float;
22

33
import std;
44
import CppUtils;
55

6-
export namespace CppUtils::UnitTest::Random
6+
export namespace CppUtils::UnitTest::Math::Random
77
{
88
inline auto _ = TestSuite{"Random", {"UnitTest"}, [](auto& suite) {
99
suite.addTest("getRandomNumberInInterval", [&] {
1010
constexpr auto min = 1;
1111
constexpr auto max = 10;
1212
for (int i = 0; i < 100; ++i)
1313
{
14-
auto randomNumber = CppUtils::Random::getRandomNumberInInterval(min, max);
14+
auto randomNumber = CppUtils::Math::getRandomNumberInInterval(min, max);
1515
suite.expect(randomNumber >= min and randomNumber <= max);
1616
}
1717
});

tests/Math/Math.mpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export module CppUtils.UnitTests.Math;
1+
export module CppUtils.UnitTests.Math.Random;
22

33
import std;
44
import CppUtils;
55

6-
export namespace CppUtils::UnitTest::Math
6+
export namespace CppUtils::UnitTest::Math::Float
77
{
8-
inline auto _ = TestSuite{"Math", {"UnitTest"}, [](auto& suite) {
8+
inline auto _ = TestSuite{"Math/Float", {"UnitTest"}, [](auto& suite) {
99
suite.addTest("absolute", [&] {
1010
suite.expectEqual(CppUtils::Math::absolute(0), 0u);
1111
suite.expectEqual(CppUtils::Math::absolute(1), 1u);

tests/UnitTests.mpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export import CppUtils.UnitTests.Language.CallStackCompiler;
2222
export import CppUtils.UnitTests.Language.TreeParser;
2323
export import CppUtils.UnitTests.ChronoLogger;
2424
export import CppUtils.UnitTests.Logger;
25-
export import CppUtils.UnitTests.Math;
25+
export import CppUtils.UnitTests.Math.Float;
26+
export import CppUtils.UnitTests.Math.Random;
2627
export import CppUtils.UnitTests.Memory;
2728
export import CppUtils.UnitTests.Network;
28-
export import CppUtils.UnitTests.Random;
2929
export import CppUtils.UnitTests.Stl.Format;
3030
export import CppUtils.UnitTests.String.Utility;
3131
export import CppUtils.UnitTests.System.Error;

0 commit comments

Comments
 (0)