Reduce indentation in argumentparser.cpp
This commit is contained in:
parent
04a8ef02d5
commit
80fba8b6d4
|
@ -620,12 +620,13 @@ void Argument::setSubArguments(const ArgumentInitializerList &secondaryArguments
|
|||
*/
|
||||
void Argument::addSubArgument(Argument *arg)
|
||||
{
|
||||
if (find(m_subArgs.cbegin(), m_subArgs.cend(), arg) == m_subArgs.cend()) {
|
||||
if (find(m_subArgs.cbegin(), m_subArgs.cend(), arg) != m_subArgs.cend()) {
|
||||
return;
|
||||
}
|
||||
m_subArgs.push_back(arg);
|
||||
if (find(arg->m_parents.cbegin(), arg->m_parents.cend(), this) == arg->m_parents.cend()) {
|
||||
arg->m_parents.push_back(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -668,7 +669,9 @@ Argument *Argument::conflictsWithArgument() const
|
|||
*/
|
||||
Argument *Argument::wouldConflictWithArgument() const
|
||||
{
|
||||
if (!isCombinable()) {
|
||||
if (isCombinable()) {
|
||||
return nullptr;
|
||||
}
|
||||
for (Argument *parent : m_parents) {
|
||||
for (Argument *sibling : parent->subArguments()) {
|
||||
if (sibling != this && sibling->isPresent() && !sibling->isCombinable()) {
|
||||
|
@ -676,7 +679,6 @@ Argument *Argument::wouldConflictWithArgument() const
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -742,13 +744,16 @@ ArgumentParser::ArgumentParser()
|
|||
*/
|
||||
void ArgumentParser::setMainArguments(const ArgumentInitializerList &mainArguments)
|
||||
{
|
||||
if (mainArguments.size()) {
|
||||
if (!mainArguments.size()) {
|
||||
m_mainArgs.clear();
|
||||
}
|
||||
for (Argument *arg : mainArguments) {
|
||||
arg->m_isMainArg = true;
|
||||
}
|
||||
m_mainArgs.assign(mainArguments);
|
||||
if (!m_defaultArg) {
|
||||
if (!(*mainArguments.begin())->requiredValueCount()) {
|
||||
if (m_defaultArg || (*mainArguments.begin())->requiredValueCount()) {
|
||||
return;
|
||||
}
|
||||
bool subArgsRequired = false;
|
||||
for (const Argument *subArg : (*mainArguments.begin())->subArguments()) {
|
||||
if (subArg->isRequired()) {
|
||||
|
@ -759,11 +764,6 @@ void ArgumentParser::setMainArguments(const ArgumentInitializerList &mainArgumen
|
|||
if (!subArgsRequired) {
|
||||
m_defaultArg = *mainArguments.begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_mainArgs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1587,7 +1587,9 @@ void ArgumentParser::checkConstraints(const ArgumentVector &args)
|
|||
throw Failure(argsToString("The argument \"", conflictingArgument->name(), "\" can not be combined with \"", arg->name(), "\"."));
|
||||
}
|
||||
for (size_t i = 0; i != occurrences; ++i) {
|
||||
if (!arg->allRequiredValuesPresent(i)) {
|
||||
if (arg->allRequiredValuesPresent(i)) {
|
||||
continue;
|
||||
}
|
||||
stringstream ss(stringstream::in | stringstream::out);
|
||||
ss << "Not all parameter for argument \"" << arg->name() << "\" ";
|
||||
if (i) {
|
||||
|
@ -1606,7 +1608,6 @@ void ArgumentParser::checkConstraints(const ArgumentVector &args)
|
|||
}
|
||||
throw Failure(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
// check contraints of sub arguments recursively
|
||||
checkConstraints(arg->m_subArgs);
|
||||
|
|
Loading…
Reference in New Issue