VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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.
 
 OptionValue (const std::string &s)
 Constructor for a valued value. More...
 
bool is_on () const
 Returns true if an unvalued enabled option.
 
bool is_off () const
 Returns true if an unvalued disabled option.
 
bool valued () const
 Returns true if constructed with the string overload, or false if constructed by on() or off() or the default constructor. More...
 
std::string value () const
 Returns the value as a string.
 
bool numeric () const
 Returns true if value() is an unsigned integer.
 
unsigned int number (unsigned int default_=0U) const
 Returns value() as an unsigned integer. More...
 

Static Public Member Functions

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

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

G::OptionValue::OptionValue ( const std::string &  s)
inlineexplicit

Constructor for a valued value.

Precondition: !s.empty()

Definition at line 89 of file goptionvalue.h.

Member Function Documentation

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 142 of file goptionvalue.h.

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

Returns true if constructed with the string overload, or false if constructed by on() or off() or the default constructor.

Note that a non-valued() value can still have a non-empty value().

Definition at line 124 of file goptionvalue.h.


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