diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-04-27 19:36:58 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-04-28 12:08:08 +0300 |
commit | 5bb170316ebad036ee5b8b18dee7ce3d09c72df4 (patch) | |
tree | acb30c55637b40e7fb4ff9679cb9187ffa410c68 /butl/standard-version.ixx | |
parent | dad361a3415e88475a78d1b2702133629fb6e548 (diff) |
Add support for standard version earliest pre-release
Diffstat (limited to 'butl/standard-version.ixx')
-rw-r--r-- | butl/standard-version.ixx | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/butl/standard-version.ixx b/butl/standard-version.ixx index b01faef..332eb02 100644 --- a/butl/standard-version.ixx +++ b/butl/standard-version.ixx @@ -8,8 +8,9 @@ namespace butl standard_version ( std::uint16_t e, std::uint64_t v, const std::string& s, - std::uint16_t r) - : standard_version (v, s) + std::uint16_t r, + bool allow_earliest) + : standard_version (v, s, allow_earliest) { // Can't initialize above due to ctor delegating. // @@ -20,9 +21,10 @@ namespace butl inline std::uint16_t standard_version:: major () const noexcept { + std::uint64_t e (version % 10); std::uint64_t v (version / 10); std::uint64_t ab (v % 1000); - if (ab != 0) + if (ab != 0 || e == 1) v += 1000 - ab; return static_cast<std::uint16_t> (v / 1000000000 % 1000); @@ -31,9 +33,10 @@ namespace butl inline std::uint16_t standard_version:: minor () const noexcept { + std::uint64_t e (version % 10); std::uint64_t v (version / 10); std::uint64_t ab (v % 1000); - if (ab != 0) + if (ab != 0 || e == 1) v += 1000 - ab; return static_cast<std::uint16_t> (v / 1000000 % 1000); @@ -42,9 +45,10 @@ namespace butl inline std::uint16_t standard_version:: patch () const noexcept { + std::uint64_t e (version % 10); std::uint64_t v (version / 10); std::uint64_t ab (v % 1000); - if (ab != 0) + if (ab != 0 || e == 1) v += 1000 - ab; return static_cast<std::uint16_t> (v / 1000 % 1000); @@ -74,6 +78,12 @@ namespace butl return abe > 5000; } + inline bool standard_version:: + earliest () const noexcept + { + return version % 10000 == 1 && !snapshot (); + } + inline int standard_version:: compare (const standard_version& v) const noexcept { |