Command line option.
More...
#include <cppassist/include/cppassist/cmdline/CommandLineOption.h>
Command line option.
A command line option is a named value than can be specified on the command line. It can have a long and a short version. Immediatly after the option itself, the value must be specified on the command line.
Example: myapp [--config-file <filename>]
"--config-file", "-c",
"filename",
"Specify path to configuration file",
◆ OptionalState
State whether or not an option is optional.
Enumerator |
---|
NonOptional | |
Optional | |
◆ CommandLineOption()
cppassist::CommandLineOption::CommandLineOption |
( |
const std::string & |
longName, |
|
|
const std::string & |
shortName, |
|
|
const std::string & |
valueName, |
|
|
const std::string & |
description, |
|
|
OptionalState |
optional = Optional |
|
) |
| |
Constructor.
- Parameters
-
[in] | longName | Long name (e.g., "--config-file") |
[in] | shortName | Short name (e.g., "-c") |
[in] | valueName | Name of the value (only relevant for the help text) |
[in] | description | Description text |
[in] | optional | Optional-state |
◆ ~CommandLineOption()
cppassist::CommandLineOption::~CommandLineOption |
( |
| ) |
|
◆ name()
const std::string& cppassist::CommandLineOption::name |
( |
| ) |
const |
Get name.
- Returns
- Long name if available, else short name
◆ names()
const std::string& cppassist::CommandLineOption::names |
( |
| ) |
const |
Get names.
- Returns
- String containing both the short and long name (e.g., "-c, --config-file")
◆ longName()
const std::string& cppassist::CommandLineOption::longName |
( |
| ) |
const |
Get long name.
- Returns
- Long name (e.g., "--config-file")
◆ setLongName()
void cppassist::CommandLineOption::setLongName |
( |
const std::string & |
longName | ) |
|
Set long name.
- Parameters
-
[in] | longName | Long name (e.g., "--config-file") |
◆ shortName()
const std::string& cppassist::CommandLineOption::shortName |
( |
| ) |
const |
Get short name.
- Returns
- Short name (e.g., "-c")
◆ setShortName()
void cppassist::CommandLineOption::setShortName |
( |
const std::string & |
shortName | ) |
|
Set short name.
- Parameters
-
[in] | shortName | Short name (e.g., "-c") |
◆ valueName()
const std::string& cppassist::CommandLineOption::valueName |
( |
| ) |
const |
Get value name.
- Returns
- Value name (e.g., "filename")
◆ setValueName()
void cppassist::CommandLineOption::setValueName |
( |
const std::string & |
name | ) |
|
Set value name.
- Parameters
-
[in] | name | Value name (e.g., "filename") |
◆ description()
const std::string& cppassist::CommandLineOption::description |
( |
| ) |
const |
Get description.
- Returns
- Description text
◆ setDescription()
void cppassist::CommandLineOption::setDescription |
( |
const std::string & |
description | ) |
|
Set description.
- Parameters
-
[in] | description | Description text |
◆ isOptional()
bool cppassist::CommandLineOption::isOptional |
( |
| ) |
const |
Check optional-flag.
- Returns
true
if optional, else false
◆ optional()
Check optional-flag.
- Returns
- Optional-state
◆ setOptional()
void cppassist::CommandLineOption::setOptional |
( |
OptionalState |
optional | ) |
|
Set optional-flag.
- Parameters
-
[in] | optional | Optional-state |
◆ value()
const std::string& cppassist::CommandLineOption::value |
( |
| ) |
const |
Get value.
- Returns
- Option value
◆ setValue()
void cppassist::CommandLineOption::setValue |
( |
const std::string & |
value | ) |
|
◆ updateNames()
void cppassist::CommandLineOption::updateNames |
( |
| ) |
|
|
protected |
◆ m_longName
std::string cppassist::CommandLineOption::m_longName |
|
protected |
Long name (e.g., "--config-file")
◆ m_shortName
std::string cppassist::CommandLineOption::m_shortName |
|
protected |
◆ m_names
std::string cppassist::CommandLineOption::m_names |
|
protected |
String containing both the short and long name (e.g., "-c, --config-file")
◆ m_valueName
std::string cppassist::CommandLineOption::m_valueName |
|
protected |
Value name (e.g., "filename")
◆ m_description
std::string cppassist::CommandLineOption::m_description |
|
protected |
◆ m_optional
◆ m_value
std::string cppassist::CommandLineOption::m_value |
|
protected |
The documentation for this class was generated from the following file: