blob: 9fd66953925193e79c78289a70e631211106aea0 [file] [log] [blame]
Miguel Gomez21dad042020-06-26 20:54:48 +00001#pragma once
2
3#include <string>
4
5namespace minimum_ship_level
6{
7
8/** @brief Version components */
9struct 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 */
19bool 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 */
29void 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 */
38int compare(const Version& a, const Version& b);
39
40} // namespace minimum_ship_level