![]() |
GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
|
![]() |
This class is used to parse the command line arguments.
Example usage:
This example reads the number after the flag "--some-option" or "-s" into the integer variable myOption. If no flag is provided, the default value of 42 is used.
The 3rd argument in ArgParser::option and ArgParser::parse that are set to true here are the "firstPass" arguments which simply means we want to read these options right away instead of reading something from an input file and only then parse the command line arguments.
Definition at line 317 of file ArgParser.h.
Public Member Functions | |
ArgParser ()=default | |
ArgParser (ArgParser &&) noexcept=default | |
ArgParser (const ArgParser &)=default | |
~ArgParser () | |
template<typename T > | |
ArgParseConfigT< std::vector< T > > & | default_option (std::vector< T > *output_location, bool firstPass) |
ArgParser & | operator= (ArgParser &&) noexcept=default |
ArgParser & | operator= (const ArgParser &)=default |
template<typename T > | |
ArgParseConfigT< T > & | option (const std::string flag, T *output_location, bool firstPass) |
void | parse (int argc, char **argv, bool firstPass) |
void | parse_file (std::string &filename) |
void | print (std::ostream &out) const |
Private Member Functions | |
ArgParseItem & | get_item (const std::string &flag) |
void | handle_default_option (int, char **argv, int &iarg, bool firstPass) |
void | handle_long_flag (int argc, char **argv, int &iarg, bool firstPass) |
void | handle_short_flag (int argc, char **argv, int &iarg, bool firstPass) |
Static Private Member Functions | |
static std::vector< std::string > | argument_list (int argc, char **argv, int &iarg, int max_args) |
Private Attributes | |
std::vector< ArgParseItem * > | values |
|
default |
|
default |
|
defaultnoexcept |
|
inline |
Definition at line 326 of file ArgParser.h.
References values.
|
inlinestaticprivate |
Reads arguments into a list until finding one that begins with '-'.
Definition at line 505 of file ArgParser.h.
Referenced by handle_long_flag(), and handle_short_flag().
|
inline |
Definition at line 420 of file ArgParser.h.
References option().
Referenced by TGRSIOptions::Load().
|
inlineprivate |
Definition at line 523 of file ArgParser.h.
References values.
Referenced by handle_default_option(), handle_long_flag(), handle_short_flag(), and parse_file().
|
inlineprivate |
Definition at line 495 of file ArgParser.h.
References get_item(), and ArgParseItem::parse().
Referenced by parse().
|
inlineprivate |
Definition at line 446 of file ArgParser.h.
References argument_list(), get_item(), ArgParseItem::num_arguments(), and ArgParseItem::parse().
Referenced by parse().
|
inlineprivate |
Definition at line 470 of file ArgParser.h.
References argument_list(), get_item(), ArgParseItem::num_arguments(), and ArgParseItem::parse().
Referenced by parse().
|
inline |
Definition at line 412 of file ArgParser.h.
References values.
Referenced by default_option(), TGRSIOptions::Load(), and main().
|
inline |
This version takes argc and argv, parses them, and sets only those that have the matching firstPass flag set. This allows us to parse command line arguments in two stages, one to get the normal options and file names (from which the run info and analysis options are read), and a second stage, where only the run info and analysis option flags are parsed.
Definition at line 333 of file ArgParser.h.
References handle_default_option(), handle_long_flag(), handle_short_flag(), and values.
Referenced by TGRSIOptions::Load(), and main().
|
inline |
Definition at line 365 of file ArgParser.h.
References get_item(), and ArgParseItem::parse().
Referenced by TGRSIOptions::Load().
|
inline |
Definition at line 425 of file ArgParser.h.
References ArgParseItem::printable(), and values.
Referenced by operator<<().
|
private |
Definition at line 540 of file ArgParser.h.
Referenced by ~ArgParser(), get_item(), option(), parse(), and print().