aboutsummaryrefslogtreecommitdiff
path: root/butl/standard-version.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-04-27 21:56:42 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-04-28 12:08:14 +0300
commit55f115d875bf70305ca43e93761395b4329a23a6 (patch)
tree9b1d1f5384a1d267c2d98c849c92fb29ada66ea8 /butl/standard-version.cxx
parent5bb170316ebad036ee5b8b18dee7ce3d09c72df4 (diff)
Add standard_version_constraint::satisfies()
Diffstat (limited to 'butl/standard-version.cxx')
-rw-r--r--butl/standard-version.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/butl/standard-version.cxx b/butl/standard-version.cxx
index 16095c0..3e049e2 100644
--- a/butl/standard-version.cxx
+++ b/butl/standard-version.cxx
@@ -530,4 +530,24 @@ namespace butl
return (min_open ? '(' : '[') + min_version->string () + ' ' +
max_version->string () + (max_open ? ')' : ']');
}
+
+ bool standard_version_constraint::
+ satisfies (const standard_version& v) const noexcept
+ {
+ bool s (true);
+
+ if (min_version)
+ {
+ int i (v.compare (*min_version));
+ s = min_open ? i > 0 : i >= 0;
+ }
+
+ if (s && max_version)
+ {
+ int i (v.compare (*max_version));
+ s = max_open ? i < 0 : i <= 0;
+ }
+
+ return s;
+ }
}