12#ifndef __FDP_SEMVER_HXX__
13#define __FDP_SEMVER_HXX__
20namespace FairDataPipeline {
81 version(
unsigned int major,
unsigned int minor,
unsigned int patch,
83 std::string meta_data =
"")
84 : major_(major), minor_(minor), patch_(patch), meta_tag_(tag),
85 tag_v_(tag_v), meta_data_(meta_data) {}
87 version(
const std::string version_str);
90 : major_(v.major_), minor_(v.minor_), patch_(v.patch_),
91 meta_tag_(v.meta_tag_), tag_v_(v.tag_v_), meta_data_(v.meta_data_) {}
93 void bump_major() { major_ += 1; }
94 void bump_minor() { minor_ += 1; }
95 void bump_patch() { patch_ += 1; }
117 std::string to_string()
const {
118 std::string out_str_;
120 out_str_ += std::to_string(major_) +
".";
121 out_str_ += std::to_string(minor_) +
".";
122 out_str_ += std::to_string(patch_);
125 out_str_ +=
"-" + get_tag_str();
128 out_str_ += std::to_string(tag_v_);
131 if (!meta_data_.empty()) {
132 out_str_ +=
"+" + meta_data_;
138 friend std::ostream &operator<<(std::ostream &os,
const version &v) {
144 if (v1.major_ < v2.major_)
146 else if (v2.major_ < v1.major_)
148 if (v1.minor_ < v2.minor_)
150 else if (v2.minor_ < v1.minor_)
152 if (v1.patch_ < v2.patch_)
154 else if (v2.patch_ < v1.patch_)
156 if (v1.meta_tag_ < v2.meta_tag_)
158 else if (v2.meta_tag_ < v1.meta_tag_)
160 if (v1.tag_v_ < v2.tag_v_)
162 else if (v2.tag_v_ < v1.tag_v_)
172 bool same_ = v1.major_ == v2.major_;
173 same_ = same_ && (v1.minor_ == v2.minor_);
174 same_ = same_ && (v1.patch_ == v2.patch_);
175 same_ = same_ && (v1.meta_tag_ == v2.meta_tag_);
176 same_ = same_ && (v1.tag_v_ == v2.tag_v_);
177 same_ = same_ && (v1.meta_data_ == v2.meta_data_);
186 return (v1 == v2) || v1 < v2;
190 return (v1 == v2) || v1 > v2;
194 unsigned int major_ = 0;
195 unsigned int minor_ = 1;
196 unsigned int patch_ = 0;
198 unsigned int tag_v_ = 1E9;
199 std::string meta_data_ =
"";
200 std::string get_tag_str()
const;
class describing the semantic version of an object
Definition: semver.hxx:54
version()=default
Construct a new version with the default start value of 0.1.0
version(unsigned int major, unsigned int minor, unsigned int patch, meta_tag tag=meta_tag::RELEASE, unsigned int tag_v=1E9, std::string meta_data="")
Construct a new version from integer representation.
Definition: semver.hxx:81
meta_tag
the allowed tags for versions describing version state
Definition: semver.hxx:39