Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
gnsstk::CommandLine Class Reference

Detailed Description

list of Options

Definition at line 63 of file CommandLine.hpp.

#include <CommandLine.hpp>

Classes

class  Option
 

Public Member Functions

void Add (char s, std::string l, std::string a, bool rep, bool req, bool *ptr, std::string predes, std::string des, bool doc=true)
 add a boolean option More...
 
void Add (char s, std::string l, std::string a, bool rep, bool req, double *ptr, std::string predes, std::string des, bool doc=true)
 add a double option More...
 
void Add (char s, std::string l, std::string a, bool rep, bool req, gnsstk::RinexSatID *ptr, std::string predes, std::string des, bool doc=true)
 add a RinexSatID option More...
 
void Add (char s, std::string l, std::string a, bool rep, bool req, int *ptr, std::string predes, std::string des, bool doc=true)
 add an integer option More...
 
void Add (char s, std::string l, std::string a, bool rep, bool req, std::string *ptr, std::string predes, std::string des, bool doc=true)
 add a string option More...
 
void Add (char s, std::string l, std::string a, bool rep, bool req, std::vector< gnsstk::RinexSatID > *ptr, std::string predes, std::string des, bool doc=true)
 add a vector<RinexSatID> option More...
 
void Add (char s, std::string l, std::string a, bool rep, bool req, std::vector< int > *ptr, std::string predes, std::string des, bool doc=true)
 add a vector integer option More...
 
void Add (char s, std::string l, std::string a, bool rep, bool req, std::vector< std::string > *ptr, std::string predes, std::string des, bool doc=true)
 add a vector<string> option More...
 
void Add_deprecated (std::string old_opt, std::string new_opt)
 
void Add_ignore (std::string opt, bool has_arg=false)
 
void Add_ignore_off (std::string opt)
 
void Add_ignore_on (std::string opt)
 
 CommandLine (void)
 
unsigned int count (std::string lopt)
 
void DefineUsageString (std::string str) noexcept
 Define the text after 'Usage: '; default is '<prgm> [options] ...'. More...
 
void DumpConfiguration (std::ostream &os, std::string tag=std::string())
 
bool hasErrors (void)
 
bool hasHelp (void)
 
void noArgsRequired (void)
 
void noExpansion (std::string l)
 
int ProcessCommandLine (int argc, char **argv, std::string PrgmDesc, std::string &Usage, std::string &Errors, std::vector< std::string > &Unrec)
 
void setToggle (std::string lstr, bool b=true)
 
 ~CommandLine (void)
 

Private Types

enum  OptionTypeEnum {
  typeUndefined =-1, typeBool, typeInt, typeVectorInt,
  typeDouble, typeString, typeVectorString, typeSat,
  typeVectorSat, typeCount
}
 types of options supported - easily expanded More...
 
typedef enum gnsstk::CommandLine::OptionTypeEnum typeOpt
 types of options supported - easily expanded More...
 

Private Member Functions

void BuildSyntaxPage (void)
 
void Parse (std::vector< std::string > &Args, std::string &Errors, std::vector< std::string > &Unrecog)
 
void Postprocess (std::string &Errors, std::vector< std::string > &Unrecog)
 
void PreProcessArgs (const char *arg, std::vector< std::string > &Args, std::string &Errors)
 
std::string SyntaxPage (void)
 
bool ValidateCommandLine (std::string &msg)
 

Private Attributes

int debug
 
std::map< std::string, std::string > deprec_opts
 
bool foundErrors
 
bool help
 
bool helponly
 
std::vector< std::string > ignore_off_opts
 list of strings '–opt' that turn "ignoring of args" OFF More...
 
std::vector< std::string > ignore_on_opts
 list of strings '–opt' that turn "ignoring of args" ON More...
 
std::vector< std::string > ignore_opts_with_arg
 list of strings '–opt' that, with their following arg, are ignored More...
 
