home/src/alias_registry.hh

36 lines
820 B
C++
Raw Normal View History

#ifndef alias_registry_hh_INCLUDED
#define alias_registry_hh_INCLUDED
#include "safe_ptr.hh"
#include "string.hh"
2015-09-16 23:32:02 +02:00
#include "id_map.hh"
namespace Kakoune
{
class AliasRegistry : public SafeCountable
{
public:
AliasRegistry(AliasRegistry& parent) : m_parent(&parent) {}
void add_alias(String alias, String command);
2015-09-16 23:32:02 +02:00
void remove_alias(StringView alias);
StringView operator[](StringView name) const;
2015-09-16 23:32:02 +02:00
using AliasMap = IdMap<String, MemoryDomain::Aliases>;
2015-09-06 19:09:32 +02:00
using iterator = AliasMap::const_iterator;
2015-01-12 14:58:41 +01:00
Vector<StringView> aliases_for(StringView command) const;
2015-11-17 14:55:27 +01:00
Vector<std::pair<StringView, StringView>> flatten_aliases() const;
private:
friend class Scope;
AliasRegistry() {}
SafePtr<AliasRegistry> m_parent;
2015-09-16 23:32:02 +02:00
AliasMap m_aliases;
};
}
#endif // alias_registry_hh_INCLUDED