blob: 086c99957ed78e2b1ec417d32c3d40229a297e02 [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
Adriana Kobylak30352a62024-04-09 09:25:36 -050041/** @brief Check if the minimum ship level option is enabled
42 * @return true if enabled, false otherwise
43 */
44bool enabled();
45
46/** @brief Get the minimum version
47 * @return[out] msl - Minimum version string
48 */
49std::string getMinimumVersion();
50
Patrick Williams6a85e8a2021-08-27 08:22:29 -050051} // namespace minimum_ship_level