2014-10-30 00:22:54 +01:00
|
|
|
#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"
|
2014-10-30 00:22:54 +01:00
|
|
|
|
|
|
|
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;
|
2014-10-30 00:22:54 +01:00
|
|
|
|
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;
|
2014-10-30 00:22:54 +01:00
|
|
|
|
|
|
|
private:
|
2014-10-30 15:00:42 +01:00
|
|
|
friend class Scope;
|
2014-10-30 00:22:54 +01:00
|
|
|
AliasRegistry() {}
|
|
|
|
|
2015-02-19 14:58:25 +01:00
|
|
|
SafePtr<AliasRegistry> m_parent;
|
2015-09-16 23:32:02 +02:00
|
|
|
AliasMap m_aliases;
|
2014-10-30 00:22:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // alias_registry_hh_INCLUDED
|