E-MailRelay
Public Member Functions | Static Public Member Functions | List of all members
G::OptionValue Class Reference

A simple structure encapsulating the value of a command-line option. More...

#include <goptionvalue.h>

Public Member Functions

 OptionValue ()
 Default constructor for a valueless value. More...
 
 OptionValue (const std::string &s, std::size_t count=1U)
 Constructor for a valued value. More...
 
bool isOn () const
 Returns true if on(). More...
 
bool isOff () const
 Returns true if off(). More...
 
std::string value () const
 Returns the value as a string. More...
 
bool numeric () const
 Returns true if value() is an unsigned integer. More...
 
unsigned int number (unsigned int default_=0U) const
 Returns value() as an unsigned integer. More...
 
size_t count () const
 Returns an instance count that is one by default. More...
 
void increment ()
 Increments the instance count(). More...
 

Static Public Member Functions

static OptionValue on ()
 A factory function for an unvalued option-enabled option. More...
 
static OptionValue off ()
 A factory function for an unvalued option-disabled option. More...
 

Detailed Description

A simple structure encapsulating the value of a command-line option.

Unvalued options (eg. "--debug") can be be explicitly on (eg. "--debug=yes") or off ("--debug=no"); the latter are typically ignored.

Definition at line 38 of file goptionvalue.h.

Constructor & Destructor Documentation

◆ OptionValue() [1/2]

G::OptionValue::OptionValue ( )
inline

Default constructor for a valueless value.

Definition at line 83 of file goptionvalue.h.

◆ OptionValue() [2/2]

G::OptionValue::OptionValue ( const std::string &  s,
std::size_t  count = 1U 
)
inlineexplicit

Constructor for a valued value.

Precondition: !s.empty()

Definition at line 90 of file goptionvalue.h.

Member Function Documentation

◆ count()

std::size_t G::OptionValue::count ( ) const
inline

Returns an instance count that is one by default.

Definition at line 141 of file goptionvalue.h.

◆ increment()

void G::OptionValue::increment ( )
inline

Increments the instance count().

Definition at line 147 of file goptionvalue.h.

◆ isOff()

bool G::OptionValue::isOff ( ) const
inline

Returns true if off().

Definition at line 117 of file goptionvalue.h.

◆ isOn()

bool G::OptionValue::isOn ( ) const
inline

Returns true if on().

Definition at line 111 of file goptionvalue.h.

◆ number()

unsigned int G::OptionValue::number ( unsigned int  default_ = 0U) const
inline

Returns value() as an unsigned integer.

Returns the default if not numeric().

Definition at line 135 of file goptionvalue.h.

◆ numeric()

bool G::OptionValue::numeric ( ) const
inline

Returns true if value() is an unsigned integer.

Definition at line 129 of file goptionvalue.h.

◆ off()

G::OptionValue G::OptionValue::off ( )
inlinestatic

A factory function for an unvalued option-disabled option.

Definition at line 103 of file goptionvalue.h.

◆ on()

G::OptionValue G::OptionValue::on ( )
inlinestatic

A factory function for an unvalued option-enabled option.

Definition at line 97 of file goptionvalue.h.

◆ value()

std::string G::OptionValue::value ( ) const
inline

Returns the value as a string.

Definition at line 123 of file goptionvalue.h.


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