IOSS 2.0

Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Ioss::GetLongOption Class Reference

A database of program command line and environment variable options and methods for manipulating them. More...

`#include <Ioss_GetLongOpt.h>`

Collaboration diagram for Ioss::GetLongOption:
[legend]

## Classes
struct | Cell

## Public Types
enum | OptType { NoValue, OptionalValue, MandatoryValue }

## Public Member Functions
| GetLongOption (char optmark='-')
| Create an empty options database. More...
| ~GetLongOption ()
| Frees dynamically allocated memory. More...
int | parse (int argc, char *const *argv)
| parse command line arguments More...
int | parse (char *str, char *p)
| parse an argument string. More...
int | enroll (const char *opt, OptType t, const char *desc, const char *val, const char *optval=nullptr)
| Enroll a command line option into the database. More...
const char * | retrieve (const char *opt) const
| Get a command line option object. More...
void | usage (std::ostream &outfile=std::cout) const
| Print the program usage string. More...
void | usage (const char *str)
| Set the program usage string. More...

## Static Public Member Functions
static char * | basename (char *pathname)
| Extract the base file name from a full path. More...

## Private Member Functions
int | setcell (Cell *c, char *valtoken, char *nexttoken, const char *name)

## Private Attributes
Cell * | table
const char * | ustring
char * | pname
Cell * | last
int | enroll_done
char | optmarker

## Detailed Description

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.

## Member Enumeration Documentation

## ◆ OptType

enum Ioss::GetLongOption::OptType

Enumerator
NoValue |
OptionalValue |
MandatoryValue |

## Constructor & Destructor Documentation

## ◆ 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.

## Member Function Documentation

## ◆ 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()

int Ioss::GetLongOption::enroll | ( | const char * | opt,
|  | OptType | t,
|  | const char * | desc,
|  | const char * | val,
|  | const char * | optval = `nullptr`
| ) |  |

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.

Returns
  1 if successful, 0 if unsuccessful.

## ◆ parse() [1/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

  [in] | argc | Number of command line arguments passed in from main(int argc, char *argv[]).
  [in] | argv | Command line arguments passed in from main(int argc, char *argv[]).

Returns
  Number of options processed, or -1 on failure.

## ◆ parse() [2/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.

## ◆ retrieve()

const char * Ioss::GetLongOption::retrieve | ( | const char * | opt | ) | const

Get a command line option object.

Parameters

  [in] | opt | The option name.

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 | ( | std::ostream & | outfile = `std::cout` | ) | const

Print the program usage string.

Parameters

  [in] | outfile | The output stream to which the usage string is printed.

## ◆ usage() [2/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

  [in] | str | The usage string.

## Member Data Documentation

## ◆ enroll_done

int Ioss::GetLongOption::enroll_done
| private

## ◆ last

Cell* Ioss::GetLongOption::last
| private

## ◆ optmarker

char Ioss::GetLongOption::optmarker
| private

## ◆ pname

char* Ioss::GetLongOption::pname
| private

## ◆ table

Cell* Ioss::GetLongOption::table
| private

## ◆ ustring

const char* Ioss::GetLongOption::ustring
| private

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

- src/Ioss_GetLongOpt.h
- src/Ioss_GetLongOpt.C