The versatile, all-in-one C++20 utility toolset of R Super Librairie
Strings, maths, colors, system, time, command-line parsing, logging and threads for any C++ project.
Documentation
ยท
Examples
ยท
Report a Bug
RSTools is the foundational utility toolkit of RSLib (R Super Librairie).
Born from the need to stop rewriting the same boilerplate code across different applications, RSTools provides a versatile, highly reusable set of C++ utilities designed to make everyday development faster, safer, and more efficient. Whether you are building a small personal script or a large-scale system architecture, RSTools has you covered with ready-to-use tools.
Include <RST/RST.hpp> for everything, or only the header of a module, such as <RST/string/String.hpp>.
| Module | Namespace | Highlights |
|---|---|---|
| ๐ค String | RST::String |
Trim, split, join, replace, case, number parsing, compile-time hashing |
| ๐งฎ Maths | RST::Maths |
Constants, interpolation, random numbers, 2D/3D vectors, matrices |
| ๐จ Color | RST::Color |
RGBA colors, hex and HSV conversions, blending |
| ๐ป System | RST::System |
CPU, memory, OS and disk info, environment variables, files, paths |
| โฑ๏ธ Time | RST::Time |
Stopwatch, frame timer, date formatting |
| โ๏ธ Parser | RST::Parser |
Command-line parser with subcommands, validation and generated help |
| ๐ Log | RST::Log |
Thread-safe loggers, console and file sinks, patterns, macros |
| ๐งต Threads | RST::Threads |
Thread pool with task priorities |
| โ Test | RSTest.hpp |
Minimal unit-test macros |
| ๐ Crypto | RST::Crypto |
Coming soon |
Requirements: a C++20 compiler (GCC 13+ or Clang 17+) and CMake 3.28+.
Add RSTools to your CMakeLists.txt with FetchContent:
include(FetchContent)
FetchContent_Declare(RSTools
GIT_REPOSITORY https://github.com/NetcatRunner/RSTools.git
GIT_TAG v3.1.0
)
FetchContent_MakeAvailable(RSTools)
target_link_libraries(my_app PRIVATE RST::RST)Or clone it into your project and use add_subdirectory(lib/RSTools) instead of FetchContent.
| CMake option | Default | Description |
|---|---|---|
RST_BUILD_TESTS |
ON for the main project |
Build the unit tests |
RST_BUILD_EXAMPLES |
ON for the main project |
Build the examples |
RST_BUILD_DOCS |
OFF |
Build the API documentation (requires Doxygen) |
Here is a quick glimpse of how easy it is to use RSTools in your main application:
#include <RST/RST.hpp>
int main(int argc, char** argv) {
RST::Parser::ArgParser parser("greet", "Says hello.");
parser.addOption({"-n", "--count"}, "How many greetings").integer().range(1, 10).defaultValue(1);
// --help, --version and invalid arguments end here: nothing throws.
if (auto result = parser.parse(argc, argv); !result) {
result.print();
return result.exitCode();
}
auto log = RST::Log::Registry::init("greet");
const std::string name = RST::String::trimCopy(" RSTools ");
for (int i = 0; i < parser.get<int>("--count").value_or(1); ++i)
log->info("Hello {}!", name);
}More in the examples and the documentation.
RSTools is a community-driven library. Whether you want to fix a bug, add a function, improve the logger or fix a typo, your help is welcome: see CONTRIBUTING.md to get started, and CHANGELOG.md for what changed in each release.
Distributed under the MIT License. See LICENSE for more information.