std::vector< std::string > ignore_opts_without_arg
 list of strings '–opt' that are simply ignored More...
 
std::vector< Optionoptions
 list of Options More...
 
int optionsize
 
bool requireOneArg
 
std::string syntaxPage
 
int syntaxPageBuilt
 
bool verbose
 

Member Typedef Documentation

◆ typeOpt

types of options supported - easily expanded

Member Enumeration Documentation

◆ OptionTypeEnum

types of options supported - easily expanded

Enumerator
typeUndefined 
typeBool 
typeInt 
typeVectorInt 
typeDouble 
typeString 
typeVectorString 
typeSat 
typeVectorSat 
typeCount 

Definition at line 66 of file CommandLine.hpp.

Constructor & Destructor Documentation

◆ CommandLine()

gnsstk::CommandLine::CommandLine ( void  )
inline

Definition at line 152 of file CommandLine.hpp.

◆ ~CommandLine()

gnsstk::CommandLine::~CommandLine ( void  )
inline

Definition at line 157 of file CommandLine.hpp.

Member Function Documentation

◆ Add() [1/8]

void gnsstk::CommandLine::Add ( char  s,
std::string  l,
std::string  a,
bool  rep,
bool  req,
bool *  ptr,
std::string  predes,
std::string  des,
bool  doc = true 
)
inline

add a boolean option

Definition at line 197 of file CommandLine.hpp.

◆ Add() [2/8]

void gnsstk::CommandLine::Add ( char  s,
std::string  l,
std::string  a,
bool  rep,
bool  req,
double *  ptr,
std::string  predes,
std::string  des,
bool  doc = true 
)
inline

add a double option

Definition at line 221 of file CommandLine.hpp.

◆ Add() [3/8]

void gnsstk::CommandLine::Add ( char  s,
std::string  l,
std::string  a,
bool  rep,
bool  req,
gnsstk::RinexSatID ptr,
std::string  predes,
std::string  des,
bool  doc = true 
)
inline

add a RinexSatID option

Definition at line 246 of file CommandLine.hpp.

◆ Add() [4/8]

void gnsstk::CommandLine::Add ( char  s,
std::string  l,
std::string  a,
bool  rep,
bool  req,
int *  ptr,
std::string  predes,
std::string  des,
bool  doc = true 
)
inline

add an integer option

Definition at line 205 of file CommandLine.hpp.

◆ Add() [5/8]

void gnsstk::CommandLine::Add ( char  s,
std::string  l,
std::string  a,
bool  rep,
bool  req,
std::string *  ptr,
std::string  predes,
std::string  des,
bool  doc = true 
)
inline

add a string option

Definition at line 229 of file CommandLine.hpp.

◆ Add() [6/8]

void gnsstk::CommandLine::Add ( char  s,
std::string  l,
std::string  a,
bool  rep,
bool  req,
std::vector< gnsstk::RinexSatID > *  ptr,
std::string  predes,
std::string  des,
bool  doc = true 
)
inline

add a vector<RinexSatID> option

Definition at line 254 of file CommandLine.hpp.

◆ Add() [7/8]

void gnsstk::CommandLine::Add ( char  s,
std::string  l,
std::string  a,
bool  rep,
bool  req,
std::vector< int > *  ptr,
std::string  predes,
std::string  des,
bool  doc = true 
)
inline

add a vector integer option

Definition at line 213 of file CommandLine.hpp.

◆ Add() [8/8]

void gnsstk::CommandLine::Add ( char  s,
std::string  l,
std::string  a,
bool  rep,
bool  req,
std::vector< std::string > *  ptr,
std::string  predes,
std::string  des,
bool  doc = true 
)
inline

add a vector<string> option

Definition at line 237 of file CommandLine.hpp.

◆ Add_deprecated()

void gnsstk::CommandLine::Add_deprecated ( std::string  old_opt,
std::string  new_opt 
)
inline

add a deprecated option, that is let old_opt be equivalent to new_opt, where new_opt is the long option for one the the regular options.

