|
Option++
2.0
C++ library for reading command-line options
|
Holds data that was parsed from the program command line. More...
#include <parser_result.hpp>
Public Types | |
| using | value_type = parsed_entry |
| Type used for storing argument data. | |
| using | container_type = std::vector< value_type > |
| Type of container used to store the data entries. | |
| using | size_type = container_type::size_type |
Unsigned integer type (usually std::size_t) that can hold container size. | |
| using | iterator = container_type::iterator |
| Plain iterator type. | |
| using | const_iterator = container_type::const_iterator |
| Constant iterator type. | |
| using | reverse_iterator = container_type::reverse_iterator |
| Reverse iterator type. | |
| using | const_reverse_iterator = container_type::const_reverse_iterator |
| Constant reverse iterator type. | |
Public Member Functions | |
| parser_result () noexcept | |
| Default constructor. More... | |
| parser_result (const std::initializer_list< value_type > &il) | |
| Construct from an initializer list. More... | |
| template<typename InputIt > | |
| parser_result (InputIt first, InputIt last) | |
| Construct from a sequence. More... | |
| void | push_back (const value_type &entry) |
Add a parsed_entry to the back of the container. More... | |
| void | push_back (value_type &&entry) |
Add a parsed_entry to the back of the container. More... | |
| void | clear () noexcept |
| Erase all data entries currently stored. | |
| size_type | size () const noexcept |
| Return the number of data entries. More... | |
| bool | empty () const noexcept |
| Return whether the container is empty. More... | |
| iterator | begin () noexcept |
Return an iterator to the beginning of the container. More... | |
| const_iterator | begin () const noexcept |
Return a const_iterator to the beginning of the container. More... | |
| iterator | end () noexcept |
Return an iterator to the end of the container. More... | |
| const_iterator | end () const noexcept |
Return a const_iterator to the end of the container. More... | |
| const_iterator | cbegin () const noexcept |
Return a const_iterator to the beginning of the container. More... | |
| const_iterator | cend () const noexcept |
Return a const_iterator to the end of the container. More... | |
| reverse_iterator | rbegin () noexcept |
Return a reverse_iterator to the beginning. More... | |
| const_reverse_iterator | rbegin () const noexcept |
Return a const_reverse_iterator to the beginning. More... | |
| reverse_iterator | rend () noexcept |
Return a reverse_iterator to the end. More... | |
| const_reverse_iterator | rend () const noexcept |
Return a const_reverse_iterator to the end. More... | |
| const_reverse_iterator | crbegin () const noexcept |
Return a const_reverse_iterator to the beginning. More... | |
| const_reverse_iterator | crend () const noexcept |
Return a const_reverse_iterator to the end. More... | |
| value_type & | at (size_type index) |
| Range-checked subscript. More... | |
| const value_type & | at (size_type index) const |
| Range-checked subscript. More... | |
| value_type & | operator[] (size_type index) |
| Subscript operator. More... | |
| const value_type & | operator[] (size_type index) const |
| Subscript operator. More... | |
| value_type & | back () |
| Access last entry in the container. More... | |
| const value_type & | back () const |
| Access last entry in the container. More... | |
| bool | is_option_set (const std::string &long_name) const noexcept |
| Returns whether the specified option is set. More... | |
| bool | is_option_set (char short_name) const noexcept |
| Returns whether the specified option is set. More... | |
| std::string | get_argument (std::string long_name) const noexcept |
| Get the argument for the specified option. More... | |
| std::string | get_argument (char short_name) const noexcept |
| Get the argument for the specified option. More... | |
Holds data that was parsed from the program command line.
This is a container of parsed_entry instances that describe all the program options that were set on the command line as well as all non-option arguments, all in the order in which they were originally specified.
For example, if the user ran the program with the command
then the corresponding parser_result would hold seven data entries: -a, -f, -n, file1.txt, file2.txt, --verbose, file3.txt, in that order.
|
inlinenoexcept |
Default constructor.
Constructs an empty parser_result.
|
inline |
Construct from an initializer list.
| il | The initializer_list holding the parsed data. |
|
inline |
Construct from a sequence.
| InputIt | The type of iterator (usually deduced). |
| first | Iterator pointing to the beginning of the sequence. |
| last | Iterator pointing to one past the end of the sequence. |
|
inline |
Range-checked subscript.
| index | The index of the parsed_entry to return. |
index. | out_of_range | Thrown if index >= size(). |
|
inline |
Range-checked subscript.
| index | The index of the parsed_entry to return. |
index. | out_of_range | Thrown if index >= size(). |
|
inline |
Access last entry in the container.
| out_of_range | If container is empty. |
parsed_entry.
|
inline |
Access last entry in the container.
| out_of_range | If container is empty. |
parsed_entry.
|
inlinenoexcept |
Return a const_iterator to the beginning of the container.
const_iterator pointing to the first entry.
|
inlinenoexcept |
Return an iterator to the beginning of the container.
iterator pointing to the first entry.
|
inlinenoexcept |
Return a const_iterator to the beginning of the container.
const_iterator pointing to the first entry.
|
inlinenoexcept |
Return a const_iterator to the end of the container.
const_iterator pointing to one past the last entry.
|
inlinenoexcept |
Return a const_reverse_iterator to the beginning.
const_reverse_iterator pointing to the first entry in the reversed sequence.
|
inlinenoexcept |
Return a const_reverse_iterator to the end.
const_reverse_iterator pointing to one past the last entry in the reversed sequence.
|
inlinenoexcept |
Return whether the container is empty.
|
inlinenoexcept |
Return a const_iterator to the end of the container.
const_iterator pointing to one past the last entry.
|
inlinenoexcept |
Return an iterator to the end of the container.
iterator pointing to one past the last entry.
|
noexcept |
Get the argument for the specified option.
If no argument was given, an empty string is returned. If multiple arguments were given, the last is returned.
| short_name | The short name for the option. |
|
noexcept |
Get the argument for the specified option.
If no argument was given, an empty string is returned. If multiple arguments were given, the last is returned.
| long_name | The long name for the option. |
|
noexcept |
Returns whether the specified option is set.
| short_name | The short name for the option. |
|
noexcept |
Returns whether the specified option is set.
| long_name | The long name for the option. |
|
inline |
Subscript operator.
| index | The index of the data entry to return. |
parsed_entry corresponding to the index.
|
inline |
Subscript operator.
| index | The index of the data entry to return. |
parsed_entry corresponding to the index.
|
inline |
Add a parsed_entry to the back of the container.
| entry | The parsed data entry to add. |
|
inline |
Add a parsed_entry to the back of the container.
| entry | The parsed data entry to add. |
|
inlinenoexcept |
Return a const_reverse_iterator to the beginning.
const_reverse_iterator pointing to the first entry in the reversed sequence.
|
inlinenoexcept |
Return a reverse_iterator to the beginning.
reverse_iterator pointing to the first entry in the reversed sequence.
|
inlinenoexcept |
Return a const_reverse_iterator to the end.
const_reverse_iterator pointing to one past the last entry in the reversed sequence.
|
inlinenoexcept |
Return a reverse_iterator to the end.
reverse_iterator pointing to one past the last entry in the reversed sequence.
|
inlinenoexcept |
Return the number of data entries.
This will be the total number of options and non-option arguments that were specified.
1.8.17