-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more documentation and include doxyfile
Signed-off-by: Stephen Brawner <brawner@gmail.com>
- Loading branch information
Showing
13 changed files
with
552 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# All settings not listed here will use the Doxygen default values. | ||
|
||
PROJECT_NAME = "rcpputils" | ||
PROJECT_NUMBER = master | ||
PROJECT_BRIEF = "C++ API providing common utilities and data structures." | ||
|
||
# Use these lines to include the generated logging_macro.h (update install path if needed) | ||
INPUT = README.md ./include ./docs | ||
USE_MDFILE_AS_MAINPAGE = README.md | ||
RECURSIVE = YES | ||
OUTPUT_DIRECTORY = doc_output | ||
|
||
EXTRACT_ALL = YES | ||
SORT_MEMBER_DOCS = NO | ||
|
||
GENERATE_LATEX = NO | ||
EXCLUDE_SYMBOLS = detail details | ||
|
||
ENABLE_PREPROCESSING = YES | ||
MACRO_EXPANSION = YES | ||
EXPAND_ONLY_PREDEF = YES | ||
PREDEFINED += __declspec(x)= | ||
PREDEFINED += RCPPUTILS_PUBLIC= | ||
PREDEFINED += RCPPUTILS_PUBLIC_TYPE= | ||
|
||
# Tag files that do not exist will produce a warning and cross-project linking will not work. | ||
TAGFILES += "../../../doxygen_tag_files/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/" | ||
# Uncomment to generate tag files for cross-project linking. | ||
#GENERATE_TAGFILE = "../../../doxygen_tag_files/rcpputils.tag" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# rcpputils Features | ||
|
||
This package includes the following convenience functions for generally cross-platform c++ functionality: | ||
* [Assertion functions](#assertion-functions) | ||
* [Clang thread safety annotation macros](#clang-thread-safety-annotation-macros) | ||
* [Endianness helpers](#endianness-helpers) | ||
* [Library discovery](#library-discovery) | ||
* [String helpers](#string-helpers) | ||
* [File system helpers](#file-system-helpers) | ||
* [Type traits helpers](#type-traits-helpers) | ||
* [Visibility macros](#visibility-macros) | ||
|
||
## Assertion Functions {#assertion-functions} | ||
The [rcpputils/asserts.hpp](rcpputils/include/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: | ||
```c++ | ||
ResultType some_function(ArgType arg) | ||
{ | ||
// Check if the required internal state for calling `some_function` is valid. | ||
// There's usually no reason to operate on the input if the state is invalid. | ||
rcpputils::check_true(internal_state.is_valid); | ||
|
||
// Check if the arguments are valid. | ||
// It's usually best practice to only process valid inputs. | ||
rcpputils::require_true(arg.is_valid); | ||
|
||
auto result = do_logic(arg); | ||
|
||
// Assert that the result is valid. | ||
// This will only throw when ran in debug mode if result is invalid. | ||
// Throwing early when invalid may help find points of error when debugging. | ||
rcpputils::assert_true(result.is_valid); | ||
return result | ||
} | ||
``` | ||
## Clang Thread Safety Annotation Macros {#clang-thread-safety-annotation-macros} | ||
the `rcpputils/thread_safety_annotations.hpp` header provides macros for Clang's [Thread Safety Analysis](https://clang.llvm.org/docs/ThreadSafetyAnalysis.html) 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](https://clang.llvm.org/docs/ThreadSafetyAnalysis.html) and the tests in `test/test_basic.cpp` | ||
## Endianness helpers {#endianness-helpers} | ||
In `rcpputils/endian.hpp` | ||
Emulates the features of std::endian if it is not available. See [cppreference](https://en.cppreference.com/w/cpp/types/endian) for more information. | ||
## Library Discovery {#library-discovery} | ||
In `rcpputils/find_library.hpp`: | ||
* `find_library(library_name)`: Namely used for dynamically loading RMW | ||
implementations. | ||
* For dynamically loading user-defined plugins in C++, please use | ||
[`pluginlib`](https://github.com/ros/pluginlib) instead. | ||
## String Helpers {#string-helpers} | ||
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. | ||
## File system helpers {#file-system-helpers} | ||
`rcpputils/filesystem_helper.hpp` provides `std::filesystem`-like functionality on systems that do not yet include those features. See the [cppreference](https://en.cppreference.com/w/cpp/header/filesystem) for more information. | ||
## Type traits helpers {#type-traits-helpers} | ||
`rcpputils/pointer_traits.hpp` provides several type trait definitions for pointers and smart pointers. | ||
## Visibility definitions and macros {#visibility-definitions-and-macros} | ||
`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](https://gcc.gnu.org/wiki/Visibility). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.