RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
RSTools

๐Ÿ› ๏ธ RSTools (RSLib)

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
C++20 CMake 3.28+ Supported Platforms
Latest Release License: MIT Build Status

๐Ÿ“– Table of Contents


๐Ÿš€ About

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.

๐Ÿงฐ Modules

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

๐Ÿ›  Getting Started

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)

๐Ÿ’ป Usage Example

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);
}
static std::shared_ptr< Logger > init(std::string_view appName="app", LogLevel level=LogLevel::Info, bool toFile=false)
Quick setup: logs from level to the console, and to <appName>.log if toFile is true.
Command-line parser with flags, options, positionals, subcommands and generated help.
Definition ArgParser.hpp:34
std::string trimCopy(std::string_view str, std::string_view chars=Whitespace)

More in the examples and the documentation.

๐Ÿค Community & Contributing

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.

๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for more information.