21 return str && str[0]==
'-';
26 if (!str)
return false;
34 if (!str)
return false;
36 bool hadPlusMinus =
false;
37 bool hadDecimalPlace =
false;
38 bool hadExponent =
false;
39 bool couldBeInt =
true;
40 bool couldBeFloat =
true;
43 const char* ptr = str;
46 if (std::strncmp(ptr,
"0x",2)==0)
53 ((*ptr>=
'0' && *ptr<=
'9') ||
54 (*ptr>=
'a' && *ptr<=
'f') ||
55 (*ptr>=
'A' && *ptr<=
'F'))
62 if (*ptr==0)
return true;
68 while (*ptr!=0 && couldBeFloat)
70 if (*ptr==
'+' || *ptr==
'-')
82 else if (*ptr>=
'0' && *ptr<=
'9')
95 hadDecimalPlace =
true;
99 else if (*ptr==
'e' || *ptr==
'E')
101 if (hadExponent || noZeroToNine==0)
104 couldBeFloat =
false;
110 hadDecimalPlace =
false;
111 hadPlusMinus =
false;
118 couldBeFloat =
false;
123 if (couldBeInt && noZeroToNine>0)
return true;
124 if (couldBeFloat && noZeroToNine>0)
return true;
134 case ossimParameter::OSSIM_FLOAT_PARAMETER:
return isNumber(str);
135 case ossimParameter::OSSIM_DOUBLE_PARAMETER:
return isNumber(str);
136 case ossimParameter::OSSIM_INT_PARAMETER:
return isNumber(str);
137 case ossimParameter::OSSIM_UNSIGNED_INT_PARAMETER:
return isNumber(str);
138 case ossimParameter::OSSIM_STRING_PARAMETER:
return isString(str);
150 case ossimParameter::OSSIM_FLOAT_PARAMETER:
153 case ossimParameter::OSSIM_DOUBLE_PARAMETER:
156 case ossimParameter::OSSIM_INT_PARAMETER:
159 case ossimParameter::OSSIM_UNSIGNED_INT_PARAMETER:
162 case ossimParameter::OSSIM_STRING_PARAMETER:
173 theMemAllocated(false)
183 theMemAllocated(
true)
185 vector<ossimString> args = commandLine.
split(
" ",
true);
190 for (
size_t i=0; i<args.size(); i++)
192 size_t n = args[i].size();
194 strncpy(
theArgv[i], args[i].chars(),
n);
217 for(
int i=0;i<*
argc;i++)
247 for(
int pos=1;pos<*
theArgc;++pos)
264 for(
int pos=1;pos<*
theArgc;++pos)
301 if (argstr.
size()==0)
305 vector<ossimString> components = argstr.
split(
" ");
306 int new_argc = *
theArgc + (int)components.size();
307 char** new_argv =
new char*[new_argc];
314 j += (int)components.size();
321 new_argv[pos+i]=components[i].stringDup();
334 if (pos<=0)
return false;
342 if (pos<=0)
return false;
357 if (pos<=0)
return false;
374 if (pos<=0)
return false;
394 if (pos<=0)
return false;
416 if (pos<=0)
return false;
441 if (pos<=0)
return false;
473 bool includeNextItem =
true;
485 includeNextItem =
true;
489 if (!includeNextItem && (arg.
string()[0] !=
','))
493 vector<ossimString> sub_args = arg.
split(
",",
true);
495 param_list.push_back(sub_args[i]);
498 if (arg[arg.
length()-1] !=
',')
499 includeNextItem =
false;
524 if (
match(pos,str) &&
539 if (
match(pos,str) &&
556 if (
match(pos,str) &&
575 if (
match(pos,str) &&
600 if (itr->second>=severity)
return true;
612 std::set<std::string> options;
620 const std::string& option = itr->first;
621 std::string::size_type prevpos = 0, pos = 0;
622 while ((pos=option.find(
' ',prevpos))!=std::string::npos)
624 if (option[prevpos]==
'-')
626 options.insert(std::string(option,prevpos,pos-prevpos));
630 if (option[prevpos]==
'-')
633 options.insert(std::string(option,prevpos,std::string::npos));
639 for(
int pos=1;pos<
argc();++pos)
665 if (itr->second>=severity)
void insert(int pos, const ossimString &arg)
Inserts string into the argv argument list, and increment the argc respectively.
std::string getApplicationName() const
return the application name, as specified by argv[0]
const UsageMap & getCommandLineOptions() const
bool read(const std::string &str)
search for an occurance of a string in the argument list, on sucess remove that occurance from the li...
bool valid(const char *str) const
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
ossim_uint32 toUInt32() const
static bool isNumber(const char *str)
return return true if specified parameter is an number.
int numberOfParams(const std::string &str, const ossimParameter value) const
int find(const std::string &str) const
return the position of an occurence of a string in the argument list.
void reportRemainingOptionsAsUnrecognized(ossimErrorSeverity severity=OSSIM_BENIGN)
for each remaining option report it as an unrecongnized.
bool match(int pos, const std::string &str) const
return true if specified argument matches string.
bool errors(ossimErrorSeverity severity=OSSIM_BENIGN) const
std::string::size_type length() const
std::string::size_type size() const
os2<< "> n<< " > nendobj n
unsigned int ossim_uint32
const char * chars() const
For backward compatibility.
void setApplicationName(const ossimString &name)
void initialize(int *argc, const char **argv)
Initialize from command arguments.
bool containsOptions() const
std::map< std::string, ossimErrorSeverity > ossimErrorMessageMap
bool assign(const char *str)
void remove(int pos, int num=1)
remove one or more arguments from the argv argument list, and decrement the argc respectively.
ossimApplicationUsage * theUsage
void reportError(const std::string &message, ossimErrorSeverity severity=OSSIM_CRITICAL)
report an error message by adding to the ErrorMessageMap.
static bool isString(const char *str)
return return true if string is any other string apart from an option.
ossimErrorMessageMap theErrorMessageMap
static bool isOption(const char *str)
return return true if specified string is an option in the form of -option or –option ...
char ** argv()
return the argument array.
int & argc()
return the argument count.
ossimArgumentParser(int *argc, char **argv)
std::basic_ostream< char > ostream
Base class for char output streams.
ossimErrorMessageMap & getErrorMessageMap()
void writeErrorMessages(std::ostream &output, ossimErrorSeverity sevrity=OSSIM_BENIGN)
write out error messages at an above specified .
const std::string & string() const