args-parser 6.3.6
Loading...
Searching...
No Matches
Args::GroupIface Class Reference

Interface for the groups. More...

#include <group_iface.hpp>

Inheritance diagram for Args::GroupIface:
Collaboration diagram for Args::GroupIface:

Public Types

using ArgPtr = std::unique_ptr<ArgIface, details::Deleter<ArgIface>>
 Smart pointer to the argument.
using Arguments = std::vector<ArgPtr>
 List of child arguments.

Public Member Functions

template<typename T>
 GroupIface (T &&name, bool required=false)
virtual ~GroupIface ()
const Argumentschildren () const
GroupIfaceaddArg (ArgIface &arg)
 Add argument.
GroupIfaceaddArg (ArgIface *arg)
 Add argument.
virtual GroupIfaceaddArg (ArgPtr arg)
 Add argument.
String name () const override
bool isWithValue () const override
bool isRequired () const override
virtual GroupIfacesetRequired (bool on=true)
 Set required flag.
const Stringflag () const override
const StringargumentName () const override
const StringvalueSpecifier () const override
const Stringdescription () const override
const StringlongDescription () const override
void clear () override
 Clear state of the argument.
Public Member Functions inherited from Args::ArgIface
 ArgIface ()
virtual ~ArgIface ()
virtual ArgType type () const =0
virtual bool isDefined () const =0
virtual const StringdefaultValue () const
CmdLinecmdLine () const

Protected Member Functions

ArgIfacefindArgument (const String &name) override
void process (Context &) override
 Process argument's staff, for example take values from context.
void checkCorrectnessBeforeParsing (StringList &flags, StringList &names) const override
 Check correctness of the argument before parsing.
void checkCorrectnessAfterParsing () const override
 Check correctness of the argument after parsing.
void setCmdLine (CmdLine *cmdLine) override
 Set command line parser.
bool isMisspelledName (const String &name, StringList &possibleNames) const override

Protected Attributes

Arguments m_children
 List of children.

Detailed Description

Interface for the groups.

Definition at line 33 of file group_iface.hpp.

Member Typedef Documentation

◆ ArgPtr

Smart pointer to the argument.

Definition at line 37 of file group_iface.hpp.

◆ Arguments

using Args::GroupIface::Arguments = std::vector<ArgPtr>

List of child arguments.

Definition at line 39 of file group_iface.hpp.

Constructor & Destructor Documentation

◆ GroupIface()

template<typename T>
Args::GroupIface::GroupIface ( T && name,
bool required = false )
inlineexplicit

Definition at line 42 of file group_iface.hpp.

◆ ~GroupIface()

virtual Args::GroupIface::~GroupIface ( )
inlinevirtual

Definition at line 49 of file group_iface.hpp.

Member Function Documentation

◆ addArg() [1/3]

GroupIface & Args::GroupIface::addArg ( ArgIface & arg)
inline

Add argument.

Note
Developer should handle lifetime of the argument.

Definition at line 60 of file group_iface.hpp.

◆ addArg() [2/3]

GroupIface & Args::GroupIface::addArg ( ArgIface * arg)
inline

Add argument.

Note
Developer should handle lifetime of the argument.

Definition at line 66 of file group_iface.hpp.

◆ addArg() [3/3]

virtual GroupIface & Args::GroupIface::addArg ( ArgPtr arg)
inlinevirtual

Add argument.

Reimplemented in Args::Command.

Definition at line 72 of file group_iface.hpp.

◆ argumentName()

const String & Args::GroupIface::argumentName ( ) const
inlineoverridevirtual
Returns
Argument name.

Implements Args::ArgIface.

Definition at line 121 of file group_iface.hpp.

◆ checkCorrectnessAfterParsing()

void Args::GroupIface::checkCorrectnessAfterParsing ( ) const
inlineoverrideprotectedvirtual

Check correctness of the argument after parsing.

Implements Args::ArgIface.

Reimplemented in Args::OnlyOneGroup.

Definition at line 210 of file group_iface.hpp.

◆ checkCorrectnessBeforeParsing()

