UI::Util::CLOption Class Reference

Most general class for a command line option. Use this class for a option without argument. More...

`#include <GetOpt.hpp>`

Inheritance diagram for UI::Util::CLOption:
Collaboration diagram for UI::Util::CLOption:

## Public Member Functions

| CLOption (std::string const &nameLong, char nameShort, std::string const &doc="No documentation for this option.", std::string const &defaultArg="")
| Standard constructor. Normally, you would not use this directly, but rather use GetOpt::set.
std::string | getNameLong () const
| Get the long name.
char | getNameShort () const
| Get the short name.
std::string | getDoc () const
| Get the documentation.
bool | isGiven () const
| Check if this option was given.
std::string | getArg () const
| Get argument given with this option.
virtual void | printUsage () const
| Print usage information for this option.
virtual option * | getCOptLong (option *opt) const
| Get GNU getopt_long(3) represention of this option.
virtual std::string | getCOptShort () const
| Get GNU getopt(3) represention of this option.
virtual void | setGiven (std::string const &arg="")
| Mark this option as "given", and optionally set the argument.

## Protected Attributes

std::string const | defaultArg_

## Detailed Description

Most general class for a command line option. Use this class for a option without argument.

Deprecated:
  Leagcy - don't use this for new code – use boost::program_options instead.

## Constructor & Destructor Documentation

## CLOption()

UI::Util::CLOption::CLOption | ( | std::string const & | nameLong,
|  | char | nameShort,
|  | std::string const & | doc = `"No documentation for this option."`,
|  | std::string const & | defaultArg = `""`
| ) |  |

Standard constructor. Normally, you would not use this directly, but rather use GetOpt::set.

Parameters

  nameLong | Long name of the option; e.g. "version".
  nameShort | Short name (one character) of the option; e.g. 'v'.
  doc | Documentation string for this option; e.g. "Show version information".
  defaultArg | Default value for that option.

## Member Function Documentation

## getArg()

std::string UI::Util::CLOption::getArg | ( |  | ) | const

Get argument given with this option.

Returns
  Argument, if any; zero-length string for none. This must be set manually via setGiven() (GetOpt automates this).

Examples
  GetOpt.cpp.

References defaultArg_, and isGiven().

## getCOptLong()

option * UI::Util::CLOption::getCOptLong | ( | option * | opt | ) | const

virtual

Get GNU getopt_long(3) represention of this option.

Returns
  Corresponding option struct for GNU getopt_long(3).

Reimplemented in UI::Util::CLOptionArg, and UI::Util::CLOptionOptArg.

Referenced by UI::Util::CLOptionArg::getCOptLong(), and UI::Util::CLOptionOptArg::getCOptLong().

## getCOptShort()

std::string UI::Util::CLOption::getCOptShort | ( |  | ) | const

virtual

Get GNU getopt(3) represention of this option.

Returns
  Corresponding "optstr" for getopt(3).

Reimplemented in UI::Util::CLOptionArg, and UI::Util::CLOptionOptArg.

## getDoc()

std::string UI::Util::CLOption::getDoc | ( |  | ) | const

Get the documentation.

Returns
  Documentation string of this option.

Referenced by UI::Util::CLOptionArg::printUsage(), and UI::Util::CLOptionOptArg::printUsage().

## getNameLong()

std::string UI::Util::CLOption::getNameLong | ( |  | ) | const

Get the long name.

Returns
  Long name of this option.

Referenced by UI::Util::CLOptionArg::printUsage(), and UI::Util::CLOptionOptArg::printUsage().

## getNameShort()

char UI::Util::CLOption::getNameShort | ( |  | ) | const

Get the short name.

Returns
  Short name of this option.

Referenced by UI::Util::CLOptionArg::getCOptShort(), UI::Util::CLOptionOptArg::getCOptShort(), UI::Util::CLOptionArg::printUsage(), and UI::Util::CLOptionOptArg::printUsage().

## isGiven()

bool UI::Util::CLOption::isGiven | ( |  | ) | const

Check if this option was given.

Returns
  true, if argument was given, else false. This must be set manually via setGiven() (GetOpt automates this).

Examples
  GetOpt.cpp.

Referenced by getArg().

## printUsage()

void UI::Util::CLOption::printUsage | ( |  | ) | const

virtual

Print usage information for this option.

Reimplemented in UI::Util::CLOptionArg, and UI::Util::CLOptionOptArg.

Referenced by UI::Util::GetOpt::printUsage().

## setGiven()

void UI::Util::CLOption::setGiven | ( | std::string const & | arg = `""` | ) |

virtual

Mark this option as "given", and optionally set the argument.

Parameters

  arg | Argument string to set this option to.

## Field Documentation

## defaultArg_

std::string const UI::Util::CLOption::defaultArg_

protected

Option argument

Referenced by getArg(), UI::Util::CLOptionArg::printUsage(), and UI::Util::CLOptionOptArg::printUsage().

The documentation for this class was generated from the following files:

- GetOpt.hpp
- GetOpt.cpp