aboutsummaryrefslogtreecommitdiff
path: root/butl
diff options
context:
space:
mode:
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;
+ }
}