diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-02-27 20:51:44 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-02-27 20:51:44 +0100 |
| commit | 43bc8314fba746a05f607d71fa128ebeadf264b2 (patch) | |
| tree | 02b94f4cc7b58e9826f0f9c3c71f6613ff3cacf2 /src/parameters_parser.hh | |
| parent | 09901d455e9e9d9182dfc9ceb13a2cc7735980b4 (diff) | |
ParameterParser: refactoring, simplify
Diffstat (limited to 'src/parameters_parser.hh')
| -rw-r--r-- | src/parameters_parser.hh | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/parameters_parser.hh b/src/parameters_parser.hh index 2ba77c76..d91f436f 100644 --- a/src/parameters_parser.hh +++ b/src/parameters_parser.hh @@ -61,31 +61,26 @@ struct ParametersParser const String& operator*() const { - assert(m_parser.m_positional[m_index]); - return m_parser.m_params[m_index]; + return m_parser.m_params[m_parser.m_positional_indices[m_index]]; } const String* operator->() const { - assert(m_parser.m_positional[m_index]); - return &m_parser.m_params[m_index]; + return &m_parser.m_params[m_parser.m_positional_indices[m_index]]; } - iterator& operator++() - { - while (m_index < m_parser.m_positional.size() and - not m_parser.m_positional[++m_index]) {} - return *this; - } + iterator& operator++() { ++m_index; return *this; } bool operator==(const iterator& other) const { - return &m_parser == &other.m_parser and m_index == other.m_index; + assert(&m_parser == &other.m_parser); + return m_index == other.m_index; } bool operator!=(const iterator& other) const { - return &m_parser != &other.m_parser or m_index != other.m_index; + assert(&m_parser == &other.m_parser); + return m_index != other.m_index; } bool operator<(const iterator& other) const @@ -108,7 +103,7 @@ struct ParametersParser private: ParameterList m_params; - std::vector<bool> m_positional; + std::vector<size_t> m_positional_indices; std::unordered_map<String, bool> m_options; }; |
