1 #pragma once 2 3 #include <cstdint> 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 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 51 } // namespace minimum_ship_level 52