diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-01-19 20:52:08 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-01-19 20:52:08 +0000 |
| commit | ce6b4c2cc4b7728a5b5e6952072ad571f58fff74 (patch) | |
| tree | f51e5e6dbcb2a01065a9fe926fed004efe1e6011 /src | |
| parent | 2824bd9a464521999f7f68f4f08356ac9e69538e (diff) | |
idvaluemap: complete_id_if method for conditional id completion
Diffstat (limited to 'src')
| -rw-r--r-- | src/idvaluemap.hh | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/idvaluemap.hh b/src/idvaluemap.hh index 7f7dc7de..387e6fb0 100644 --- a/src/idvaluemap.hh +++ b/src/idvaluemap.hh @@ -63,14 +63,19 @@ public: } } - template<std::string (*id_to_string)(const _Id&)> - CandidateList complete_id(const std::string& prefix, - size_t cursor_pos) + template<std::string (*id_to_string)(const _Id&), + typename _Condition> + CandidateList complete_id_if(const std::string& prefix, + size_t cursor_pos, + _Condition condition) { std::string real_prefix = prefix.substr(0, cursor_pos); CandidateList result; for (auto& value : m_content) { + if (not condition(value)) + continue; + std::string id_str = id_to_string(value.first); if (id_str.substr(0, real_prefix.length()) == real_prefix) result.push_back(std::move(id_str)); @@ -78,6 +83,14 @@ public: return result; } + template<std::string (*id_to_string)(const _Id&)> + CandidateList complete_id(const std::string& prefix, + size_t cursor_pos) + { + return complete_id_if<id_to_string>( + prefix, cursor_pos, [](const value_type&) { return true; }); + } + iterator begin() { return m_content.begin(); } iterator end() { return m_content.end(); } const_iterator begin() const { return m_content.begin(); } |
