Add method to reset arguments recursively
This commit is contained in:
parent
d8b9845d15
commit
70869f24a8
|
@ -282,6 +282,18 @@ Argument *Argument::wouldConflictWithArgument() const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets this argument and all sub arguments recursively.
|
||||
* \sa Argument::reset()
|
||||
*/
|
||||
void Argument::resetRecursively()
|
||||
{
|
||||
for(Argument *arg : m_subArgs) {
|
||||
arg->resetRecursively();
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \class ApplicationUtilities::ArgumentParser
|
||||
* \brief The ArgumentParser class provides a means for handling command line arguments.
|
||||
|
@ -463,6 +475,17 @@ void ArgumentParser::readArgs(int argc, const char * const *argv)
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets all Argument instances assigned as mainArguments() and sub arguments.
|
||||
* \sa Argument::reset()
|
||||
*/
|
||||
void ArgumentParser::resetArgs()
|
||||
{
|
||||
for(Argument *arg : m_mainArgs) {
|
||||
arg->resetRecursively();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether at least one uncombinable main argument is present.
|
||||
*/
|
||||
|
|
|
@ -185,6 +185,7 @@ public:
|
|||
Argument *conflictsWithArgument() const;
|
||||
Argument *wouldConflictWithArgument() const;
|
||||
void reset();
|
||||
void resetRecursively();
|
||||
|
||||
private:
|
||||
const char *m_name;
|
||||
|
@ -220,6 +221,7 @@ public:
|
|||
void printHelp(std::ostream &os) const;
|
||||
void parseArgs(int argc, const char *const *argv);
|
||||
void readArgs(int argc, const char *const *argv);
|
||||
void resetArgs();
|
||||
unsigned int actualArgumentCount() const;
|
||||
const char *executable() const;
|
||||
UnknownArgumentBehavior unknownArgumentBehavior() const;
|
||||
|
|
Loading…
Reference in New Issue