25 #ifndef DtCmdLine_ARGUMENT_H
26 #define DtCmdLine_ARGUMENT_H
37 #ifdef DtUSE_UTILITIES_NAMESPACE
38 namespace DtUSE_UTILITIES_NAMESPACE
61 static char&
delimiterRef() {
static char delim =
' ';
return delim; }
136 void _checkWithVisitor()
const;
151 Arg(
const std::string& flag,
152 const std::string& name,
153 const std::string& desc,
168 virtual void addToList( std::list<Arg*>& argList )
const;
228 virtual bool processArg(
int *i, std::vector<std::string>& args) = 0;
240 const std::string& getFlag()
const;
245 const std::string& getName()
const;
250 std::string getDescription()
const;
255 virtual bool isRequired()
const;
261 void forceRequired();
272 bool isValueRequired()
const;
283 bool isIgnoreable()
const;
293 virtual bool argMatches(
const std::string& s )
const;
299 virtual std::string toString()
const;
305 virtual std::string shortID(
const std::string& valueId =
"val" )
const;
311 virtual std::string longID(
const std::string& valueId =
"val" )
const;
320 virtual void trimFlag( std::string& flag, std::string& value )
const;
328 bool _hasBlanks(
const std::string& s )
const;
335 void setRequireLabel(
const std::string& s );
359 inline Arg::Arg(
const std::string& flag,
360 const std::string& name,
361 const std::string& desc,
369 _requireLabel(
"required"),
370 _valueRequired(valreq),
376 if (
_flag.length() > 1 )
378 "Argument flag can only be one character long",
toString() ) );
391 (
_name.find(
" ", 0 ) != std::string::npos ) )
410 std::string delim =
" ";
414 id += delim +
"<" + valueId +
">";
422 inline std::string
Arg::longID(
const std::string& valueId )
const
431 id +=
" <" + valueId +
">";
439 id +=
" <" + valueId +
">";
460 std::string desc =
"";
527 for (
int i = 0; (
unsigned int)i < flag.length(); i++ )
536 value = flag.substr(stop+1);
537 flag = flag.substr(0,stop);
547 for (
int i = 1; (
unsigned int)i < s.length(); i++ )
570 argList.push_front( (
Arg*)
this );
579 #ifdef DtUSE_UTILITIES_NAMESPACE