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);
53 while (s.size() && (s[0] <
'0' || s[0] >
'9')) s = s.substr(1);
55 int r = sscanf(s.c_str(),
"%d.%d.%d.%d", &vers.major, &vers.minor,
56 &vers.patch, &vers.post);
64 : major(0), minor(0), patch(0), post(0), pre(
""), build(
"") {}
67 std::string pre, std::string build) {
77 if (major != other.major)
return major < other.major;
78 if (minor != other.minor)
return minor < other.minor;
79 if (patch != other.patch)
return patch < other.patch;
80 if (post != other.post)
return post < other.post;
81 return pre < other.pre;
85 return major == other.major && minor == other.minor && patch == other.patch &&
86 post == other.post && pre == other.pre;
90 return !(*
this == other) && !(*
this < other);
94 return (*
this == other) || (*
this < other);
98 return (*
this == other) || (*
this > other);
102 return !(*
this == other);
106 if ((v.major == 0) && (v.minor == 0) && (v.patch == 0))
return s;
108 s << v.major <<
'.' << v.minor;
125 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.