40 size_t pos = s.find(
'+');
41 if (pos != string::npos) {
42 vers.build = s.substr(pos + 1);
46 if (pos != string::npos) {
47 vers.pre = s.substr(pos + 1);
52 while (s.size() && (s[0] <
'0' || s[0] >
'9')) s = s.substr(1);
54 int r = sscanf(s.c_str(),
"%d.%d.%d.%d", &vers.major, &vers.minor,
55 &vers.patch, &vers.post);
63 : major(0), minor(0), patch(0), post(0), pre(
""), build(
"") {}
66 std::string pre, std::string build) {
76 if (major != other.major)
return major < other.major;
77 if (minor != other.minor)
return minor < other.minor;
78 if (patch != other.patch)
return patch < other.patch;
79 if (post != other.post)
return post < other.post;
80 return pre < other.pre;
84 return major == other.major && minor == other.minor && patch == other.patch &&
85 post == other.post && pre == other.pre;
89 return !(*
this == other) && !(*
this < other);
93 return (*
this == other) || (*
this < other);
97 return (*
this == other) || (*
this > other);
101 return !(*
this == other);
105 if ((v.major == 0) && (v.minor == 0) && (v.patch == 0))
return s;
107 s << v.major <<
'.' << v.minor;
124 std::ostringstream os;
std::ostream & operator<<(std::ostream &s, const SemanticVersion &v)
Dump version string.
Semantic version encode/decode object.
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.