blob: af0c2a233e253741ed9bb5a8f5931b3ea0619ea0 [file] [log] [blame]
Patrick Williams6a85e8a2021-08-27 08:22:29 -05001#pragma once
2
Patrick Williamsb36a3eb2023-05-26 15:03:00 -05003#include <cstdint>
Patrick Williams6a85e8a2021-08-27 08:22:29 -05004#include <string>
5
6namespace minimum_ship_level
7{
8
9/** @brief Version components */
10struct 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 */
20bool 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 */
30void 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 */
39int compare(const Version& a, const Version& b);
40
41} // namespace minimum_ship_level