cppassist  1.0.0.f4fab4f962ff
C++ sanctuary for small but powerful and frequently required, stand alone features.
Public Types | Public Member Functions | Protected Attributes | List of all members
cppassist::CommandLineParameter Class Reference

Command line parameter. More...

#include <cppassist/include/cppassist/cmdline/CommandLineParameter.h>

Public Types

enum  OptionalState { NonOptional = 0, Optional = 1 }
 State whether or not a parameter is optional. More...
 

Public Member Functions

 CommandLineParameter (const std::string &name, OptionalState optional=Optional)
 Constructor. More...
 
 ~CommandLineParameter ()
 Destructor. More...
 
const std::string & name () const
 Get parameter name. More...
 
void setName (const std::string &name)
 Set parameter name. More...
 
bool isOptional () const
 Check optional-flag. More...
 
OptionalState optional () const
 Check optional-flag. More...
 
void setOptional (OptionalState optional)
 Set optional-flag. More...
 
const std::string & value () const
 Get value. More...
 
void setValue (const std::string &value)
 Set value. More...
 

Protected Attributes

std::string m_name
 Parameter name (e.g., "filename") More...
 
OptionalState m_optional
 Optional-state. More...
 
std::string m_value
 Parameter value. More...
 

Detailed Description

Command line parameter.

A command line parameter is a stand-alone value that is specified on the command line. For example, a filename at the end of the command line can be required as a parameter.

Example: myapp <input> [<output>]

Member Enumeration Documentation

◆ OptionalState

State whether or not a parameter is optional.

Enumerator
NonOptional 
Optional 

Constructor & Destructor Documentation

◆ CommandLineParameter()

cppassist::CommandLineParameter::CommandLineParameter ( const std::string &  name,
OptionalState  optional = Optional 
)

Constructor.

Parameters
[in]nameParameter name (e.g., "filename")
[in]optionalOptional-state

◆ ~CommandLineParameter()

cppassist::CommandLineParameter::~CommandLineParameter ( )

Destructor.

Member Function Documentation

◆ name()

const std::string& cppassist::CommandLineParameter::name ( ) const

Get parameter name.

Returns
Parameter name (e.g., "filename")

◆ setName()

void cppassist::CommandLineParameter::setName ( const std::string &  name)

Set parameter name.

Parameters
[in]nameParameter name (e.g., "filename")

◆ isOptional()

bool cppassist::CommandLineParameter::isOptional ( ) const

Check optional-flag.

Returns
true if optional, else false

◆ optional()

OptionalState cppassist::CommandLineParameter::optional ( ) const

Check optional-flag.

Returns
Optional-state

◆ setOptional()

void cppassist::CommandLineParameter::setOptional ( OptionalState  optional)

Set optional-flag.

Parameters
[in]optionalOptional-state

◆ value()

const std::string& cppassist::CommandLineParameter::value ( ) const

Get value.

Returns
Parameter value

◆ setValue()

void cppassist::CommandLineParameter::setValue ( const std::string &  value)

Set value.

Parameters
[in]valueParameter value

Member Data Documentation

◆ m_name

std::string cppassist::CommandLineParameter::m_name
protected

Parameter name (e.g., "filename")

◆ m_optional

OptionalState cppassist::CommandLineParameter::m_optional
protected

Optional-state.

◆ m_value

std::string cppassist::CommandLineParameter::m_value
protected

Parameter value.


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