putils
Phiste's C++ Utilities
Stand-alone utility classes
- AbstractFactory Base class for a factory able to create any type in a given typelist calling
make<T>()
. - CellularAutomaton Simple cellular automaton implementation
- CLI Simple and extensible Command-Line Interface.
- Directory An abstraction to Unix and Windows directories, which lets you iterate through a directory and get information about each file.
- JSON JSON lexer and pretty-printer
- NamedPipe Abstraction to named pipes
- Observable A minimalistic (but greatly sufficient) implementation of the Observer pattern.
- OperatorForward Mix-in class which lets you forward all operators to a given member.
- Point Simple abstraction to a 2D or 3D point/rectangle.
- Process Abstraction to a process (useful to run system commands and send them input/get their output)
- RAII A class template able to perform RAII on any type.
- ThreadPool Thread pool implementation
- Timer Simple timer based on std::chrono.
Standard library replacements
- string: fixed-size drop-in replacement for
std::string
- vector: fixed-size drop-in replacement for
std::vector
- function: fixed-size drop-in replacement for
std::function
Packages
- Lua (enabled with the PUTILS_BUILD_LUA CMake option)
- Python (enabled with the PUTILS_BUILD_PYTHON CMake option)
- Mediator (enabled with the PUTILS_BUILD_MEDIATOR CMake option)
- Meta
- PluginManager
- PSE (enabled with the PUTILS_BUILD_PSE CMake option)
- Reflection
PSE makes use of Conan for dependency management. The necessary packages will be automatically downloaded when you run CMake, but Conan must be installed separately by running:
pip install conan
Function-only headers
- anonymous_variable.hpp: macro to define an anonymous variable
- casts.hpp: static and dynamic casts for std::unique_ptr
- chop.hpp: function removing any newline and carriage return characters from the end of a string.
- concat.hpp: function taking any number of parameters and concatenating them into a string.
- erase.hpp: function taking a container and a value and erasing the value from the container.
- file_extension.hpp: function returning a file's extension
- fwd.hpp: macro which calls std::forward for the correct type
- get_current_dir.hpp: function which returns the current working directory as a string
- get_last_error_as_string.hpp: function for Windows
- go_to_bin_dir.hpp: function which takes
argv[0]
as parameter and changes the current working directory to that containing the executed file. - hash.hpp: Pre-defined hashers for enums and pairs
- lengthof.hpp: macro returning the length of an array
- lock_and_run.hpp: function which takes a mutex, a function and its parameters. Creates a scoped lock for the mutex and runs the function.
- members.hpp: help with class members
- rand.hpp: function using C++ 11's random number generation facilities
- read_stream.hpp: function which extracts an entire std::istream to a std::string
- regex.hpp: utilities to easily construct and match regexes through literal operators
- remove_if.hpp: function taking a container and a predicate and calling std::remove_if
- same_sign.hpp: function indicating whether two scalars have the same sign
- sign.hpp: function returning -1, 0 or 1 depending on the sign of the parameter
- to_string.hpp: uses a std::stringstream to serialize an object
- traits.hpp: type traits
- url.hpp: URL encoder and decoder
- with.hpp:
with
macro mimicking the Kotlin construct
CMake tools
- conan: lets you run conan commands directly from cmake
- conan_helper: provides a helper macro to simply list conan dependencies
- cotire: lets you easily set up precompiled-header and single-compilation-unit compilations to speed up builds