Definition at line 192 of file CommandLine.hpp.

◆ Add_ignore()

void gnsstk::CommandLine::Add_ignore ( std::string  opt,
bool  has_arg = false 
)
inline

add an 'ignore' option, that is an option '–opt' that is simply ignored. if has_arg is true, the token following –opt (its argument) is also ignored.

Definition at line 176 of file CommandLine.hpp.

◆ Add_ignore_off()

void gnsstk::CommandLine::Add_ignore_off ( std::string  opt)
inline

add an 'ignore_off' option; this is an option '–opt' that turns off the 'ignoring of options' that was started by an 'ignore_on' option.

Definition at line 188 of file CommandLine.hpp.

◆ Add_ignore_on()

void gnsstk::CommandLine::Add_ignore_on ( std::string  opt)
inline

add an 'ignore_on' option; this is an option '–opt' that causes the options that follow to be ignored, until an 'ignore_off' option is found.

Definition at line 184 of file CommandLine.hpp.

◆ BuildSyntaxPage()

void gnsstk::CommandLine::BuildSyntaxPage ( void  )
private

Build the syntax page.

Exceptions
Exception
Exception

Definition at line 381 of file CommandLine.cpp.

◆ count()

unsigned int gnsstk::CommandLine::count ( std::string  lopt)
inline

Definition at line 162 of file CommandLine.hpp.

◆ DefineUsageString()

void gnsstk::CommandLine::DefineUsageString ( std::string  str)
inlinenoexcept

Define the text after 'Usage: '; default is '<prgm> [options] ...'.

Definition at line 296 of file CommandLine.hpp.

◆ DumpConfiguration()

void gnsstk::CommandLine::DumpConfiguration ( std::ostream &  os,
std::string  tag = std::string() 
)

Dump the configuration. Output is of the form longOpt Descript : values if tag is not empty (the default), begin each line with it.

Exceptions
Exception
Exception

Definition at line 180 of file CommandLine.cpp.

◆ hasErrors()

bool gnsstk::CommandLine::hasErrors ( void  )
inline

Definition at line 161 of file CommandLine.hpp.

◆ hasHelp()

bool gnsstk::CommandLine::hasHelp ( void  )
inline

Definition at line 160 of file CommandLine.hpp.

◆ noArgsRequired()

void gnsstk::CommandLine::noArgsRequired ( void  )
inline

Definition at line 171 of file CommandLine.hpp.

◆ noExpansion()

void gnsstk::CommandLine::noExpansion ( std::string  l)
inline

modify a Vector option; string l must match long option string passed to constructor: turn off expansion of arguments ('a,b,c' -> 'a' 'b' and 'c')

Definition at line 265 of file CommandLine.hpp.

◆ Parse()

void gnsstk::CommandLine::Parse ( std::vector< std::string > &  Args,
std::string &  Errors,
std::vector< std::string > &  Unrecog 
)
private

Parse the (preprocessed) list of args.

Exceptions
Exception
Exception

Definition at line 679 of file CommandLine.cpp.

◆ Postprocess()

void gnsstk::CommandLine::Postprocess ( std::string &  Errors,
std::vector< std::string > &  Unrecog 
)
private

Post process - convert value strings to real values.

Exceptions
Exception
Exception

Definition at line 803 of file CommandLine.cpp.

◆ PreProcessArgs()

void gnsstk::CommandLine::PreProcessArgs ( const char *  arg,
std::vector< std::string > &  Args,
std::string &  Errors 
)
private

Preprocess the arguments by pulling out debug, etc, replace deprecated options, drop ignored options, open –file files, open list files and parse comma-separated values

Exceptions
Exception
Exception

Definition at line 483 of file CommandLine.cpp.

◆ ProcessCommandLine()

int gnsstk::CommandLine::ProcessCommandLine ( int  argc,
char **  argv,
std::string  PrgmDesc,
std::string &  Usage,
std::string &  Errors,
std::vector< std::string > &  Unrec 
)

