Option++
2.0
C++ library for reading command-line options
|
Holds data parsed from the command line. More...
#include <parser_result.hpp>
Public Member Functions | |
parsed_entry () noexcept | |
Default constructor. | |
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. More... | |
Public Attributes | |
std::string | original_text |
The original text used on the command line. More... | |
std::string | original_without_argument |
The original text used on the command line but without any option argument. More... | |
bool | is_option {false} |
True if this parsed_entry represents a program option, false otherwise. More... | |
std::string | long_name |
The long name of the option which this parsed_entry represents. More... | |
char | short_name {'\0'} |
The short name of the option which this parsed_entry represents. More... | |
std::string | argument |
The argument that was passed to the option, if any. More... | |
const option * | opt_info {nullptr} |
Pointer to the option instance representing this option, if any. | |
Holds data parsed from the command line.
Each parsed_entry
instance represents either a program option or a non-option argument that was passed on the command line.
|
inlineexplicit |
Constructor.
original_text | The original text used on the command line. |
is_option | True if the data represents a program option, false for non-option arguments. |
long_name | The long name of the option (empty string if this is not an option). |
short_name | The short name of the option (0 if this is not an option). |
argument | The argument passed to the option, if any. |
std::string optionpp::parsed_entry::argument |
The argument that was passed to the option, if any.
If is_option
is false, or if no argument was given, then this should be an empty string.
bool optionpp::parsed_entry::is_option {false} |
True if this parsed_entry
represents a program option, false otherwise.
This field will be false if the parsed_entry
is a non-option argument (a separate command line argument that does not begin with a hyphen, or one that occurs after the end-of-options marker --
).
std::string optionpp::parsed_entry::long_name |
The long name of the option which this parsed_entry
represents.
If is_option
is false, this should be an empty string.
std::string optionpp::parsed_entry::original_text |
The original text used on the command line.
For non-option arguments, the text is stored verbatim. If this parsed_entry
represents an option, then this field will take the form -X
if the short name was used (where X
is the short name) or --XXX
if the long name was used (where XXX
is the long name).
In addition, if an argument was given with the option, then the argument will be included after the option name.
std::string optionpp::parsed_entry::original_without_argument |
The original text used on the command line but without any option argument.
For example, if the user entered an option --width=32
, then this field should be set to "--width"
whereas original_text
would contain the full string.
char optionpp::parsed_entry::short_name {'\0'} |
The short name of the option which this parsed_entry
represents.
If is_option
is false, this should be a null character.