Patrick Williams | 6a85e8a | 2021-08-27 08:22:29 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Williams | b36a3eb | 2023-05-26 15:03:00 -0500 | [diff] [blame] | 3 | #include <cstdint> |
Patrick Williams | 6a85e8a | 2021-08-27 08:22:29 -0500 | [diff] [blame] | 4 | #include <string> |
| 5 | |
| 6 | namespace minimum_ship_level |
| 7 | { |
| 8 | |
| 9 | /** @brief Version components */ |
| 10 | struct Version |
| 11 | { |
| 12 | uint8_t major; |
| 13 | uint8_t minor; |
| 14 | uint8_t rev; |
| 15 | }; |
| 16 | |
| 17 | /** @brief Verify if the current BMC version meets the min ship level |
| 18 | * @return true if the verification succeeded, false otherwise |
| 19 | */ |
| 20 | bool verify(const std::string& versionStr); |
| 21 | |
| 22 | /** @brief Parse the version components into a struct |
| 23 | * @details User passes a version string in regex format (REGEX_BMC_MSL) |
| 24 | * at compilation time, this value is break down by parse function to allocate |
| 25 | * a struct so it can be compared position by position against the (BMC_MSL) |
| 26 | * also defined at compile time. |
| 27 | * @param[in] versionStr - The version string to be parsed |
| 28 | * @param[out] version - The version struct to be populated |
| 29 | */ |
| 30 | void parse(const std::string& versionStr, Version& version); |
| 31 | |
| 32 | /** @brief Compare the versions provided |
| 33 | * @param[in] a - The first version to compare |
| 34 | * @param[in] b - The second version to compare |
| 35 | * @return 1 if a > b |
| 36 | * 0 if a = b |
| 37 | * -1 if a < b |
| 38 | */ |
| 39 | int compare(const Version& a, const Version& b); |
| 40 | |
Adriana Kobylak | 30352a6 | 2024-04-09 09:25:36 -0500 | [diff] [blame] | 41 | /** @brief Check if the minimum ship level option is enabled |
| 42 | * @return true if enabled, false otherwise |
| 43 | */ |
| 44 | bool enabled(); |
| 45 | |
| 46 | /** @brief Get the minimum version |
| 47 | * @return[out] msl - Minimum version string |
| 48 | */ |
| 49 | std::string getMinimumVersion(); |
| 50 | |
Patrick Williams | 6a85e8a | 2021-08-27 08:22:29 -0500 | [diff] [blame] | 51 | } // namespace minimum_ship_level |