QCommandLineOption: reduce string data

... by centralizing the common part of repeated qWarnings() in a single
function, passing the variable part through %s.

Change-Id: I114d10f41d4b0bbf59ef87f75308dc5b3ccd3967
Reviewed-by: David Faure <david.faure@kdab.com>
bb10
Marc Mutz 2015-06-27 11:11:10 +02:00
parent 9d0a10dc84
commit cde7f1b469
1 changed files with 16 additions and 16 deletions

View File

@ -252,24 +252,24 @@ namespace {
result_type operator()(const QString &name) const Q_DECL_NOEXCEPT
{
if (name.isEmpty()) {
qWarning("QCommandLineOption: Option names cannot be empty");
return true;
} else {
const QChar c = name.at(0);
if (c == QLatin1Char('-')) {
qWarning("QCommandLineOption: Option names cannot start with a '-'");
return true;
} else if (c == QLatin1Char('/')) {
qWarning("QCommandLineOption: Option names cannot start with a '/'");
return true;
} else if (name.contains(QLatin1Char('='))) {
qWarning("QCommandLineOption: Option names cannot contain a '='");
return true;
}
}
if (name.isEmpty())
return warn("be empty");
const QChar c = name.at(0);
if (c == QLatin1Char('-'))
return warn("start with a '-'");
if (c == QLatin1Char('/'))
return warn("start with a '/'");
if (name.contains(QLatin1Char('=')))
return warn("contain a '='");
return false;
}
static bool warn(const char *what) Q_DECL_NOEXCEPT
{
qWarning("QCommandLineOption: Option names cannot %s", what);
return true;
}
};
} // unnamed namespace