From ffd860c1da02d234ad39226c58302138a2930a6c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 5 Jun 2014 23:49:52 +0100 Subject: [PATCH] Use a id_map implementation for SwitchMap That way parameter definition order is respected when writing command doc strings. --- src/id_map.hh | 5 +++++ src/parameters_parser.hh | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/id_map.hh b/src/id_map.hh index 023c73c0..e8fe1ccb 100644 --- a/src/id_map.hh +++ b/src/id_map.hh @@ -18,6 +18,9 @@ public: using iterator = typename container_type::iterator; using const_iterator = typename container_type::const_iterator; + id_map() = default; + id_map(std::initializer_list val) : m_content{val} {} + void append(const value_type& value) { m_content.push_back(value); @@ -91,6 +94,8 @@ public: prefix, cursor_pos, [](const value_type&) { return true; }); } + bool empty() const { return m_content.empty(); } + iterator begin() { return m_content.begin(); } iterator end() { return m_content.end(); } const_iterator begin() const { return m_content.begin(); } diff --git a/src/parameters_parser.hh b/src/parameters_parser.hh index b41dc9a0..49d970f7 100644 --- a/src/parameters_parser.hh +++ b/src/parameters_parser.hh @@ -2,11 +2,10 @@ #define parameters_parser_hh_INCLUDED #include "exception.hh" +#include "id_map.hh" #include "memoryview.hh" #include "string.hh" -#include - namespace Kakoune { @@ -40,7 +39,7 @@ struct SwitchDesc String description; }; -using SwitchMap = std::unordered_map; +using SwitchMap = id_map; String generate_switches_doc(const SwitchMap& opts);