remove ugly id_to_str param in idvaluemap and str_to_str

This commit is contained in:
Maxime Coste 2012-06-25 19:11:13 +02:00
parent ccec35f88c
commit cffb895797
6 changed files with 9 additions and 16 deletions

View File

@ -41,13 +41,13 @@ FilterGroup& FilterGroup::get_group(const String& id)
CandidateList FilterGroup::complete_id(const String& prefix, CandidateList FilterGroup::complete_id(const String& prefix,
size_t cursor_pos) size_t cursor_pos)
{ {
return m_filters.complete_id<str_to_str>(prefix, cursor_pos); return m_filters.complete_id(prefix, cursor_pos);
} }
CandidateList FilterGroup::complete_group_id(const String& prefix, CandidateList FilterGroup::complete_group_id(const String& prefix,
size_t cursor_pos) size_t cursor_pos)
{ {
return m_filters.complete_id_if<str_to_str>( return m_filters.complete_id_if(
prefix, cursor_pos, prefix, cursor_pos,
[](std::pair<String, FilterFunc>& func) [](std::pair<String, FilterFunc>& func)
{ return func.second.target<FilterGroup>() != nullptr; }); { return func.second.target<FilterGroup>() != nullptr; });

View File

@ -33,7 +33,7 @@ void FilterRegistry::add_filter_to_group(FilterGroup& group,
CandidateList FilterRegistry::complete_filter(const String& prefix, CandidateList FilterRegistry::complete_filter(const String& prefix,
size_t cursor_pos) size_t cursor_pos)
{ {
return m_factories.complete_id<str_to_str>(prefix, cursor_pos); return m_factories.complete_id(prefix, cursor_pos);
} }
} }

View File

@ -41,13 +41,13 @@ HighlighterGroup& HighlighterGroup::get_group(const String& id)
CandidateList HighlighterGroup::complete_id(const String& prefix, CandidateList HighlighterGroup::complete_id(const String& prefix,
size_t cursor_pos) size_t cursor_pos)
{ {
return m_highlighters.complete_id<str_to_str>(prefix, cursor_pos); return m_highlighters.complete_id(prefix, cursor_pos);
} }
CandidateList HighlighterGroup::complete_group_id(const String& prefix, CandidateList HighlighterGroup::complete_group_id(const String& prefix,
size_t cursor_pos) size_t cursor_pos)
{ {
return m_highlighters.complete_id_if<str_to_str>( return m_highlighters.complete_id_if(
prefix, cursor_pos, prefix, cursor_pos,
[](std::pair<String, HighlighterFunc>& func) [](std::pair<String, HighlighterFunc>& func)
{ return func.second.target<HighlighterGroup>() != nullptr; }); { return func.second.target<HighlighterGroup>() != nullptr; });

View File

@ -35,7 +35,7 @@ void HighlighterRegistry::add_highlighter_to_group(Window& window,
CandidateList HighlighterRegistry::complete_highlighter(const String& prefix, CandidateList HighlighterRegistry::complete_highlighter(const String& prefix,
size_t cursor_pos) size_t cursor_pos)
{ {
return m_factories.complete_id<str_to_str>(prefix, cursor_pos); return m_factories.complete_id(prefix, cursor_pos);
} }
} }

View File

@ -63,8 +63,7 @@ public:
} }
} }
template<String (*id_to_string)(const _Id&), template<typename _Condition>
typename _Condition>
CandidateList complete_id_if(const String& prefix, CandidateList complete_id_if(const String& prefix,
size_t cursor_pos, size_t cursor_pos,
_Condition condition) _Condition condition)
@ -76,18 +75,17 @@ public:
if (not condition(value)) if (not condition(value))
continue; continue;
String id_str = id_to_string(value.first); String id_str = value.first;
if (id_str.substr(0, real_prefix.length()) == real_prefix) if (id_str.substr(0, real_prefix.length()) == real_prefix)
result.push_back(std::move(id_str)); result.push_back(std::move(id_str));
} }
return result; return result;
} }
template<String (*id_to_string)(const _Id&)>
CandidateList complete_id(const String& prefix, CandidateList complete_id(const String& prefix,
size_t cursor_pos) size_t cursor_pos)
{ {
return complete_id_if<id_to_string>( return complete_id_if(
prefix, cursor_pos, [](const value_type&) { return true; }); prefix, cursor_pos, [](const value_type&) { return true; });
} }

View File

@ -117,11 +117,6 @@ bool operator== (const std::unique_ptr<T>& lhs, T* rhs)
return lhs.get() == rhs; return lhs.get() == rhs;
} }
inline String str_to_str(const String& str)
{
return str;
}
} }
#endif // utils_hh_INCLUDED #endif // utils_hh_INCLUDED