rename idvaluemap to id_map, remove Id template param, use String
This commit is contained in:
parent
d27548dd15
commit
9a6712e56b
|
@ -2,7 +2,7 @@
|
||||||
#define function_group_hh_INCLUDED
|
#define function_group_hh_INCLUDED
|
||||||
|
|
||||||
#include "exception.hh"
|
#include "exception.hh"
|
||||||
#include "idvaluemap.hh"
|
#include "id_map.hh"
|
||||||
#include "string.hh"
|
#include "string.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
|
@ -58,7 +58,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
idvaluemap<String, Function> m_functions;
|
id_map<Function> m_functions;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define function_registry_h_INCLUDED
|
#define function_registry_h_INCLUDED
|
||||||
|
|
||||||
#include "completion.hh"
|
#include "completion.hh"
|
||||||
#include "idvaluemap.hh"
|
#include "id_map.hh"
|
||||||
#include "string.hh"
|
#include "string.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
|
@ -38,7 +38,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
idvaluemap<String, FunctionType> m_functions;
|
id_map<FunctionType> m_functions;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef hook_manager_hh_INCLUDED
|
#ifndef hook_manager_hh_INCLUDED
|
||||||
#define hook_manager_hh_INCLUDED
|
#define hook_manager_hh_INCLUDED
|
||||||
|
|
||||||
#include "idvaluemap.hh"
|
#include "id_map.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -29,7 +29,7 @@ private:
|
||||||
friend class GlobalHooks;
|
friend class GlobalHooks;
|
||||||
|
|
||||||
HookManager* m_parent;
|
HookManager* m_parent;
|
||||||
std::unordered_map<String, idvaluemap<String, HookFunc>> m_hook;
|
std::unordered_map<String, id_map<HookFunc>> m_hook;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlobalHooks : public HookManager,
|
class GlobalHooks : public HookManager,
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
#ifndef idvaluemap_hh_INCLUDED
|
#ifndef id_map_hh_INCLUDED
|
||||||
#define idvaluemap_hh_INCLUDED
|
#define id_map_hh_INCLUDED
|
||||||
|
|
||||||
#include "completion.hh"
|
#include "completion.hh"
|
||||||
|
#include "string.hh"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename Id, typename Value>
|
template<typename Value>
|
||||||
class idvaluemap
|
class id_map
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::pair<Id, Value> value_type;
|
typedef std::pair<String, Value> value_type;
|
||||||
typedef std::vector<value_type> container_type;
|
typedef std::vector<value_type> container_type;
|
||||||
typedef typename container_type::iterator iterator;
|
typedef typename container_type::iterator iterator;
|
||||||
typedef typename container_type::const_iterator const_iterator;
|
typedef typename container_type::const_iterator const_iterator;
|
||||||
|
@ -27,7 +28,7 @@ public:
|
||||||
m_content.push_back(std::move(value));
|
m_content.push_back(std::move(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator find(const Id& id)
|
iterator find(const String& id)
|
||||||
{
|
{
|
||||||
for (auto it = begin(); it != end(); ++it)
|
for (auto it = begin(); it != end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,7 @@ public:
|
||||||
return end();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator find(const Id& id) const
|
const_iterator find(const String& id) const
|
||||||
{
|
{
|
||||||
for (auto it = begin(); it != end(); ++it)
|
for (auto it = begin(); it != end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -47,19 +48,19 @@ public:
|
||||||
return end();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool contains(const Id& id) const
|
bool contains(const String& id) const
|
||||||
{
|
{
|
||||||
return find(id) != end();
|
return find(id) != end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(const Id& id)
|
void remove(const String& id)
|
||||||
{
|
{
|
||||||
auto it = find(id);
|
auto it = find(id);
|
||||||
if (it != end())
|
if (it != end())
|
||||||
m_content.erase(it);
|
m_content.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_all(const Id& id)
|
void remove_all(const String& id)
|
||||||
{
|
{
|
||||||
for (auto it = find(id); it != end(); it = find(id))
|
for (auto it = find(id); it != end(); it = find(id))
|
||||||
m_content.erase(it);
|
m_content.erase(it);
|
||||||
|
@ -77,9 +78,8 @@ public:
|
||||||
if (not condition(value))
|
if (not condition(value))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String id_str = value.first;
|
if (prefix_match(value.first, real_prefix))
|
||||||
if (prefix_match(id_str, real_prefix))
|
result.push_back(value.first);
|
||||||
result.push_back(std::move(id_str));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -102,4 +102,4 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // idvaluemap_hh_INCLUDED
|
#endif // id_map_hh_INCLUDED
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef keymap_manager_hh_INCLUDED
|
#ifndef keymap_manager_hh_INCLUDED
|
||||||
#define keymap_manager_hh_INCLUDED
|
#define keymap_manager_hh_INCLUDED
|
||||||
|
|
||||||
#include "idvaluemap.hh"
|
|
||||||
#include "keys.hh"
|
#include "keys.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user