From 43bc8314fba746a05f607d71fa128ebeadf264b2 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 27 Feb 2013 20:51:44 +0100 Subject: ParameterParser: refactoring, simplify --- src/parameters_parser.hh | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/parameters_parser.hh') 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 m_positional; + std::vector m_positional_indices; std::unordered_map m_options; }; -- cgit v1.2.3