32 #include "model/semantic_vers.h"
41 size_t pos = s.find(
'+');
42 if (pos != string::npos) {
43 vers.build = s.substr(pos + 1);
47 if (pos != string::npos) {
48 vers.pre = s.substr(pos + 1);
51 int r = sscanf(s.c_str(),
"%d.%d.%d.%d", &vers.major, &vers.minor,
52 &vers.patch, &vers.post);
60 : major(0), minor(0), patch(0), post(0), pre(
""), build(
"") {}
63 std::string pre, std::string build) {
73 if (major != other.major)
return major < other.major;
74 if (minor != other.minor)
return minor < other.minor;
75 if (patch != other.patch)
return patch < other.patch;
76 if (post != other.post)
return post < other.post;
77 return pre < other.pre;
81 return major == other.major && minor == other.minor && patch == other.patch &&
82 post == other.post && pre == other.pre;
86 return !(*
this == other) && !(*
this < other);
90 return (*
this == other) || (*
this < other);
94 return (*
this == other) || (*
this > other);
98 return !(*
this == other);
102 if ((v.major == 0) && (v.minor == 0) && (v.patch == 0))
105 s << v.major <<
'.' << v.minor;
122 std::ostringstream os;
Versions uses a modified semantic versioning scheme: major.minor.revision.post-tag+build.
SemanticVersion()
Construct a "0.0.0.0" version.
static SemanticVersion parse(std::string s)
Parse a version string, sets major == -1 on errors.
std::string to_string()
Return printable representation.