Option++
2.0
C++ library for reading command-line options
|
Go to the documentation of this file.
25 #ifndef OPTIONPP_PARSER_RESULT_HPP
26 #define OPTIONPP_PARSER_RESULT_HPP
29 #include <initializer_list>
203 template <
typename InputIt>
219 void clear() noexcept { m_entries.clear(); }
235 bool empty() const noexcept {
return m_entries.empty(); }
309 throw out_of_range(
"out of bounds parser_result access",
310 "optionpp::parser_result::at");
311 return (*
this)[index];
318 throw out_of_range(
"out of bounds parser_result access",
319 "optionpp::parser_result::at");
320 return (*
this)[index];
333 return m_entries[index];
343 throw out_of_range(
"out of bounds parser_result access",
344 "optionpp::parser_result::back");
345 return m_entries.back();
353 throw out_of_range(
"out of bounds parser_result access",
354 "optionpp::parser_result::at");
355 return m_entries.back();
364 bool is_option_set(
const std::string& long_name)
const noexcept;
382 std::string
get_argument(std::string long_name)
const noexcept;
392 std::string
get_argument(
char short_name)
const noexcept;
std::string long_name
The long name of the option which this parsed_entry represents.
Definition: parser_result.hpp:111
const_reverse_iterator crbegin() const noexcept
Return a const_reverse_iterator to the beginning.
Definition: parser_result.hpp:293
parser_result(InputIt first, InputIt last)
Construct from a sequence.
Definition: parser_result.hpp:204
Exception indicating out of range access.
Definition: error.hpp:59
const_iterator cbegin() const noexcept
Return a const_iterator to the beginning of the container.
Definition: parser_result.hpp:260
Describes a valid program command-line option.
Definition: option.hpp:67
void clear() noexcept
Erase all data entries currently stored.
Definition: parser_result.hpp:219
Holds data parsed from the command line.
Definition: parser_result.hpp:45
const value_type & operator[](size_type index) const
Subscript operator.
Definition: parser_result.hpp:332
const value_type & at(size_type index) const
Range-checked subscript.
Definition: parser_result.hpp:316
parser_result(const std::initializer_list< value_type > &il)
Construct from an initializer list.
Definition: parser_result.hpp:195
const_iterator begin() const noexcept
Return a const_iterator to the beginning of the container.
Definition: parser_result.hpp:245
const_reverse_iterator crend() const noexcept
Return a const_reverse_iterator to the end.
Definition: parser_result.hpp:299
bool empty() const noexcept
Return whether the container is empty.
Definition: parser_result.hpp:235
const_iterator cend() const noexcept
Return a const_iterator to the end of the container.
Definition: parser_result.hpp:265
std::string argument
The argument that was passed to the option, if any.
Definition: parser_result.hpp:127
value_type & back()
Access last entry in the container.
Definition: parser_result.hpp:341
container_type::const_iterator const_iterator
Constant iterator type.
Definition: parser_result.hpp:175
parsed_entry() noexcept
Default constructor.
Definition: parser_result.hpp:49
const_iterator end() const noexcept
Return a const_iterator to the end of the container.
Definition: parser_result.hpp:254
bool is_option_set(const std::string &long_name) const noexcept
Returns whether the specified option is set.
Definition: parser_result.cpp:32
value_type & at(size_type index)
Range-checked subscript.
Definition: parser_result.hpp:307
container_type::size_type size_type
Unsigned integer type (usually std::size_t) that can hold container size.
Definition: parser_result.hpp:167
parsed_entry(const std::string &original_text, bool is_option=false, const std::string &long_name="", char short_name='\0', const std::string &argument="")
Constructor.
Definition: parser_result.hpp:62
std::string get_argument(std::string long_name) const noexcept
Get the argument for the specified option.
Definition: parser_result.cpp:52
std::string original_without_argument
The original text used on the command line but without any option argument.
Definition: parser_result.hpp:92
std::string original_text
The original text used on the command line.
Definition: parser_result.hpp:82
void push_back(value_type &&entry)
Add a parsed_entry to the back of the container.
Definition: parser_result.hpp:214
void push_back(const value_type &entry)
Add a parsed_entry to the back of the container.
Definition: parser_result.hpp:210
Library namespace.
Definition: error.hpp:31
const value_type & back() const
Access last entry in the container.
Definition: parser_result.hpp:351
iterator end() noexcept
Return an iterator to the end of the container.
Definition: parser_result.hpp:250
Holds data that was parsed from the program command line.
Definition: parser_result.hpp:152
iterator begin() noexcept
Return an iterator to the beginning of the container.
Definition: parser_result.hpp:241
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator to the end.
Definition: parser_result.hpp:286
container_type::iterator iterator
Plain iterator type.
Definition: parser_result.hpp:171
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator to the beginning.
Definition: parser_result.hpp:276
container_type::reverse_iterator reverse_iterator
Reverse iterator type.
Definition: parser_result.hpp:179
parser_result() noexcept
Default constructor.
Definition: parser_result.hpp:190
size_type size() const noexcept
Return the number of data entries.
Definition: parser_result.hpp:230
Header file for option class.
const option * opt_info
Pointer to the option instance representing this option, if any.
Definition: parser_result.hpp:133
reverse_iterator rend() noexcept
Return a reverse_iterator to the end.
Definition: parser_result.hpp:282
bool is_option
True if this parsed_entry represents a program option, false otherwise.
Definition: parser_result.hpp:103
std::vector< value_type > container_type
Type of container used to store the data entries.
Definition: parser_result.hpp:162
char short_name
The short name of the option which this parsed_entry represents.
Definition: parser_result.hpp:119
value_type & operator[](size_type index)
Subscript operator.
Definition: parser_result.hpp:328
Header file for exception classes.
container_type::const_reverse_iterator const_reverse_iterator
Constant reverse iterator type.
Definition: parser_result.hpp:183
reverse_iterator rbegin() noexcept
Return a reverse_iterator to the beginning.
Definition: parser_result.hpp:272