diff options
author | 2016-02-19 22:20:53 -0800 | |
---|---|---|
committer | 2016-02-27 09:05:54 -0800 | |
commit | 6d7c19f5759eac6f9ac8014b4bcdb8cb9b059bb7 (patch) | |
tree | 4224067f76e3f42350b9928969a29a3957f6c882 | |
parent | 46bab1c193a83ba35e3e1163812dcc75267a461a (diff) | |
download | paludis-6d7c19f5759eac6f9ac8014b4bcdb8cb9b059bb7.tar.gz paludis-6d7c19f5759eac6f9ac8014b4bcdb8cb9b059bb7.tar.xz |
args: add some iteration helpers
Add some utility methods to aid in increase use of C++11 style for-range loops.
-rw-r--r-- | paludis/args/args_handler.hh | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/paludis/args/args_handler.hh b/paludis/args/args_handler.hh index 85599264d..f1e708867 100644 --- a/paludis/args/args_handler.hh +++ b/paludis/args/args_handler.hh @@ -132,9 +132,12 @@ namespace paludis typedef WrappedForwardIterator<ParametersConstIteratorTag, const std::string> ParametersConstIterator; ParametersConstIterator begin_parameters() const; - ParametersConstIterator end_parameters() const; + IteratorRange<ParameterConstIterator> parameters() const { + return make_iterator_range(begin_parameters(), end_parameters()); + } + bool empty() const; /** @@ -194,9 +197,12 @@ namespace paludis typedef WrappedForwardIterator<UsageLineConstIteratorTag, const std::string> UsageLineConstIterator; UsageLineConstIterator begin_usage_lines() const; - UsageLineConstIterator end_usage_lines() const; + IteratorRange<UsageLineConstIterator> usage_lines() const { + return make_iterator_range(begin_usage_lines(), end_usage_lines()); + } + ///\} ///\name Iterate over our environment lines (for documentation) @@ -207,9 +213,12 @@ namespace paludis const std::pair<std::string, std::string> > EnvironmentLineConstIterator; EnvironmentLineConstIterator begin_environment_lines() const; - EnvironmentLineConstIterator end_environment_lines() const; + IteratorRange<EnvironmentLineConstIterator> environment_lines() const { + return make_iterator_range(begin_environment_lines(), end_environment_lines()); + } + ///\} ///\name Iterate over our examples (for documentation) @@ -220,9 +229,12 @@ namespace paludis const std::pair<std::string, std::string> > ExamplesConstIterator; ExamplesConstIterator begin_examples() const; - ExamplesConstIterator end_examples() const; + IteratorRange<ExamplesConstIterator> examples() const { + return make_iterator_range(begin_examples(), end_examples()); + } + ///\} ///\name Iterate over our sections @@ -234,6 +246,10 @@ namespace paludis ArgsSectionsConstIterator begin_args_sections() const; ArgsSectionsConstIterator end_args_sections() const; + IteratorRange<ArgsSectionsConstIterator> args_sections() const { + return make_iterator_range(begin_args_sections(), end_args_sections()); + } + /** * The 'Options' section. * @@ -252,6 +268,10 @@ namespace paludis NotesIterator begin_notes() const; NotesIterator end_notes() const; + IteratorRange<NotesIterator> notes() const { + return make_iterator_range(begin_notes(), end_notes()); + } + ///\} ///\name Iterate over our extra description lines (for documentation) @@ -261,9 +281,12 @@ namespace paludis typedef WrappedForwardIterator<DescriptionLineConstIteratorTag, const std::string> DescriptionLineConstIterator; DescriptionLineConstIterator begin_description_lines() const; - DescriptionLineConstIterator end_description_lines() const; + IteratorRange<DescriptionLineConstIterator> description_lines() const { + return make_iterator_range(begin_description_lines(), end_description_lines()); + } + ///\} ///\name Iterate over our 'see also' lines @@ -274,9 +297,12 @@ namespace paludis typedef WrappedForwardIterator<SeeAlsoConstIteratorTag, const std::pair<std::string, int> > SeeAlsoConstIterator; SeeAlsoConstIterator begin_see_alsos() const; - SeeAlsoConstIterator end_see_alsos() const; + IteratorRange<SeeAlsoConstIterator> see_alsos() const { + return make_iterator_range(begin_see_alsos(), end_see_alsos()); + } + ///\} ///\name For use by ArgsVisitor |