7 #ifndef IFM3D_DEVICE_SEMVER_H
8 #define IFM3D_DEVICE_SEMVER_H
14 #include <ifm3d/device/module_device.h>
24 const std::optional<std::string> prerelease = std::nullopt,
25 const std::optional<std::string> build_meta = std::nullopt)
29 prerelease(prerelease),
30 build_meta(build_meta)
34 const size_t major_num;
35 const size_t minor_num;
36 const size_t patch_num;
37 const std::optional<std::string> prerelease;
38 const std::optional<std::string> build_meta;
41 operator<(
const SemVer& rhs)
const
45 return major_num < rhs.major_num ||
46 (major_num == rhs.major_num &&
47 (minor_num < rhs.minor_num ||
48 (minor_num == rhs.minor_num && (patch_num < rhs.patch_num))));
52 operator==(
const SemVer& rhs)
const
54 return ((major_num == rhs.major_num) && (minor_num == rhs.minor_num) &&
55 (patch_num == rhs.patch_num) && (prerelease == rhs.prerelease) &&
56 (build_meta == rhs.build_meta));
60 operator!=(
const SemVer& rhs)
const
62 return !(*
this == rhs);
66 operator>=(
const SemVer& rhs)
const
68 return !(*
this < rhs);
72 operator>(
const SemVer& rhs)
const
78 operator<=(
const SemVer& rhs)
const
80 return !(rhs < *
this);
85 operator<<(std::ostream& os,
const SemVer& version)
87 os << version.major_num <<
'.' << version.minor_num <<
'.'
90 if (version.prerelease.has_value())
92 os <<
'-' << version.prerelease.value();
95 if (version.build_meta.has_value())
97 os <<
'+' << version.build_meta.value();
103 static std::optional<SemVer> Parse(
const std::string& version_string);
107 #endif // IFM3D_DEVICE_SEMVER_H