| Directory: | ./ |
|---|---|
| File: | include/pinocchio/utils/version.hpp |
| Date: | 2025-02-12 21:03:38 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 8 | 8 | 100.0% |
| Branches: | 15 | 24 | 62.5% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2018 CNRS | ||
| 3 | // | ||
| 4 | |||
| 5 | #ifndef __pinocchio_utils_version_hpp__ | ||
| 6 | #define __pinocchio_utils_version_hpp__ | ||
| 7 | |||
| 8 | #include "pinocchio/config.hpp" | ||
| 9 | |||
| 10 | #include <string> | ||
| 11 | #include <sstream> | ||
| 12 | |||
| 13 | namespace pinocchio | ||
| 14 | { | ||
| 15 | |||
| 16 | /// | ||
| 17 | /// \brief Returns the current version of Pinocchio as a string using | ||
| 18 | /// the following standard: | ||
| 19 | /// PINOCCHIO_MINOR_VERSION.PINOCCHIO_MINOR_VERSION.PINOCCHIO_PATCH_VERSION | ||
| 20 | /// | ||
| 21 | 70 | inline std::string printVersion(const std::string & delimiter = ".") | |
| 22 | { | ||
| 23 |
1/2✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
|
70 | std::ostringstream oss; |
| 24 |
4/8✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 70 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
|
70 | oss << PINOCCHIO_MAJOR_VERSION << delimiter << PINOCCHIO_MINOR_VERSION << delimiter |
| 25 |
1/2✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
|
70 | << PINOCCHIO_PATCH_VERSION; |
| 26 |
1/2✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
|
140 | return oss.str(); |
| 27 | 70 | } | |
| 28 | |||
| 29 | /// | ||
| 30 | /// \brief Checks if the current version of Pinocchio is at least the version provided | ||
| 31 | /// by the input arguments. | ||
| 32 | /// | ||
| 33 | /// \param[in] major_version Major version to check. | ||
| 34 | /// \param[in] minor_version Minor version to check. | ||
| 35 | /// \param[in] patch_version Patch version to check. | ||
| 36 | /// | ||
| 37 | /// \returns true if the current version of Pinocchio is greater than the version provided | ||
| 38 | /// by the input arguments. | ||
| 39 | /// | ||
| 40 | 4 | inline bool checkVersionAtLeast( | |
| 41 | unsigned int major_version, unsigned int minor_version, unsigned int patch_version) | ||
| 42 | { | ||
| 43 | return PINOCCHIO_MAJOR_VERSION > major_version | ||
| 44 |
8/10✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 1 times.
|
4 | || (PINOCCHIO_MAJOR_VERSION >= major_version && (PINOCCHIO_MINOR_VERSION > minor_version || (PINOCCHIO_MINOR_VERSION >= minor_version && PINOCCHIO_PATCH_VERSION >= patch_version))); |
| 45 | } | ||
| 46 | } // namespace pinocchio | ||
| 47 | |||
| 48 | #endif // __pinocchio_utils_version_hpp__ | ||
| 49 |