Create the command line = list of commands; parse it

Parameters
argcthe number of command line args
argvcommand line args
PrgmDescstring giving program description, shown at top of syntax page
Usagestring return syntax page
Errorsstring return all error messages
Unrecvector of strings not recognized by parser
Returns
-3 an error was found in the definition of command line options -2 an error occurred (e.g. new failed) -1 an error was found on the command line 0 ok 1 help was requested
Exceptions
Exception
Exception

Definition at line 80 of file CommandLine.cpp.

◆ setToggle()

void gnsstk::CommandLine::setToggle ( std::string  lstr,
bool  b = true 
)
inline

Modify a Bool option; string l must match long option string passed to constructor: when option is found, toggle instead of setting true If toggle is true, argument toggles the value rather than just setting it true.

Parameters
lstrlong option string which identifies the option to be changed
bbool set 'toggle' switch to this, default true

Definition at line 284 of file CommandLine.hpp.

◆ SyntaxPage()

string gnsstk::CommandLine::SyntaxPage ( void  )
private

Generate the usage string (syntax page)

Exceptions
Exception
Exception

Definition at line 769 of file CommandLine.cpp.

◆ ValidateCommandLine()

bool gnsstk::CommandLine::ValidateCommandLine ( std::string &  msg)
private

Determine if the command line, as declared, is valid.

Exceptions
Exception
Exception

Definition at line 294 of file CommandLine.cpp.

Member Data Documentation

◆ debug

int gnsstk::CommandLine::debug
private

Definition at line 124 of file CommandLine.hpp.

◆ deprec_opts

std::map<std::string,std::string> gnsstk::CommandLine::deprec_opts
private

for deprecated options - substitutions: if key is found, replace it with value; value must be the longOpt of an option. Include '–' in the strings

Definition at line 147 of file CommandLine.hpp.

◆ foundErrors

bool gnsstk::CommandLine::foundErrors
private

Definition at line 123 of file CommandLine.hpp.

◆ help

bool gnsstk::CommandLine::help
private

Definition at line 123 of file CommandLine.hpp.

◆ helponly

bool gnsstk::CommandLine::helponly
private

Definition at line 123 of file CommandLine.hpp.

◆ ignore_off_opts

std::vector<std::string> gnsstk::CommandLine::ignore_off_opts
private

list of strings '–opt' that turn "ignoring of args" OFF

Definition at line 143 of file CommandLine.hpp.

◆ ignore_on_opts

std::vector<std::string> gnsstk::CommandLine::ignore_on_opts
private

list of strings '–opt' that turn "ignoring of args" ON

Definition at line 140 of file CommandLine.hpp.

◆ ignore_opts_with_arg

std::vector<std::string> gnsstk::CommandLine::ignore_opts_with_arg
private

list of strings '–opt' that, with their following arg, are ignored

Definition at line 134 of file CommandLine.hpp.

◆ ignore_opts_without_arg

std::vector<std::string> gnsstk::CommandLine::ignore_opts_without_arg
private

list of strings '–opt' that are simply ignored

Definition at line 137 of file CommandLine.hpp.

◆ options

std::vector<Option> gnsstk::CommandLine::options
private

list of Options

Definition at line 131 of file CommandLine.hpp.

◆ optionsize

int gnsstk::CommandLine::optionsize
private

Definition at line 128 of file CommandLine.hpp.

◆ requireOneArg

bool gnsstk::CommandLine::requireOneArg
private

Definition at line 123 of file CommandLine.hpp.

◆ syntaxPage

std::string gnsstk::CommandLine::syntaxPage
private

Definition at line 127 of file CommandLine.hpp.

◆ syntaxPageBuilt

int gnsstk::CommandLine::syntaxPageBuilt
private

Definition at line 126 of file CommandLine.hpp.

◆ verbose

bool gnsstk::CommandLine::verbose
private

Definition at line 123 of file CommandLine.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44