baptistapedro / arsenalgear-cpp

A library containing general purpose C++ utils.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A library containing general purpose C++ utils

v2.0 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.

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.

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 and compile the library and its prerequisites

./script/install.sh

NOTE: if you are on Cygwin64 you may get an error related to the \r character. To solve it run the dos2unix command on the script (ex: dos2unix install.sh) before running it.

A new library libarsenalgear.a (or libarsenalgear.lib in the Windows case) will be created into the /usr/local/lib folder of your computer and the header files will be installed into /usr/local/include.

NOTE: if you are on MacOS or Windows the paths are slightly different (looks at install.sh).

Prerequisites list:

  • A g++ compiler.
  • C++17 standard.
  • GNU make for compilation.

4) EXTRA: update the repository if needed

./scripts/update.sh
./scripts/install.sh

5) EXTRA: uninstall the repository if needed

./scripts/uninstall.sh

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.

Tests

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

They are installed in the second step of the installation through the install.sh script. Before running test codes you need to compile them:

make

To launch all tests simultaneously:

./test/all_tests.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.

Credits

Project leaders


Gianluca Bianco

About

A library containing general purpose C++ utils.

License:MIT License


Languages

Language:C++ 70.8%Language:Shell 16.2%Language:Makefile 10.4%Language:Python 2.5%