IOSS  2.0
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

Celltable
 
const char * ustring
 
char * pname
 
Celllast
 
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

Enumerator
NoValue 
OptionalValue 
MandatoryValue 

Constructor & Destructor Documentation

◆ GetLongOption()

Ioss::GetLongOption::GetLongOption ( char  optmark = '-')
explicit

Create an empty options database.

Parameters
optmarkThe 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]pathnameThe 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]optThe long option name.
[in]tThe option type.
[in]descA short description of the option.
[in]valThe option value.
[in]optvalThe default value.
Returns
1 if successful, 0 if unsuccessful.

◆ 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]strThe option string.
[in]pA 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
[in]argcNumber of command line arguments passed in from main(int argc, char *argv[]).
[in]argvCommand line arguments passed in from main(int argc, char *argv[]).
Returns
Number of options processed, or -1 on failure.

◆ retrieve()

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

Get a command line option object.

Parameters
[in]optThe 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 ( 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]strThe usage string.

◆ usage() [2/2]

void Ioss::GetLongOption::usage ( std::ostream &  outfile = std::cout) const

Print the program usage string.

Parameters
[in]outfileThe output stream to which the usage string is printed.

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: