Option++
2.0
C++ library for reading command-line options
|
Go to the documentation of this file.
25 #ifndef OPTIONPP_RESULT_ITERATOR_HPP
26 #define OPTIONPP_RESULT_ITERATOR_HPP
35 template <
typename T,
typename Ptr,
typename Ref,
bool IsOption>
49 : m_result{&result}, m_index{0} {
50 if (!result.empty() && result[0].is_option != IsOption)
123 return !(*
this == other);
128 typename T::size_type m_index;
136 template <
typename T,
137 typename Ptr,
typename Ref,
bool IsOption>
138 inline result_iterator<T, Ptr, Ref, IsOption>
145 template <
typename T,
146 typename Ptr,
typename Ref,
bool IsOption>
147 inline result_iterator<T, Ptr, Ref, IsOption>
191 template <
typename T,
192 typename Ptr,
typename Ref,
bool IsOption>
196 "optionpp::non_option_iterator::operator*"};
197 if (m_index == m_result->size())
199 "optionpp::non_option_iterator::operator*"};
200 return (*m_result)[m_index];
203 template <
typename T,
204 typename Ptr,
typename Ref,
bool IsOption>
210 }
while (m_index < m_result->size()
211 && (*m_result)[m_index].is_option != IsOption);
216 template <
typename T,
217 typename Ptr,
typename Ref,
bool IsOption>
223 throw out_of_range{
"out of bounds parser_result access",
224 "optionpp::non_option_iterator::operator--"};
226 }
while ((*m_result)[m_index].is_option != IsOption);
231 template <
typename T,
232 typename Ptr,
typename Ref,
bool IsOption>
235 bool left_default = !m_result;
236 bool right_default = !other.m_result;
237 bool left_at_end = left_default || m_result->size() == m_index;
238 bool right_at_end = right_default
239 || other.m_result->size() == other.m_index;
242 if (!left_default && !right_default)
243 return m_index == other.m_index && m_result == other.m_result;
245 else if (left_at_end && right_at_end)
Exception indicating out of range access.
Definition: error.hpp:59
Holds data parsed from the command line.
Definition: parser_result.hpp:45
result_iterator< T, Ptr, Ref, IsOption > begin(result_iterator< T, Ptr, Ref, IsOption > it) noexcept
begin function for range for loop support.
Definition: result_iterator.hpp:139
bool operator==(const result_iterator< T, Ptr, Ref, IsOption > &other) const
result_iterator comparison operator.
Definition: result_iterator.hpp:234
result_iterator(T &result)
Constructor.
Definition: result_iterator.hpp:48
Iterator over parser_result arguments.
Definition: result_iterator.hpp:36
result_iterator() noexcept
Default constructor.
Definition: result_iterator.hpp:43
result_iterator operator++(int)
Postfix increment operator.
Definition: result_iterator.hpp:81
bool operator!=(const result_iterator< T, Ptr, Ref, IsOption > &other) const
result_iterator comparison operator.
Definition: result_iterator.hpp:122
result_iterator< parser_result, parsed_entry *, parsed_entry &, true > option_iterator
Iterator over option entries in a parser_result.
Definition: result_iterator.hpp:158
Ptr operator->() const
Member access operator.
Definition: result_iterator.hpp:68
result_iterator operator--(int)
Postfix decrement operator.
Definition: result_iterator.hpp:102
Exception indicating an invalid iterator was dereferenced.
Definition: error.hpp:73
result_iterator & operator++()
Prefix increment operator.
Definition: result_iterator.hpp:205
Library namespace.
Definition: error.hpp:31
Holds data that was parsed from the program command line.
Definition: parser_result.hpp:152
Header file for parser_result class.
result_iterator< T, Ptr, Ref, IsOption > end(const result_iterator< T, Ptr, Ref, IsOption > &) noexcept
end function for range for loop support.
Definition: result_iterator.hpp:148
Ref operator*() const
Dereference operator.
Definition: result_iterator.hpp:193
result_iterator & operator--()
Prefix decrement operator.
Definition: result_iterator.hpp:218