diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-02-03 19:14:35 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-02-03 19:14:35 +0000 |
| commit | 0483e951ade67989f762cfcd3796b261ffae41dd (patch) | |
| tree | 012f813b4efc8dadcd7b8b17dd600ea66f2f7d21 /src/command_manager.hh | |
| parent | ac02ccb53d2a299e43807f81f589cdb677787677 (diff) | |
use memoryview instead of std::vector where applicable
Diffstat (limited to 'src/command_manager.hh')
| -rw-r--r-- | src/command_manager.hh | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/command_manager.hh b/src/command_manager.hh index 125db6e1..aa9e6818 100644 --- a/src/command_manager.hh +++ b/src/command_manager.hh @@ -2,13 +2,13 @@ #define command_manager_hh_INCLUDED #include <string> -#include <vector> #include <unordered_map> #include <functional> #include <initializer_list> #include "utils.hh" #include "completion.hh" +#include "memoryview.hh" namespace Kakoune { @@ -20,7 +20,7 @@ struct wrong_argument_count : runtime_error wrong_argument_count() : runtime_error("wrong argument count") {} }; -typedef std::vector<std::string> CommandParameters; +typedef memoryview<std::string> CommandParameters; typedef std::function<void (const CommandParameters&, const Context& context)> Command; @@ -31,23 +31,17 @@ class PerArgumentCommandCompleter { public: typedef std::function<CandidateList (const std::string&, size_t)> ArgumentCompleter; - typedef std::vector<ArgumentCompleter> ArgumentCompleterList; + typedef memoryview<ArgumentCompleter> ArgumentCompleterList; PerArgumentCommandCompleter(const ArgumentCompleterList& completers) - : m_completers(completers) {} - - PerArgumentCommandCompleter(ArgumentCompleterList&& completers) - : m_completers(completers) {} - - PerArgumentCommandCompleter(std::initializer_list<ArgumentCompleter> completers) - : m_completers(completers) {} + : m_completers(completers.begin(), completers.end()) {} CandidateList operator()(const CommandParameters& params, size_t token_to_complete, size_t pos_in_token) const; private: - ArgumentCompleterList m_completers; + std::vector<ArgumentCompleter> m_completers; }; class CommandManager : public Singleton<CommandManager> @@ -69,10 +63,10 @@ public: unsigned flags = None, const CommandCompleter& completer = CommandCompleter()); - void register_command(const std::vector<std::string>& command_names, - Command command, - unsigned flags = None, - const CommandCompleter& completer = CommandCompleter()); + void register_commands(const memoryview<std::string>& command_names, + Command command, + unsigned flags = None, + const CommandCompleter& completer = CommandCompleter()); private: struct CommandDescriptor |
