applied some clang modernize (#2435)
This commit is contained in:
@@ -3,12 +3,13 @@
|
||||
|
||||
#include "commandargument.h"
|
||||
|
||||
CommandArgument::CommandArgument() {}
|
||||
#include <utility>
|
||||
|
||||
CommandArgument::CommandArgument(const QString& name,
|
||||
const QString& description)
|
||||
: m_name(name)
|
||||
, m_description(description)
|
||||
CommandArgument::CommandArgument() = default;
|
||||
|
||||
CommandArgument::CommandArgument(QString name, QString description)
|
||||
: m_name(std::move(name))
|
||||
, m_description(std::move(description))
|
||||
{}
|
||||
|
||||
void CommandArgument::setName(const QString& name)
|
||||
|
||||
@@ -9,7 +9,7 @@ class CommandArgument
|
||||
{
|
||||
public:
|
||||
CommandArgument();
|
||||
explicit CommandArgument(const QString& name, const QString& description);
|
||||
explicit CommandArgument(QString name, QString description);
|
||||
|
||||
void setName(const QString& name);
|
||||
QString name() const;
|
||||
|
||||
@@ -67,10 +67,10 @@ QString optionsToString(const QList<CommandOption>& options,
|
||||
if (!arguments.isEmpty()) {
|
||||
result += QObject::tr("Arguments") + ":\n";
|
||||
}
|
||||
for (int i = 0; i < arguments.length(); ++i) {
|
||||
for (const auto& argument : arguments) {
|
||||
result += QStringLiteral(" %1 %2\n")
|
||||
.arg(arguments.at(i).name().leftJustified(size, ' '))
|
||||
.arg(arguments.at(i).description());
|
||||
.arg(argument.name().leftJustified(size, ' '))
|
||||
.arg(argument.description());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -363,9 +363,8 @@ CommandLineParser::Node* CommandLineParser::findParent(
|
||||
}
|
||||
// find the parent in the subNodes recursively
|
||||
Node* res = nullptr;
|
||||
for (auto i = m_parseTree.subNodes.begin(); i != m_parseTree.subNodes.end();
|
||||
++i) {
|
||||
res = recursiveParentSearch(parent, *i);
|
||||
for (auto& subNode : m_parseTree.subNodes) {
|
||||
res = recursiveParentSearch(parent, subNode);
|
||||
if (res != nullptr) {
|
||||
break;
|
||||
}
|
||||
@@ -381,8 +380,8 @@ CommandLineParser::Node* CommandLineParser::recursiveParentSearch(
|
||||
if (node.argument == parent) {
|
||||
res = &node;
|
||||
} else {
|
||||
for (auto i = node.subNodes.begin(); i != node.subNodes.end(); ++i) {
|
||||
res = recursiveParentSearch(parent, *i);
|
||||
for (auto& subNode : node.subNodes) {
|
||||
res = recursiveParentSearch(parent, subNode);
|
||||
if (res != nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,26 +3,28 @@
|
||||
|
||||
#include "commandoption.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
CommandOption::CommandOption(const QString& name,
|
||||
const QString& description,
|
||||
const QString& valueName,
|
||||
const QString& defaultValue)
|
||||
QString description,
|
||||
QString valueName,
|
||||
QString defaultValue)
|
||||
: m_names(name)
|
||||
, m_description(description)
|
||||
, m_valueName(valueName)
|
||||
, m_value(defaultValue)
|
||||
, m_description(std::move(description))
|
||||
, m_valueName(std::move(valueName))
|
||||
, m_value(std::move(defaultValue))
|
||||
{
|
||||
m_checker = [](QString const&) { return true; };
|
||||
}
|
||||
|
||||
CommandOption::CommandOption(const QStringList& names,
|
||||
const QString& description,
|
||||
const QString& valueName,
|
||||
const QString& defaultValue)
|
||||
: m_names(names)
|
||||
, m_description(description)
|
||||
, m_valueName(valueName)
|
||||
, m_value(defaultValue)
|
||||
CommandOption::CommandOption(QStringList names,
|
||||
QString description,
|
||||
QString valueName,
|
||||
QString defaultValue)
|
||||
: m_names(std::move(names))
|
||||
, m_description(std::move(description))
|
||||
, m_valueName(std::move(valueName))
|
||||
, m_value(std::move(defaultValue))
|
||||
{
|
||||
m_checker = [](QString const&) -> bool { return true; };
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@ class CommandOption
|
||||
{
|
||||
public:
|
||||
CommandOption(const QString& name,
|
||||
const QString& description,
|
||||
const QString& valueName = QString(),
|
||||
const QString& defaultValue = QString());
|
||||
QString description,
|
||||
QString valueName = QString(),
|
||||
QString defaultValue = QString());
|
||||
|
||||
CommandOption(const QStringList& names,
|
||||
const QString& description,
|
||||
const QString& valueName = QString(),
|
||||
const QString& defaultValue = QString());
|
||||
CommandOption(QStringList names,
|
||||
QString description,
|
||||
QString valueName = QString(),
|
||||
QString defaultValue = QString());
|
||||
|
||||
void setName(const QString& name);
|
||||
void setNames(const QStringList& names);
|
||||
|
||||
Reference in New Issue
Block a user