Option++
2.0
C++ library for reading command-line options
|
Go to the documentation of this file.
25 #ifndef OPTIONPP_OPTION_GROUP_HPP
26 #define OPTIONPP_OPTION_GROUP_HPP
95 template <
typename InputIt>
97 InputIt first, InputIt last)
98 : m_name{
name}, m_options{first, last} {}
104 const std::string&
name() const noexcept {
return m_name; }
122 m_options.push_back(opt);
123 return m_options.back();
135 option&
add_option(
const std::string& long_name,
136 char short_name =
'\0',
137 const std::string& description =
"",
138 const std::string& arg_name =
"",
139 bool arg_required =
false);
150 bool empty() const noexcept {
return m_options.empty(); }
Holds a group of program options.
Definition: option_group.hpp:41
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator to the end.
Definition: option_group.hpp:203
const std::string & name() const noexcept
Returns the name of the group.
Definition: option_group.hpp:104
reverse_iterator rbegin() noexcept
Return a reverse_iterator to the beginning.
Definition: option_group.hpp:189
Describes a valid program command-line option.
Definition: option.hpp:67
reverse_iterator rend() noexcept
Return a reverse_iterator to the end.
Definition: option_group.hpp:199
option & add_option(const option &opt=option{})
Add a program option to the group.
Definition: option_group.hpp:121
option & operator[](const std::string long_name)
Subscript operator.
Definition: option_group.cpp:41
option_group(const std::string &name, InputIt first, InputIt last)
Construct from a sequence.
Definition: option_group.hpp:96
iterator begin() noexcept
Return an iterator to the first option in the group.
Definition: option_group.hpp:156
container_type::reverse_iterator reverse_iterator
Reverse iterator type.
Definition: option_group.hpp:67
const_iterator begin() const noexcept
Return a const_iterator to the first option.
Definition: option_group.hpp:160
bool empty() const noexcept
Return whether the container is empty.
Definition: option_group.hpp:150
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator to the beginning.
Definition: option_group.hpp:193
option_group(const std::string &name)
Construct empty named group.
Definition: option_group.hpp:81
const_iterator end() const noexcept
Return a const_iterator to the end of the container.
Definition: option_group.hpp:170
container_type::iterator iterator
Plain iterator type.
Definition: option_group.hpp:59
const_iterator cend() const noexcept
Return a const_iterator to the end of the container.
Definition: option_group.hpp:182
std::vector< option > container_type
Type of container used to hold the options.
Definition: option_group.hpp:51
container_type::const_reverse_iterator const_reverse_iterator
Constant reverse iterator type.
Definition: option_group.hpp:71
container_type::size_type size_type
Type used to represent the size of the container.
Definition: option_group.hpp:55
Library namespace.
Definition: error.hpp:31
void sort()
Sorts the options by name.
Definition: option_group.cpp:77
const_reverse_iterator crend() const noexcept
Return a const_reverse_iterator to the end.
Definition: option_group.hpp:216
iterator end() noexcept
Return an iterator to one beyond the last option in the group.
Definition: option_group.hpp:166
option_group() noexcept
Default constructor.
Definition: option_group.hpp:76
const_iterator cbegin() const noexcept
Return a const_iterator to the first option.
Definition: option_group.hpp:176
const_reverse_iterator crbegin() const noexcept
Return a const_reverse_iterator to the beginning.
Definition: option_group.hpp:210
iterator find(const std::string &long_name)
Search for an option in the group.
Definition: option_group.cpp:57
container_type::const_iterator const_iterator
Constant iterator type.
Definition: option_group.hpp:63
size_type size() const noexcept
Return the number of options in the group.
Definition: option_group.hpp:145
Header file for option class.