diff options
author | 2011-04-04 14:54:38 +0100 | |
---|---|---|
committer | 2011-04-04 14:54:38 +0100 | |
commit | 5c950263e9ea902e86030b5fd3a8c6b0760e7539 (patch) | |
tree | eff1ba8b39ba44dc332f470c9717a896813b7b7c /paludis | |
parent | b3d3ba6393d47447c9ee5fe444683d2409b3cd2d (diff) | |
download | paludis-5c950263e9ea902e86030b5fd3a8c6b0760e7539.tar.gz paludis-5c950263e9ea902e86030b5fd3a8c6b0760e7539.tar.xz |
[.key~value] operator
Diffstat (limited to 'paludis')
-rw-r--r-- | paludis/package_dep_spec_constraint.cc | 94 | ||||
-rw-r--r-- | paludis/package_dep_spec_constraint.se | 1 | ||||
-rw-r--r-- | paludis/user_dep_spec.cc | 3 |
3 files changed, 92 insertions, 6 deletions
diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc index 5db0b2b47..68b163959 100644 --- a/paludis/package_dep_spec_constraint.cc +++ b/paludis/package_dep_spec_constraint.cc @@ -481,6 +481,8 @@ namespace { case kco_equals: return pattern == stringify(k.value().seconds()); + case kco_tilde: + return std::string::npos != stringify(k.value().seconds()).find(pattern); case kco_less_than: return k.value().seconds() < destringify<time_t>(pattern); case kco_greater_than: @@ -495,22 +497,74 @@ namespace bool visit(const MetadataValueKey<std::string> & k) const { - return pattern == stringify(k.value()); + switch (op) + { + case kco_equals: + return pattern == stringify(k.value()); + case kco_tilde: + return std::string::npos != stringify(k.value()).find(pattern); + case kco_less_than: + case kco_greater_than: + case kco_question: + case last_kco: + break; + } + + return false; } bool visit(const MetadataValueKey<SlotName> & k) const { - return pattern == stringify(k.value()); + switch (op) + { + case kco_equals: + return pattern == stringify(k.value()); + case kco_tilde: + return std::string::npos != stringify(k.value()).find(pattern); + case kco_less_than: + case kco_greater_than: + case kco_question: + case last_kco: + break; + } + + return false; } bool visit(const MetadataValueKey<FSPath> & k) const { - return pattern == stringify(k.value()); + switch (op) + { + case kco_equals: + return pattern == stringify(k.value()); + case kco_tilde: + return std::string::npos != stringify(k.value()).find(pattern); + case kco_less_than: + case kco_greater_than: + case kco_question: + case last_kco: + break; + } + + return false; } bool visit(const MetadataValueKey<bool> & k) const { - return pattern == stringify(k.value()); + switch (op) + { + case kco_equals: + return pattern == stringify(k.value()); + case kco_tilde: + return std::string::npos != stringify(k.value()).find(pattern); + case kco_less_than: + case kco_greater_than: + case kco_question: + case last_kco: + break; + } + + return false; } bool visit(const MetadataValueKey<long> & k) const @@ -519,6 +573,8 @@ namespace { case kco_equals: return pattern == stringify(k.value()); + case kco_tilde: + return std::string::npos != stringify(k.value()).find(pattern); case kco_less_than: return k.value() < destringify<long>(pattern); case kco_greater_than: @@ -551,6 +607,7 @@ namespace case kco_greater_than: case kco_question: + case kco_tilde: case last_kco: break; } @@ -560,7 +617,20 @@ namespace bool visit(const MetadataValueKey<std::shared_ptr<const PackageID> > & k) const { - return pattern == stringify(*k.value()); + switch (op) + { + case kco_equals: + return pattern == stringify(*k.value()); + case kco_tilde: + return std::string::npos != stringify(*k.value()).find(pattern); + case kco_less_than: + case kco_greater_than: + case kco_question: + case last_kco: + break; + } + + return false; } bool visit(const MetadataSpecTreeKey<DependencySpecTree> & s) const @@ -572,6 +642,7 @@ namespace case kco_less_than: return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -590,6 +661,7 @@ namespace case kco_less_than: return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -608,6 +680,7 @@ namespace case kco_less_than: return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -626,6 +699,7 @@ namespace case kco_less_than: return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -644,6 +718,7 @@ namespace case kco_less_than: return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -662,6 +737,7 @@ namespace case kco_less_than: return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -680,6 +756,7 @@ namespace case kco_less_than: return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -698,6 +775,7 @@ namespace case kco_less_than: return s.value()->top()->accept_returning<bool>(SpecTreeSearcher(env, id, pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -717,6 +795,7 @@ namespace return s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(), StringifyEqual(pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -738,6 +817,7 @@ namespace indirect_iterator(s.value()->end()), StringifyEqual(pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -757,6 +837,7 @@ namespace return s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(), StringifyEqual(pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -776,6 +857,7 @@ namespace return s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(), StringifyEqual(pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -800,6 +882,7 @@ namespace return s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(), StringifyEqual(pattern)); + case kco_tilde: case kco_greater_than: case kco_question: case last_kco: @@ -1024,6 +1107,7 @@ KeyConstraint::as_raw_string() const switch (operation()) { case kco_equals: s << "=" << pattern(); break; + case kco_tilde: s << "~" << pattern(); break; case kco_less_than: s << "<" << pattern(); break; case kco_greater_than: s << ">" << pattern(); break; case kco_question: s << "?"; break; diff --git a/paludis/package_dep_spec_constraint.se b/paludis/package_dep_spec_constraint.se index 54982f847..f224c1b1a 100644 --- a/paludis/package_dep_spec_constraint.se +++ b/paludis/package_dep_spec_constraint.se @@ -6,6 +6,7 @@ make_enum_KeyConstraintOperation() prefix kco key kco_equals "An = constraint" + key kco_tilde "A ~ constraint" key kco_less_than "A less than constraint" key kco_greater_than "A greater than constraint" key kco_question "A question constraint" diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc index 37f1c12c3..7f8887384 100644 --- a/paludis/user_dep_spec.cc +++ b/paludis/user_dep_spec.cc @@ -326,7 +326,7 @@ paludis::user_version_spec_options() std::tuple<KeyConstraintKeyType, std::string, KeyConstraintOperation, std::string> paludis::parse_user_key_constraint(const std::string & s) { - std::string::size_type p(s.find_first_of("=<>?")); + std::string::size_type p(s.find_first_of("=<>?~")); if (std::string::npos == p) throw PackageDepSpecError("[." + s + "] contains no operator"); @@ -348,6 +348,7 @@ paludis::parse_user_key_constraint(const std::string & s) switch (s.at(p)) { case '=': op = kco_equals; break; + case '~': op = kco_tilde; break; case '<': op = kco_less_than; break; case '>': op = kco_greater_than; break; default: |