args-parser 6.3.3
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
 
void addArg (ArgIface &arg)
 Add argument.
 
void addArg (ArgIface *arg)
 Add argument.
 
virtual void addArg (ArgPtr arg)
 Add argument.
 
String name () const override
 
bool isWithValue () const override
 
bool isRequired () const override
 
virtual void setRequired (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
 
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 59 of file group_iface.hpp.

Member Typedef Documentation

◆ ArgPtr

Smart pointer to the argument.

Definition at line 64 of file group_iface.hpp.

◆ Arguments

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

List of child arguments.

Definition at line 66 of file group_iface.hpp.

Constructor & Destructor Documentation

◆ GroupIface()

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

Definition at line 69 of file group_iface.hpp.

◆ ~GroupIface()

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

Definition at line 76 of file group_iface.hpp.

Member Function Documentation

◆ addArg() [1/3]

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

Add argument.

Note
Developer should handle lifetime of the argument.

Definition at line 87 of file group_iface.hpp.

◆ addArg() [2/3]

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

Add argument.

Note
Developer should handle lifetime of the argument.

Definition at line 93 of file group_iface.hpp.

◆ addArg() [3/3]

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

Add argument.

Reimplemented in Args::Command, and Args::Command.

Definition at line 99 of file group_iface.hpp.

◆ argumentName()

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

Implements Args::ArgIface.

Definition at line 147 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 234 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 223 of file group_iface.hpp.

◆ children()

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

Definition at line 81 of file group_iface.hpp.

◆ clear()

void Args::GroupIface::clear ( )
inlineoverridevirtual

Clear state of the argument.

Implements Args::ArgIface.

Definition at line 171 of file group_iface.hpp.

◆ description()

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

Implements Args::ArgIface.

Definition at line 159 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 188 of file group_iface.hpp.

◆ flag()

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

Implements Args::ArgIface.

Definition at line 141 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 255 of file group_iface.hpp.

◆ isRequired()

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

Implements Args::ArgIface.

Definition at line 129 of file group_iface.hpp.

◆ isWithValue()

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

Implements Args::ArgIface.

Definition at line 123 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 165 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 117 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 211 of file group_iface.hpp.

◆ setCmdLine()

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

Set command line parser.

Reimplemented from Args::ArgIface.

Definition at line 246 of file group_iface.hpp.

◆ setRequired()

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

Set required flag.

Reimplemented in Args::Command.

Definition at line 135 of file group_iface.hpp.

◆ valueSpecifier()

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

Implements Args::ArgIface.

Definition at line 153 of file group_iface.hpp.

Member Data Documentation

◆ m_children

Arguments Args::GroupIface::m_children
protected

List of children.

Definition at line 275 of file group_iface.hpp.


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