Pakman
LongOptions Class Reference

#include <LongOptions.h>

Public Member Functions

 LongOptions ()
 
 ~LongOptions ()=default
 
void add (struct option long_opt)
 
const struct option * getLongOpts () const
 
const char * getShortOpts () const
 
std::string getLongOptionName (char short_option) const
 

Detailed Description

A class for representing command-line options.

The LongOptions class is a utility wrapper for the struct option array type defined in getopt.h, and used by getopt_long().

Long options are added with add(). The struct option array is accessed with getLongOpts(), while the optstring is accessed with getShortOpts().

Definition at line 20 of file LongOptions.h.

Constructor & Destructor Documentation

◆ LongOptions()

LongOptions::LongOptions ( )

Default constructor.

The constructor will push the null struct option to the struct option array so that a valid struct option is always maintained.

Definition at line 13 of file LongOptions.cc.

◆ ~LongOptions()

LongOptions::~LongOptions ( )
default

Default destructor does nothing.

Member Function Documentation

◆ add()

void LongOptions::add ( struct option  long_opt)

Add a long option.

Parameters
long_optlong option to add.

Definition at line 20 of file LongOptions.cc.

◆ getLongOptionName()

std::string LongOptions::getLongOptionName ( char  short_option) const

Get the long option name for a short option.

Parameters
short_optionshort option character.
Returns
long option name.

Definition at line 82 of file LongOptions.cc.

◆ getLongOpts()

const struct option * LongOptions::getLongOpts ( ) const
Returns
long option array.

Definition at line 71 of file LongOptions.cc.

◆ getShortOpts()

const char * LongOptions::getShortOpts ( ) const
Returns
optstring.

Definition at line 77 of file LongOptions.cc.


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