diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-01-11 23:56:54 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-01-13 20:26:46 +0300 |
commit | f7dc4934b04c062b1ce8aad09725a30707255e69 (patch) | |
tree | 08e147151569dce6475d1b60e35ebd0df4309253 /libbutl/standard-version.ixx | |
parent | 17be80bea48c942c9496d079e07bc15a27a5d7a2 (diff) |
Improve standard version API
Diffstat (limited to 'libbutl/standard-version.ixx')
-rw-r--r-- | libbutl/standard-version.ixx | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/libbutl/standard-version.ixx b/libbutl/standard-version.ixx index 66dccba..7e282f8 100644 --- a/libbutl/standard-version.ixx +++ b/libbutl/standard-version.ixx @@ -40,28 +40,38 @@ namespace butl return static_cast<std::uint16_t> (v / 1000 % 1000); } - inline std::uint16_t standard_version:: - pre_release () const noexcept + inline bool standard_version:: + release () const noexcept { - std::uint64_t ab (version / 10 % 1000); - if (ab >= 500) - ab -= 500; + return version % 10000 == 0; + } - return static_cast<std::uint16_t> (ab); + inline optional<std::uint16_t> standard_version:: + pre_release () const noexcept + { + return release () || stub () + ? nullopt + : optional<std::uint16_t> (version / 10 % 1000); } - inline bool standard_version:: + inline optional<std::uint16_t> standard_version:: alpha () const noexcept { - std::uint64_t abe (version % 10000); - return abe > 0 && abe < 5000 && !stub (); + optional<std::uint16_t> pr (pre_release ()); + return pr && *pr < 500 ? pr : nullopt; } - inline bool standard_version:: + inline optional<std::uint16_t> standard_version:: beta () const noexcept { - std::uint64_t abe (version % 10000); - return abe > 5000 && !stub (); + optional<std::uint16_t> pr (pre_release ()); + return pr && *pr >= 500 ? optional<std::uint16_t> (*pr - 500) : nullopt; + } + + inline bool standard_version:: + final () const noexcept + { + return release () || !(snapshot () || stub ()); } inline bool standard_version:: |