A database of program command line and environment variable options and methods for manipulating them.
More...
#include <Ioss_GetLongOpt.h>
|
| GetLongOption (char optmark='-') |
| Create an empty options database.
|
|
| ~GetLongOption () |
| Frees dynamically allocated memory.
|
|
int | parse (int argc, char *const *argv) |
| parse command line arguments
|
|
int | parse (char *str, char *p) |
| parse an argument string.
|
|
bool | enroll (const char *opt, OptType t, const char *desc, const char *val, const char *optval=nullptr, bool extra_line=false) |
| Enroll a command line option into the database.
|
|
const char * | retrieve (const char *opt) const |
| Get a command line option object.
|
|
const char * | program_name () const |
|
void | usage (std::ostream &outfile=std::cout) const |
| Print the program usage string.
|
|
void | usage (const char *str) |
| Set the program usage string.
|
|
template<class INT , typename std::enable_if_t< std::is_integral_v< INT >, INT > * = nullptr> |
INT | get_option_value (const char *option_txt, INT default_value) |
|
template<class DBL , typename std::enable_if_t< std::is_floating_point_v< DBL >, DBL > * = nullptr> |
DBL | get_option_value (const char *option_txt, DBL default_value) |
|
std::string | get_option_value (const char *option_txt, const std::string &default_value) const |
|
|
static char * | basename (char *pathname) |
| Extract the base file name from a full path.
|
|
|
int | setcell (Cell *c, char *valtoken, char *nexttoken, const char *name) |
|
A database of program command line and environment variable options and methods for manipulating them.
A collection of long command line option names for a program that uses the Ioss library.
◆ OptType
Enumerator |
---|
NoValue | |
OptionalValue | |
MandatoryValue | |
◆ GetLongOption()
Ioss::GetLongOption::GetLongOption |
( |
char | optmark = '-' | ) |
|
|
explicit |
Create an empty options database.
- Parameters
-
optmark | The command line symbol designating options. |
◆ ~GetLongOption()
Ioss::GetLongOption::~GetLongOption |
( |
| ) |
|
Frees dynamically allocated memory.
Frees memory for the private struct variables representing the options.
◆ basename()
char * Ioss::GetLongOption::basename |
( |
char * | pathname | ) |
|
|
static |
Extract the base file name from a full path.
Finds the last instance of the '/' character and extracts the part of the string that follows.
- Parameters
-
[in] | pathname | The full path. |
- Returns
- The base file name.
◆ enroll()
bool Ioss::GetLongOption::enroll |
( |
const char * | opt, |
|
|
OptType | t, |
|
|
const char * | desc, |
|
|
const char * | val, |
|
|
const char * | optval = nullptr, |
|
|
bool | extra_line = false ) |
Enroll a command line option into the database.
Dynamically allocates memory for the option, sets its name type, description, value, and default value, and links it to the preceding option.
- Parameters
-
[in] | opt | The long option name. |
[in] | t | The option type. |
[in] | desc | A short description of the option. |
[in] | val | The option value. |
[in] | optval | The default value. |
[in] | extra_line | If true, add a blank line after this description output. |
- Returns
- 1 if successful, 0 if unsuccessful.
◆ get_option_value() [1/3]
std::string Ioss::GetLongOption::get_option_value |
( |
const char * | option_txt, |
|
|
const std::string & | default_value ) const |
|
inline |
◆ get_option_value() [2/3]
template<class DBL , typename std::enable_if_t< std::is_floating_point_v< DBL >, DBL > * = nullptr>
DBL Ioss::GetLongOption::get_option_value |
( |
const char * | option_txt, |
|
|
DBL | default_value ) |
|
inline |
◆ get_option_value() [3/3]
template<class INT , typename std::enable_if_t< std::is_integral_v< INT >, INT > * = nullptr>
INT Ioss::GetLongOption::get_option_value |
( |
const char * | option_txt, |
|
|
INT | default_value ) |
|
inline |
◆ parse() [1/2]
int Ioss::GetLongOption::parse |
( |
char * | str, |
|
|
char * | p ) |
parse an argument string.
Set the values of options in the option table based on the given option string.
- Parameters
-
[in] | str | The option string. |
[in] | p | A string to be used in error reporting |
- Returns
- 1 if successful, or -1 otherwise.
◆ parse() [2/2]
int Ioss::GetLongOption::parse |
( |
int | argc, |
|
|
char *const * | argv ) |
parse command line arguments
Set the values of options in the option table based on the given command line arguments.
- Parameters
-
- Returns
- Number of options processed, or -1 on failure.
◆ program_name()
const char * Ioss::GetLongOption::program_name |
( |
| ) |
const |
◆ retrieve()
const char * Ioss::GetLongOption::retrieve |
( |
const char * | opt | ) |
const |
Get a command line option object.
- Parameters
-
- Returns
- The option object.
◆ setcell()
int Ioss::GetLongOption::setcell |
( |
Cell * | c, |
|
|
char * | valtoken, |
|
|
char * | nexttoken, |
|
|
const char * | name ) |
|
private |
◆ usage() [1/2]
void Ioss::GetLongOption::usage |
( |
const char * | str | ) |
|
|
inline |
Set the program usage string.
The program usage string should define the command line syntax for program options and arguments and contain other helpful usage text.
- Parameters
-
◆ usage() [2/2]
void Ioss::GetLongOption::usage |
( |
std::ostream & | outfile = std::cout | ) |
const |
Print the program usage string.
- Parameters
-
[in] | outfile | The output stream to which the usage string is printed. |
◆ last
Cell* Ioss::GetLongOption::last {nullptr} |
|
private |
◆ options_parsed
bool Ioss::GetLongOption::options_parsed {false} |
|
private |
◆ optmarker
char Ioss::GetLongOption::optmarker |
|
private |
◆ pname
char* Ioss::GetLongOption::pname {nullptr} |
|
private |
◆ table
Cell* Ioss::GetLongOption::table {nullptr} |
|
private |
◆ ustring
const char* Ioss::GetLongOption::ustring {"[valid options and arguments]"} |
|
private |
The documentation for this class was generated from the following files: