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;
|
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
|
* \class ApplicationUtilities::ArgumentParser
|
||||||
* \brief The ArgumentParser class provides a means for handling command line arguments.
|
* \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.
|
* \brief Checks whether at least one uncombinable main argument is present.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -185,6 +185,7 @@ public:
|
||||||
Argument *conflictsWithArgument() const;
|
Argument *conflictsWithArgument() const;
|
||||||
Argument *wouldConflictWithArgument() const;
|
Argument *wouldConflictWithArgument() const;
|
||||||
void reset();
|
void reset();
|
||||||
|
void resetRecursively();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *m_name;
|
const char *m_name;
|
||||||
|
@ -220,6 +221,7 @@ public:
|
||||||
void printHelp(std::ostream &os) const;
|
void printHelp(std::ostream &os) const;
|
||||||
void parseArgs(int argc, const char *const *argv);
|
void parseArgs(int argc, const char *const *argv);
|
||||||
void readArgs(int argc, const char *const *argv);
|
void readArgs(int argc, const char *const *argv);
|
||||||
|
void resetArgs();
|
||||||
unsigned int actualArgumentCount() const;
|
unsigned int actualArgumentCount() const;
|
||||||
const char *executable() const;
|
const char *executable() const;
|
||||||
UnknownArgumentBehavior unknownArgumentBehavior() const;
|
UnknownArgumentBehavior unknownArgumentBehavior() const;
|
||||||
|
|
Loading…
Reference in New Issue