OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
|
#include <ossimArgumentParser.h>
Classes | |
class | ossimParameter |
Public Types | |
enum | ossimErrorSeverity { OSSIM_BENIGN = 0, OSSIM_CRITICAL = 1 } |
typedef std::map< std::string, ossimErrorSeverity > | ossimErrorMessageMap |
Public Member Functions | |
ossimArgumentParser (int *argc, char **argv) | |
ossimArgumentParser (const ossimString &commandLine) | |
~ossimArgumentParser () | |
void | initialize (int *argc, const char **argv) |
Initialize from command arguments. More... | |
void | setApplicationUsage (ossimApplicationUsage *usage) |
ossimApplicationUsage * | getApplicationUsage () |
const ossimApplicationUsage * | getApplicationUsage () const |
int & | argc () |
return the argument count. More... | |
char ** | argv () |
return the argument array. More... | |
char * | operator[] (int pos) |
return char* argument at specificed position. More... | |
const char * | operator[] (int pos) const |
return const char* argument at specificed position. More... | |
std::string | getApplicationName () const |
return the application name, as specified by argv[0] More... | |
int | find (const std::string &str) const |
return the position of an occurence of a string in the argument list. More... | |
bool | isOption (int pos) const |
return return true if specified parameter is an option in the form of -option or –option . More... | |
bool | isString (int pos) const |
return return true if specified parameter is an string, which can be any other string apart from an option. More... | |
bool | isNumber (int pos) const |
return return true if specified parameter is an number. More... | |
bool | containsOptions () const |
void | remove (int pos, int num=1) |
remove one or more arguments from the argv argument list, and decrement the argc respectively. More... | |
void | insert (int pos, const ossimString &arg) |
Inserts string into the argv argument list, and increment the argc respectively. More... | |
bool | match (int pos, const std::string &str) const |
return true if specified argument matches string. More... | |
bool | read (const std::string &str) |
search for an occurance of a string in the argument list, on sucess remove that occurance from the list and return true, otherwise return false. More... | |
bool | read (const std::string &str, ossimParameter value1) |
bool | read (const std::string &str, ossimParameter value1, ossimParameter value2) |
bool | read (const std::string &str, ossimParameter value1, ossimParameter value2, ossimParameter value3) |
bool | read (const std::string &str, ossimParameter value1, ossimParameter value2, ossimParameter value3, ossimParameter value4) |
bool | read (const std::string &str, ossimParameter value1, ossimParameter value2, ossimParameter value3, ossimParameter value4, ossimParameter value5) |
bool | read (const std::string &str, ossimParameter value1, ossimParameter value2, ossimParameter value3, ossimParameter value4, ossimParameter value5, ossimParameter value6) |
bool | read (const std::string &str, std::vector< ossimString > ¶m_list) |
Alternate form for reading variable length arguments (must be comma-separated), e.g.,. More... | |
int | numberOfParams (const std::string &str, const ossimParameter value) const |
bool | read (int pos, const std::string &str) |
if the argument value at the position pos matches specified string, and subsequent paramters are also matched then set the paramter values and remove the from the list of arguments. More... | |
bool | read (int pos, const std::string &str, ossimParameter value1) |
bool | read (int pos, const std::string &str, ossimParameter value1, ossimParameter value2) |
bool | read (int pos, const std::string &str, ossimParameter value1, ossimParameter value2, ossimParameter value3) |
bool | read (int pos, const std::string &str, ossimParameter value1, ossimParameter value2, ossimParameter value3, ossimParameter value4) |
bool | errors (ossimErrorSeverity severity=OSSIM_BENIGN) const |
void | reportError (const std::string &message, ossimErrorSeverity severity=OSSIM_CRITICAL) |
report an error message by adding to the ErrorMessageMap. More... | |
void | reportRemainingOptionsAsUnrecognized (ossimErrorSeverity severity=OSSIM_BENIGN) |
for each remaining option report it as an unrecongnized. More... | |
ossimErrorMessageMap & | getErrorMessageMap () |
const ossimErrorMessageMap & | getErrorMessageMap () const |
void | writeErrorMessages (std::ostream &output, ossimErrorSeverity sevrity=OSSIM_BENIGN) |
write out error messages at an above specified . More... | |
Static Public Member Functions | |
static bool | isOption (const char *str) |
return return true if specified string is an option in the form of -option or –option . More... | |
static bool | isString (const char *str) |
return return true if string is any other string apart from an option. More... | |
static bool | isNumber (const char *str) |
return return true if specified parameter is an number. More... | |
Protected Attributes | |
int * | theArgc |
char ** | theArgv |
ossimErrorMessageMap | theErrorMessageMap |
ossimApplicationUsage * | theUsage |
bool | theMemAllocated |
Definition at line 18 of file ossimArgumentParser.h.
typedef std::map<std::string,ossimErrorSeverity> ossimArgumentParser::ossimErrorMessageMap |
Definition at line 212 of file ossimArgumentParser.h.
ossimArgumentParser::ossimArgumentParser | ( | int * | argc, |
char ** | argv | ||
) |
Definition at line 169 of file ossimArgumentParser.cpp.
References argv(), ossimApplicationUsage::setApplicationName(), theArgc, and theUsage.
ossimArgumentParser::ossimArgumentParser | ( | const ossimString & | commandLine | ) |
Definition at line 179 of file ossimArgumentParser.cpp.
References n, ossimApplicationUsage::setApplicationName(), ossimString::split(), theArgc, theArgv, and theUsage.
ossimArgumentParser::~ossimArgumentParser | ( | ) |
Definition at line 201 of file ossimArgumentParser.cpp.
References theArgc, theArgv, and theMemAllocated.
|
inline |
return the argument count.
Definition at line 109 of file ossimArgumentParser.h.
Referenced by ossimEquationUtil::execute(), ossimVerticesFinderTool::initialize(), ossimPointCloudTool::initialize(), ossimBatchTest::initialize(), initialize(), ossimChipProcTool::processRemainingArgs(), and reportRemainingOptionsAsUnrecognized().
|
inline |
return the argument array.
Definition at line 112 of file ossimArgumentParser.h.
Referenced by ossimBatchTest::initialize(), initialize(), and ossimArgumentParser().
bool ossimArgumentParser::containsOptions | ( | ) | const |
Definition at line 262 of file ossimArgumentParser.cpp.
References isOption(), and theArgc.
bool ossimArgumentParser::errors | ( | ossimErrorSeverity | severity = OSSIM_BENIGN | ) | const |
Definition at line 594 of file ossimArgumentParser.cpp.
References theErrorMessageMap.
Referenced by ossimBatchTest::initialize(), and ossimChipProcTool::processRemainingArgs().
int ossimArgumentParser::find | ( | const std::string & | str | ) | const |
return the position of an occurence of a string in the argument list.
return -1 when no string is found.
Definition at line 245 of file ossimArgumentParser.cpp.
References theArgc, and theArgv.
Referenced by numberOfParams(), and read().
std::string ossimArgumentParser::getApplicationName | ( | ) | const |
return the application name, as specified by argv[0]
Definition at line 224 of file ossimArgumentParser.cpp.
References theArgc, and theArgv.
Referenced by ossimPointCloudTool::addArguments(), ossimImageUtil::addArguments(), ossimAutRegUtil::addArguments(), ossimChipperUtil::addArguments(), ossimEquationUtil::ossimEquationUtil(), reportRemainingOptionsAsUnrecognized(), ossimRegTool::setUsage(), ossimVerticesFinderTool::setUsage(), ossimBandMergeTool::setUsage(), ossimPotraceTool::setUsage(), ossimDemTool::setUsage(), ATP::ossimAtpTool::setUsage(), ossimOrthoTool::setUsage(), ossimSlopeTool::setUsage(), ossimSubImageTool::setUsage(), ossimViewshedTool::setUsage(), ossimHdf5Tool::setUsage(), ossimHlzTool::setUsage(), ossimHillshadeTool::setUsage(), ossimShorelineTool::setUsage(), ossimInfo::setUsage(), ossimChipProcTool::setUsage(), ossimTool::setUsage(), ossimAutRegUtil::usage(), ossimImageUtil::usage(), ossimChipperUtil::usage(), and writeErrorMessages().
|
inline |
Definition at line 105 of file ossimArgumentParser.h.
Referenced by ossimPointCloudTool::addArguments(), ossimImageUtil::addArguments(), ossimAutRegUtil::addArguments(), ossimChipperUtil::addArguments(), ossimInit::addOptions(), ossimTool::initialize(), ossimBandMergeTool::setUsage(), ossimRegTool::setUsage(), ossimVerticesFinderTool::setUsage(), ossimPotraceTool::setUsage(), ATP::ossimAtpTool::setUsage(), ossimDemTool::setUsage(), ossimOrthoTool::setUsage(), ossimSlopeTool::setUsage(), ossimSubImageTool::setUsage(), ossimHdf5Tool::setUsage(), ossimViewshedTool::setUsage(), ossimHlzTool::setUsage(), ossimHillshadeTool::setUsage(), ossimShorelineTool::setUsage(), ossimInfo::setUsage(), ossimChipProcTool::setUsage(), ossimTool::setUsage(), ossimPointCloudTool::usage(), ossimBatchTest::usage(), ossimAutRegUtil::usage(), ossimImageUtil::usage(), and ossimChipperUtil::usage().
|
inline |
Definition at line 106 of file ossimArgumentParser.h.
ossimArgumentParser::ossimErrorMessageMap & ossimArgumentParser::getErrorMessageMap | ( | ) |
Definition at line 649 of file ossimArgumentParser.cpp.
References theErrorMessageMap.
const ossimArgumentParser::ossimErrorMessageMap & ossimArgumentParser::getErrorMessageMap | ( | ) | const |
Definition at line 654 of file ossimArgumentParser.cpp.
References theErrorMessageMap.
void ossimArgumentParser::initialize | ( | int * | argc, |
const char ** | argv | ||
) |
Initialize from command arguments.
Definition at line 212 of file ossimArgumentParser.cpp.
References argc(), argv(), theArgc, and theArgv.
void ossimArgumentParser::insert | ( | int | pos, |
const ossimString & | arg | ||
) |
Inserts string into the argv argument list, and increment the argc respectively.
If string contains spaces, it will be split up into component simple strings.
Definition at line 299 of file ossimArgumentParser.cpp.
References ossimString::size(), ossimString::split(), theArgc, theArgv, and theMemAllocated.
|
static |
return return true if specified parameter is an number.
Definition at line 32 of file ossimArgumentParser.cpp.
Referenced by isNumber().
bool ossimArgumentParser::isNumber | ( | int | pos | ) | const |
return return true if specified parameter is an number.
Definition at line 240 of file ossimArgumentParser.cpp.
References isNumber(), theArgc, and theArgv.
|
static |
return return true if specified string is an option in the form of -option or –option .
Definition at line 19 of file ossimArgumentParser.cpp.
Referenced by containsOptions(), isOption(), and reportRemainingOptionsAsUnrecognized().
bool ossimArgumentParser::isOption | ( | int | pos | ) | const |
return return true if specified parameter is an option in the form of -option or –option .
Definition at line 230 of file ossimArgumentParser.cpp.
References isOption(), theArgc, and theArgv.
|
static |
return return true if string is any other string apart from an option.
Definition at line 24 of file ossimArgumentParser.cpp.
Referenced by isString().
bool ossimArgumentParser::isString | ( | int | pos | ) | const |
return return true if specified parameter is an string, which can be any other string apart from an option.
Definition at line 235 of file ossimArgumentParser.cpp.
References isString(), theArgc, and theArgv.
bool ossimArgumentParser::match | ( | int | pos, |
const std::string & | str | ||
) | const |
return true if specified argument matches string.
Definition at line 257 of file ossimArgumentParser.cpp.
References theArgc, and theArgv.
Referenced by read().
int ossimArgumentParser::numberOfParams | ( | const std::string & | str, |
const ossimParameter | value | ||
) | const |
Definition at line 271 of file ossimArgumentParser.cpp.
References find(), theArgv, and ossimArgumentParser::ossimParameter::valid().
|
inline |
|
inline |
return const char* argument at specificed position.
Definition at line 118 of file ossimArgumentParser.h.
bool ossimArgumentParser::read | ( | const std::string & | str | ) |
search for an occurance of a string in the argument list, on sucess remove that occurance from the list and return true, otherwise return false.
Definition at line 331 of file ossimArgumentParser.cpp.
References find().
Referenced by ossimEquationUtil::execute(), ossimVerticesFinderTool::initialize(), ossimBandMergeTool::initialize(), ossimRegTool::initialize(), ossimPotraceTool::initialize(), ATP::ossimAtpTool::initialize(), ossimDemTool::initialize(), ossimPointCloudTool::initialize(), ossimTool::initialize(), ossimHlzTool::initialize(), ossimViewshedTool::initialize(), ossimSubImageTool::initialize(), ossimHdf5Tool::initialize(), ossimHillshadeTool::initialize(), ossimShorelineTool::initialize(), ossimBatchTest::initialize(), ossimChipProcTool::initialize(), ossimInit::parseEnvOptions(), ossimInit::parseNotifyOption(), and ossimChipProcTool::processRemainingArgs().
bool ossimArgumentParser::read | ( | const std::string & | str, |
ossimParameter | value1 | ||
) |
Definition at line 339 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), find(), reportError(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | const std::string & | str, |
ossimParameter | value1, | ||
ossimParameter | value2 | ||
) |
Definition at line 353 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), find(), reportError(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | const std::string & | str, |
ossimParameter | value1, | ||
ossimParameter | value2, | ||
ossimParameter | value3 | ||
) |
Definition at line 370 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), find(), reportError(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | const std::string & | str, |
ossimParameter | value1, | ||
ossimParameter | value2, | ||
ossimParameter | value3, | ||
ossimParameter | value4 | ||
) |
Definition at line 389 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), find(), reportError(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | const std::string & | str, |
ossimParameter | value1, | ||
ossimParameter | value2, | ||
ossimParameter | value3, | ||
ossimParameter | value4, | ||
ossimParameter | value5 | ||
) |
Definition at line 411 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), find(), reportError(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | const std::string & | str, |
ossimParameter | value1, | ||
ossimParameter | value2, | ||
ossimParameter | value3, | ||
ossimParameter | value4, | ||
ossimParameter | value5, | ||
ossimParameter | value6 | ||
) |
Definition at line 435 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), find(), reportError(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | const std::string & | str, |
std::vector< ossimString > & | param_list | ||
) |
Alternate form for reading variable length arguments (must be comma-separated), e.g.,.
–input_files file1, file2, file3,file4 next_arg
Note that spaces between arguments are optional. The next_arg entry will not be considered part of the list since there's no comma separator and will be left on the argument array.
str | The option string (with "-" or "--") |
param_list | Vector to contain results as strings. Always cleared before populating |
Definition at line 462 of file ossimArgumentParser.cpp.
References find(), ossimString::length(), ossimString::split(), ossimString::string(), theArgc, and theArgv.
bool ossimArgumentParser::read | ( | int | pos, |
const std::string & | str | ||
) |
if the argument value at the position pos matches specified string, and subsequent paramters are also matched then set the paramter values and remove the from the list of arguments.
if the argument value at the posotion pos matches specified string, and subsequent parameters are also matched then set the paramter values and remove the from the list of arguments.
Definition at line 509 of file ossimArgumentParser.cpp.
References match().
bool ossimArgumentParser::read | ( | int | pos, |
const std::string & | str, | ||
ossimParameter | value1 | ||
) |
Definition at line 522 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), match(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | int | pos, |
const std::string & | str, | ||
ossimParameter | value1, | ||
ossimParameter | value2 | ||
) |
Definition at line 537 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), match(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | int | pos, |
const std::string & | str, | ||
ossimParameter | value1, | ||
ossimParameter | value2, | ||
ossimParameter | value3 | ||
) |
Definition at line 554 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), match(), theArgv, and ossimArgumentParser::ossimParameter::valid().
bool ossimArgumentParser::read | ( | int | pos, |
const std::string & | str, | ||
ossimParameter | value1, | ||
ossimParameter | value2, | ||
ossimParameter | value3, | ||
ossimParameter | value4 | ||
) |
Definition at line 573 of file ossimArgumentParser.cpp.
References ossimArgumentParser::ossimParameter::assign(), match(), theArgv, and ossimArgumentParser::ossimParameter::valid().
void ossimArgumentParser::remove | ( | int | pos, |
int | num = 1 |
||
) |
remove one or more arguments from the argv argument list, and decrement the argc respectively.
Definition at line 284 of file ossimArgumentParser.cpp.
References theArgc, and theArgv.
Referenced by ossimVerticesFinderTool::initialize().
void ossimArgumentParser::reportError | ( | const std::string & | message, |
ossimErrorSeverity | severity = OSSIM_CRITICAL |
||
) |
report an error message by adding to the ErrorMessageMap.
Definition at line 605 of file ossimArgumentParser.cpp.
References theErrorMessageMap.
Referenced by read(), and reportRemainingOptionsAsUnrecognized().
void ossimArgumentParser::reportRemainingOptionsAsUnrecognized | ( | ossimErrorSeverity | severity = OSSIM_BENIGN | ) |
for each remaining option report it as an unrecongnized.
Definition at line 610 of file ossimArgumentParser.cpp.
References argc(), getApplicationName(), ossimApplicationUsage::getCommandLineOptions(), isOption(), reportError(), theArgv, and theUsage.
Referenced by ossimBatchTest::initialize(), and ossimChipProcTool::processRemainingArgs().
|
inline |
void ossimArgumentParser::writeErrorMessages | ( | std::ostream & | output, |
ossimErrorSeverity | sevrity = OSSIM_BENIGN |
||
) |
write out error messages at an above specified .
Definition at line 659 of file ossimArgumentParser.cpp.
References getApplicationName(), and theErrorMessageMap.
Referenced by ossimBatchTest::initialize(), ossimChipProcTool::initialize(), and ossimChipProcTool::processRemainingArgs().
|
protected |
Definition at line 241 of file ossimArgumentParser.h.
Referenced by containsOptions(), find(), getApplicationName(), initialize(), insert(), isNumber(), isOption(), isString(), match(), ossimArgumentParser(), read(), remove(), and ~ossimArgumentParser().
|
protected |
Definition at line 242 of file ossimArgumentParser.h.
Referenced by find(), getApplicationName(), initialize(), insert(), isNumber(), isOption(), isString(), match(), numberOfParams(), ossimArgumentParser(), read(), remove(), reportRemainingOptionsAsUnrecognized(), and ~ossimArgumentParser().
|
protected |
Definition at line 243 of file ossimArgumentParser.h.
Referenced by errors(), getErrorMessageMap(), reportError(), and writeErrorMessages().
|
protected |
Definition at line 245 of file ossimArgumentParser.h.
Referenced by insert(), and ~ossimArgumentParser().
|
protected |
Definition at line 244 of file ossimArgumentParser.h.
Referenced by ossimArgumentParser(), and reportRemainingOptionsAsUnrecognized().