MPQC  3.0.0-alpha
sc::GetLongOpt Class Reference

Parse command line options. More...

#include <util/options/GetLongOpt.h>

Public Types

enum  OptType { NoValue, OptionalValue, MandatoryValue }
 Used by the enroll member to specify whether or not a value is expected or optional.
 

Public Member Functions

 GetLongOpt (const char optmark='-')
 Initialize the object. More...
 
int parse (int argc, char *const *argv)
 Parse command line options. More...
 
int parse (char *const str, char *const p)
 Parse options in a string. More...
 
int enroll (const char *const opt, const OptType t, const char *const desc, const char *const val)
 Enroll an option. More...
 
const char * retrieve (const char *const opt) const
 Retrieve an option. More...
 
void usage (std::ostream &outfile=std::cout) const
 Print usage information. More...
 
void usage (const char *str)
 Initialize usage synopsis. More...
 

Detailed Description

Parse command line options.

Constructor & Destructor Documentation

◆ GetLongOpt()

sc::GetLongOpt::GetLongOpt ( const char  optmark = '-')

Initialize the object.

Parameters
optmarkthe option flag marker (default is -).

Member Function Documentation

◆ enroll()

int sc::GetLongOpt::enroll ( const char *const  opt,
const OptType  t,
const char *const  desc,
const char *const  val 
)

Enroll an option.

Parameters
optthe option name
twhether or not a value is expected
desca description of the option
vala default value for the option with an optional value

◆ parse() [1/2]

int sc::GetLongOpt::parse ( char *const  str,
char *const  p 
)

Parse options in a string.

Parameters
strthe string to be parsed
pa prefix that will be prefixed to error messages
Returns
the index to the start of arguments that were not processed (an error occurred if the return value is < 1)

◆ parse() [2/2]

int sc::GetLongOpt::parse ( int  argc,
char *const *  argv 
)

Parse command line options.

Parameters
argcthe number of arguments, as passed to main
argvthe arguments, as passed to main
Returns
the index to the start of arguments that were not processed (an error occurred if the return value is < 1)

◆ retrieve()

const char* sc::GetLongOpt::retrieve ( const char *const  opt) const

Retrieve an option.

Parameters
optthe name of the option

◆ usage() [1/2]

void sc::GetLongOpt::usage ( const char *  str)
inline

Initialize usage synopsis.

Parameters
strthe usage synopsis

◆ usage() [2/2]

void sc::GetLongOpt::usage ( std::ostream &  outfile = std::cout) const

Print usage information.

Parameters
outfilestream to use for printing (default: std::cout)

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

Generated at Sun Jan 26 2020 23:24:06 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.