void Args::GroupIface::checkCorrectnessBeforeParsing ( StringList & flags,
StringList & names ) const
inlineoverrideprotectedvirtual

Check correctness of the argument before parsing.

Implementation of this method must add his flag and name to the flags and names.

Parameters
flagsAll known flags.
namesAll known names.

Implements Args::ArgIface.

Reimplemented in Args::OnlyOneGroup.

Definition at line 198 of file group_iface.hpp.

◆ children()

const Arguments & Args::GroupIface::children ( ) const
inline
Returns
List of children.

Definition at line 54 of file group_iface.hpp.

◆ clear()

void Args::GroupIface::clear ( )
inlineoverridevirtual

Clear state of the argument.

Implements Args::ArgIface.

Definition at line 145 of file group_iface.hpp.

◆ description()

const String & Args::GroupIface::description ( ) const
inlineoverridevirtual
Returns
Description of the argument.

Implements Args::ArgIface.

Definition at line 133 of file group_iface.hpp.

◆ findArgument()

ArgIface * Args::GroupIface::findArgument ( const String & name)
inlineoverrideprotectedvirtual
Returns
Argument for the given name.
Return values
Pointerto the ArgIface if this argument handles argument with the given name.
nullptrif this argument doesn't know about argument with name.
Note
Looks only in children.
Parameters
nameName of the argument. Can be for example "-t" or "--timeout".

Implements Args::ArgIface.

Definition at line 163 of file group_iface.hpp.

◆ flag()

const String & Args::GroupIface::flag ( ) const
inlineoverridevirtual
Returns
Flag.

Implements Args::ArgIface.

Definition at line 115 of file group_iface.hpp.

◆ isMisspelledName()

bool Args::GroupIface::isMisspelledName ( const String & name,
StringList & possibleNames ) const
inlineoverrideprotectedvirtual
Returns
Is given name a misspelled name of the argument.
Parameters
nameName to check (misspelled).
possibleNamesList of possible names for the given misspelled name.

Implements Args::ArgIface.

Definition at line 232 of file group_iface.hpp.

◆ isRequired()

bool Args::GroupIface::isRequired ( ) const
inlineoverridevirtual
Returns
Is this argument required?

Implements Args::ArgIface.

Definition at line 102 of file group_iface.hpp.

◆ isWithValue()

bool Args::GroupIface::isWithValue ( ) const
inlineoverridevirtual
Returns
Is this argument with value?

Implements Args::ArgIface.

Definition at line 96 of file group_iface.hpp.

◆ longDescription()

const String & Args::GroupIface::longDescription ( ) const
inlineoverridevirtual
Returns
Long description of the argument.

Implements Args::ArgIface.

Definition at line 139 of file group_iface.hpp.

◆ name()

String Args::GroupIface::name ( ) const
inlineoverridevirtual
Returns
Name of the argument.

If name is empty returned value should be a flag. I.e. for example "-t" or "--timeout"

Implements Args::ArgIface.

Definition at line 90 of file group_iface.hpp.

◆ process()

void Args::GroupIface::process ( Context & )
inlineoverrideprotectedvirtual

Process argument's staff, for example take values from context.

This method invokes exactly at that moment when parser has found this argument.

Implements Args::ArgIface.

Definition at line 186 of file group_iface.hpp.

◆ setCmdLine()

void Args::GroupIface::setCmdLine ( CmdLine * cmdLine)
inlineoverrideprotectedvirtual

Set command line parser.

Reimplemented from Args::ArgIface.

Definition at line 222 of file group_iface.hpp.

◆ setRequired()

virtual GroupIface & Args::GroupIface::setRequired ( bool on = true)
inlinevirtual

Set required flag.

Reimplemented in Args::Command.

Definition at line 108 of file group_iface.hpp.

◆ valueSpecifier()

const String & Args::GroupIface::valueSpecifier ( ) const
inlineoverridevirtual
Returns
Value specifier.

Implements Args::ArgIface.

Definition at line 127 of file group_iface.hpp.

Member Data Documentation

◆ m_children

Arguments Args::GroupIface::m_children
protected

List of children.

Definition at line 250 of file group_iface.hpp.


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