CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
Arguments Class Reference

Command line arguments parser More...

#include <cc/Arguments>

Public Member Functions

 Arguments (int argc, char *argv[])
 Read command line arguments and separate options from items.
 
List< Stringread (Out< Map< String, Variant > > options=None{})
 Parse and validate command line options.
 
void validate (const Map< String, Variant > &prototype)
 Check validity of command line arguments according to a prototype configuration.
 
void override (InOut< Map< String, Variant > > config) const
 Override config with command line options.
 
Map< String, Variantoptions () const
 Command line options (e.g.: "x=1", "-x" or "--x")
 
List< Stringitems () const
 Command line item arguments
 
String execPath () const
 Execution path.
 

Detailed Description

Command line arguments parser

Constructor & Destructor Documentation

◆ Arguments()

Arguments ( int argc,
char * argv[] )

Read command line arguments and separate options from items.

Parameters
argcNumber of arguments
argvArgument values
Exceptions
HelpRequestCommand line contains a help option (-h or --help)
VersionRequestCommand line contains a version option (-v or --version)

Member Function Documentation

◆ read()

List< String > read ( Out< Map< String, Variant > > options = None{})

Parse and validate command line options.

Returns
Command line items
Exceptions
UsageErrorif a non-existing option or an option of invalid type is encountered

◆ validate()

void validate ( const Map< String, Variant > & prototype)

Check validity of command line arguments according to a prototype configuration.

Parameters
prototypePrototype configuration
Exceptions
UsageErrorif a non-existing option or an option of invalid type is encountered

◆ override()

void override ( InOut< Map< String, Variant > > config) const

Override config with command line options.

◆ options()

Map< String, Variant > options ( ) const

Command line options (e.g.: "x=1", "-x" or "--x")

◆ items()

List< String > items ( ) const

Command line item arguments

◆ execPath()

String execPath ( ) const

Execution path.