25 #ifndef TCLAP_ARGUMENT_H
26 #define TCLAP_ARGUMENT_H
41 #if defined(HAVE_SSTREAM)
44 #elif defined(HAVE_STRSTREAM)
48 #error "Need a stringstream (sstream or strstream) to compile!"
75 Arg& operator=(
const Arg& rhs);
80 static bool& ignoreRestRef() {
static bool ign =
false;
return ign; }
86 static char& delimiterRef() {
static char delim =
' ';
return delim; }
178 Arg(
const std::string& flag,
179 const std::string& name,
180 const std::string& desc,
195 virtual void addToList( std::list<Arg*>& argList )
const;
223 #ifndef TCLAP_FLAGSTARTCHAR
224 #define TCLAP_FLAGSTARTCHAR '-'
233 #ifndef TCLAP_FLAGSTARTSTRING
234 #define TCLAP_FLAGSTARTSTRING "-"
242 #ifndef TCLAP_NAMESTARTSTRING
243 #define TCLAP_NAMESTARTSTRING "--"
265 virtual bool processArg(
int *i, std::vector<std::string>& args) = 0;
277 const std::string&
getFlag()
const;
282 const std::string&
getName()
const;
330 virtual bool argMatches(
const std::string& s )
const;
336 virtual std::string
toString()
const;
342 virtual std::string
shortID(
const std::string& valueId =
"val" )
const;
348 virtual std::string
longID(
const std::string& valueId =
"val" )
const;
357 virtual void trimFlag( std::string& flag, std::string& value )
const;
365 bool _hasBlanks(
const std::string& s )
const;
390 virtual void reset();
414 template<
typename T>
void
417 static_cast<void>(vl);
421 while ( is.good() ) {
422 if ( is.peek() != EOF )
423 #ifdef TCLAP_SETBASE_ZERO
424 is >> std::setbase(0) >> destVal;
436 "from string '" + strVal +
"'"));
439 if ( valuesRead > 1 )
441 "string '" + strVal +
"'"));
451 template<
typename T>
void
454 static_cast<void>(sl);
462 inline Arg::Arg(
const std::string& flag,
463 const std::string& name,
464 const std::string& desc,
472 _requireLabel(
"required"),
473 _valueRequired(valreq),
478 _acceptsMultipleValues(false)
480 if (
_flag.length() > 1 )
482 "Argument flag can only be one character long",
toString() ) );
495 (
_name.find(
" ", 0 ) != std::string::npos ) )
523 inline std::string
Arg::longID(
const std::string& valueId )
const
556 std::string desc =
"";
623 for (
int i = 0;
static_cast<unsigned int>(i) < flag.length(); i++ )
632 value = flag.substr(stop+1);
633 flag = flag.substr(0,stop);
643 for (
int i = 1;
static_cast<unsigned int>(i) < s.length(); i++ )
666 argList.push_front( const_cast<Arg*>(
this) );