rcpputils
master
C++ API providing common utilities and data structures.
|
This package includes the following convenience functions for generally cross-platform c++ functionality:
The rcpputils/asserts.hpp header provides the helper functions:
require_true
: for validating function inputs. Throws an std::invalid_argument
exception if the condition fails.check_true
: for checking states. Throws an rcpputils::InvalidStateException
if the condition fails.assert_true
: for verifying results. Throws an rcpputils::AssertionException
if the condition fails. This function becomes a no-op in release builds.These helper functions can be used to improve readability of C++ functions. Example usage:
the rcpputils/thread_safety_annotations.hpp
header provides macros for Clang's Thread Safety Analysis feature.
The macros allow you to annotate your code, but expand to nothing when using a non-clang compiler, so they are safe for cross-platform use.
To use thread safety annotation in your package (in a Clang+libcxx build), enable the -Wthread-safety
compiler flag.
For example usage, see the documentation of this feature and the tests in test/test_basic.cpp
Emulates the features of std::endian if it is not available. See cppreference for more information.
In rcpputils/find_library.hpp
:
find_library(library_name)
: Namely used for dynamically loading RMW implementations.pluginlib
instead.In rcpputils/join.hpp
and rcpputils/split.hpp
These headers include simple functions for joining a container into a single string and splitting a string into a container of values.
rcpputils/filesystem_helper.hpp
provides std::filesystem
-like functionality on systems that do not yet include those features. See the cppreference for more information.
rcpputils/pointer_traits.hpp
provides several type trait definitions for pointers and smart pointers.
rcpputils/visibility_control.hpp
provides macros and definitions for controlling the visibility of class members. The logic was borrowed and then namespaced from https://gcc.gnu.org/wiki/Visibility.
rcpputils/shared_library.hpp
provides dynamically loads, unloads and get symbols from shared libraries at run-time.