From f7dc4934b04c062b1ce8aad09725a30707255e69 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 11 Jan 2019 23:56:54 +0300 Subject: Improve standard version API --- libbutl/standard-version.ixx | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'libbutl/standard-version.ixx') 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 (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 (ab); + inline optional standard_version:: + pre_release () const noexcept + { + return release () || stub () + ? nullopt + : optional (version / 10 % 1000); } - inline bool standard_version:: + inline optional standard_version:: alpha () const noexcept { - std::uint64_t abe (version % 10000); - return abe > 0 && abe < 5000 && !stub (); + optional pr (pre_release ()); + return pr && *pr < 500 ? pr : nullopt; } - inline bool standard_version:: + inline optional standard_version:: beta () const noexcept { - std::uint64_t abe (version % 10000); - return abe > 5000 && !stub (); + optional pr (pre_release ()); + return pr && *pr >= 500 ? optional (*pr - 500) : nullopt; + } + + inline bool standard_version:: + final () const noexcept + { + return release () || !(snapshot () || stub ()); } inline bool standard_version:: -- cgit v1.1