aboutsummaryrefslogtreecommitdiff
path: root/butl
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
parent5bb170316ebad036ee5b8b18dee7ce3d09c72df4 (diff)
Add standard_version_constraint::satisfies()
Diffstat (limited to 'butl')
-rw-r--r--butl/standard-version3
-rw-r--r--butl/standard-version.cxx20
2 files changed, 23 insertions, 0 deletions
diff --git a/butl/standard-version b/butl/standard-version
index 0c7b9bc..59056ac 100644
--- a/butl/standard-version
+++ b/butl/standard-version
@@ -181,6 +181,9 @@ namespace butl
bool
empty () const noexcept {return !min_version && !max_version;}
+
+ bool
+ satisfies (const standard_version&) const noexcept;
};
inline bool
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;
+ }
}