HAL
hal::ProgramArguments Class Reference

#include <program_arguments.h>

Collaboration diagram for hal::ProgramArguments:
Collaboration graph

Public Member Functions

 ProgramArguments (int argc, const char **argv)
 
 ProgramArguments ()
 
 ~ProgramArguments ()=default
 
void get_original_arguments (int *argc, const char ***argv)
 
std::vector< std::string > get_set_options () const
 
bool is_option_set (const std::string &flag) const
 
void set_option (const std::string &flag, const std::string &parameter)
 
void set_option (const std::string &flag, const std::vector< std::string > &parameters)
 
bool set_option (const std::string &flag, const std::set< std::string > &equivalent_flags, const std::vector< std::string > &parameters)
 
std::string get_parameter (const std::string &flag) const
 
std::vector< std::string > get_parameters (const std::string &flag) const
 

Detailed Description

Holds the program arguments that have been passed to HAL using the command line or at any other point in time during execution.

Definition at line 45 of file program_arguments.h.

Constructor & Destructor Documentation

◆ ProgramArguments() [1/2]

hal::ProgramArguments::ProgramArguments ( int  argc,
const char **  argv 
)

Constructor. Stores the command line arguments internally.

Parameters
[out]argc- Pointer to number of arguments.
[out]argv- Pointer to array of arguments.

Definition at line 13 of file program_arguments.cpp.

◆ ProgramArguments() [2/2]

hal::ProgramArguments::ProgramArguments ( )

Constructor. Stores no command line arguments internally.

Definition at line 7 of file program_arguments.cpp.

◆ ~ProgramArguments()

hal::ProgramArguments::~ProgramArguments ( )
default

Member Function Documentation

◆ get_original_arguments()

void hal::ProgramArguments::get_original_arguments ( int *  argc,
const char ***  argv 
)

Copies the original command line arguments into the parameters.

Parameters
[out]argc- Pointer to number of arguments.
[out]argv- Pointer to array of arguments.

Definition at line 19 of file program_arguments.cpp.

◆ get_parameter()

std::string hal::ProgramArguments::get_parameter ( const std::string &  flag) const

Returns the parameter of the option.
If the option expects more than one parameter, use get_parameters().
If the user did not supply a parameter, the default value is returned.

Parameters
[in]flag- A flag of the option. If the option was entered with multiple flags, any of these works.
Returns
The parameter for the option.

Definition at line 116 of file program_arguments.cpp.

References get_parameters().

◆ get_parameters()

std::vector< std::string > hal::ProgramArguments::get_parameters ( const std::string &  flag) const

Returns the parameters of the option.
If the option expects only one parameter, use the shorthand get_parameter().
If the user did not supply (all) parameters, the default values are returned in those places.

Parameters
[in]flag- A flag of the option. If the option was entered with multiple flags, any of these works.
Returns
The parameters for the option.

Definition at line 126 of file program_arguments.cpp.

References log_error.

Referenced by get_parameter().

◆ get_set_options()

std::vector< std::string > hal::ProgramArguments::get_set_options ( ) const

Returns all flags which were used to set options in the parsed arguments or programatically in order of appearance.

Returns
All used flags to set options.

Definition at line 25 of file program_arguments.cpp.

◆ is_option_set()

bool hal::ProgramArguments::is_option_set ( const std::string &  flag) const

Checks whether an option was set.
Any flag of the option works, even if one of the other flags was actually used to set the option.

Parameters
[in]flag- A flag of the option.
Returns
True, if the user entered a flag for this option.

Definition at line 30 of file program_arguments.cpp.

◆ set_option() [1/3]

bool hal::ProgramArguments::set_option ( const std::string &  flag,
const std::set< std::string > &  equivalent_flags,
const std::vector< std::string > &  parameters 
)

Programatically set an option (specifying a set of equivalent flags) and supply parameters.

Parameters
[in]flag- A single flag which is actually set.
[in]equivalent_flags- All flags for the same option.
[in]parameters- The parameters for this flag.
Returns
True, if the flags were not found in multiple disjunct options already.

Definition at line 53 of file program_arguments.cpp.

References hal::utils::join(), and log_error.

◆ set_option() [2/3]

void hal::ProgramArguments::set_option ( const std::string &  flag,
const std::string &  parameter 
)

Programatically set an option via a single flag and supply a parameter. This is just a shorthand for set_option(flag, {parameter});

Parameters
[in]flag- A flag of the option.
[in]parameter- The parameter for this flag.

Definition at line 43 of file program_arguments.cpp.

Referenced by set_option().

◆ set_option() [3/3]

void hal::ProgramArguments::set_option ( const std::string &  flag,
const std::vector< std::string > &  parameters 
)

Programatically set an option via a single flag and supply parameters.

Parameters
[in]flag- A flag of the option.
[in]parameters- The parameters for this flag.

Definition at line 48 of file program_arguments.cpp.

References set_option().


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