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