Option++  2.0
C++ library for reading command-line options
Public Member Functions | Public Attributes | List of all members
optionpp::parsed_entry Struct Reference

Holds data parsed from the command line. More...

#include <parser_result.hpp>

Collaboration diagram for optionpp::parsed_entry:
Collaboration graph
[legend]

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 optionopt_info {nullptr}
 Pointer to the option instance representing this option, if any.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ parsed_entry()

optionpp::parsed_entry::parsed_entry ( const std::string &  original_text,
bool  is_option = false,
const std::string &  long_name = "",
char  short_name = '\0',
const std::string &  argument = "" 
)
inlineexplicit

Constructor.

Parameters
original_textThe original text used on the command line.
is_optionTrue if the data represents a program option, false for non-option arguments.
long_nameThe long name of the option (empty string if this is not an option).
short_nameThe short name of the option (0 if this is not an option).
argumentThe argument passed to the option, if any.

Member Data Documentation

◆ argument

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.

◆ is_option

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 --).

◆ long_name

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.

◆ original_text

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.

◆ original_without_argument

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.

◆ short_name

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.


The documentation for this struct was generated from the following file: