Skip to content

JustWhit3/arsenalgear-cpp

Repository files navigation

A library containing general purpose C++ utils

v2.1 license C++17/20
code size repo size total lines
codeq docgen


Table of contents

Introduction

This is a C++17/20 library containing a set of generic utils I developed for other projects. There are several sub-headers / modules related to the various topics (math, iostream and others). Existing tools are constantly updated and new ones are added once their development is required for other projects. Some projects in which I am using this library are, for example: osmanip and SAFD-algorithm.

This library is fully type-safe with automatic memory management, with minimal and indispensable dependencies.

It can be installed from source or via vcpkg. See this section for further details.

If you want to use this library please cite it following this citation template.

If you want to contribute to the repository, see this document before.

If you plan to use this library please tell me so I can add your project to the list of known projects which use this library

Code documentation is generated using Doxygen and can be accessed here.

The software is and will stay free, but if you want to support me with a donation it would be really appreciated!

Buy Me A Coffee

Architectures support

Operating systems

  • Linux
    • Ubuntu (tested)
  • Windows
    • Cygwin64 (tested)
    • MSYS2 (tested)
    • MinGW (tested)
    • WSL (tested)
  • MacOS

Compilers

  • gcc:
    • C++17: 7/8/9/10/11/12
    • C++20: 10/11/12
  • clang:
    • C++17: 5/6/7/8/9/10/11/12/13/14/15
    • C++20: 9/10/11/12/13/14/15
  • MSVC:
    • C++17: 19 (only this one tested)
    • C++20: //

Install and use

Install

Steps to be reproduced:

1) Download one of the releases of the repository.

2) Unzip and enter the downloaded repository directory.

3) Install into the system with these command:

Set the building directory:

cmake -B build

Install:

sudo cmake --build build --target install

⚠️ sudo is not required on Windows.

Prerequisites are minimal:

  • g++ (like gcc, clang or MSVC) compiler.
  • C++17 standard at least.
  • CMake (v 3.15 at least).

Use in your device

Once you have installed the library you can freely use it in one of your C++ projects by including one or more of the modules:

#include <arsenalgear/module_name.hpp>

To compile it you have simply add the -larsenalgear compilation flag.

NOTE: if you are on Windows and didn't install the headers and libraries in a system standard path you probably need to add also the -I\path\to\include and -L\path\to\lib flags.

Use with CMake

To get an installed version of the library:

find_package( arsenalgear )

then, to link it to a target:

target_link_libraries( ${TARGET} arsenalgear::arsenalgear )

To avoid tests compilation:

set( ARSENALGEAR_TESTS OFF )

Package managers

This is the list of available package managers for arsenalgear:

Tests

Tests are produced using -Wall -Wextra -pedantic flags. To check them you need some prerequisites:

Before running test codes you need to compile them:

cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build

To launch all tests simultaneously:

./test/all_tests.sh

EXTRA: to check that only the needed headers are include use this script:

./test/IWYU.sh

List of features

Constants

  • null_string: template variable to define the null string.
  • empty_space: template variable to define the empty space.

Math

  • roundoff: function use to round the value a floating point variable.
  • IsInBounds: functions used to check if a variable lies in a range.
  • parsed_f: functions used to parse a mathematical function.

Operators

Stream

  • null_stream: definition of the null stream.
  • savebuf: class used to store the output of an output stream (useful for testing).
  • select_cout: struct used to define an object which can be a different std::cout objects based on its char type.
  • select_cin: struct used to define an object which can be a different std::cin objects based on its char type.

System

  • getCommandOut: function used to print the output of a command in the console.

Utils

  • multi: function used to multiply a string for n times.
  • split_string: function used to split a string based on a certain reges.
  • except_error_func: function used to throw customized exception error.
  • isFloatingPoint: function used to check if an expression is a floating point or not.
  • one: function used to find the incremented unit of a loop.
  • StringConverter: function used to convert a char string into other char types (wchar_t, char16_t, etc...).
  • is_escape: function used to check if a string contain an ANSI escape sequence or not.

Containers

Type

  • is_pointer_to_const_char: function used to check if a string is a pointer to const char.
  • is_str: function used to check if a string is an std::string object.
  • is_streamable: struct used to check if a type is streamable to a stream or not.
  • is_any: function used to check if a type is in a list or not. Very useful to perform this operation with parameter packs.

List of known projects which use this library

Credits

Project leaders


Gianluca Bianco

Other Contributors


oz_10

SpaceIm

Stargazers over time

Stargazers over time