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;
|
2016-03-08 14:56:37 +01:00
|
|
|
using AliasDesc = std::pair<StringView, StringView>;
|
|
|
|
Vector<AliasDesc> 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
|