sptk2 logo
SPTK Home Page
Public Member Functions | List of all members
sptk::CommandLine::CommandLineParameter Class Reference

#include <CommandLine.h>

Inheritance diagram for sptk::CommandLine::CommandLineParameter:
sptk::CommandLine::CommandLineElement

Public Member Functions

 CommandLineParameter (const String &name, const String &shortName, const String &valueName, const String &validateValue, const Visibility &useWithCommands, const String &help)
 
String printableName () const override
 
void validate (const String &value) const override
 
bool hasValue () const override
 
Type type () const override
 
- Public Member Functions inherited from sptk::CommandLine::CommandLineElement
 CommandLineElement (const String &name, const String &shortName, const String &help, const Visibility &useWithCommands)
 
virtual ~CommandLineElement ()=default
 
virtual Type type () const
 
virtual String name () const
 
virtual String shortName () const
 
virtual bool hasValue () const
 
virtual void validate (const String &value) const
 
virtual String printableName () const
 
bool useWithCommand (const String &command) const
 
void formatHelp (size_t textWidth, Strings &formattedText) const
 
void printHelp (size_t nameWidth, size_t textWidth, const String &optionDefaultValue) const
 

Additional Inherited Members

- Public Types inherited from sptk::CommandLine::CommandLineElement
enum class  Type { IS_UNKNOWN , IS_COMMAND , IS_OPTION , IS_VALUE_OPTION }
 

Detailed Description

Command line parameter

Command line argument that starts from '-' character and expects a value. It may have a long name that starts from '–', and/or a short name, that starts from '-'. Value has human readable name, such as 'file name', 'text', 'number', etc.. and optional validation pattern that can be regular expression or empty string.

Constructor & Destructor Documentation

◆ CommandLineParameter()

sptk::CommandLine::CommandLineParameter::CommandLineParameter ( const String name,
const String shortName,
const String valueName,
const String validateValue,
const Visibility useWithCommands,
const String help 
)

Constructor

Parameters
nameElement name
shortNameShort element name (single character, options only)
valueNameValue name
validateValueValue validation regular expression
useWithCommandsElement visibility for a command (options only)
helpHelp (description) for the element

Member Function Documentation

◆ hasValue()

bool sptk::CommandLine::CommandLineParameter::hasValue ( ) const
overridevirtual

Returns true if element expects value

Reimplemented from sptk::CommandLine::CommandLineElement.

◆ printableName()

String sptk::CommandLine::CommandLineParameter::printableName ( ) const
overridevirtual

Returns element name in help print format

Reimplemented from sptk::CommandLine::CommandLineElement.

◆ type()

Type sptk::CommandLine::CommandLineParameter::type ( ) const
overridevirtual

Returns element type

Reimplemented from sptk::CommandLine::CommandLineElement.

◆ validate()

void sptk::CommandLine::CommandLineParameter::validate ( const String value) const
overridevirtual

Validates parameter value

Parameters
valueValue to validate

Reimplemented from sptk::CommandLine::CommandLineElement.


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

Fri Oct 14 2022 09:58:38: SPTK 5.4.1