diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-06-27 11:11:10 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-07-16 13:20:38 +0000 |
commit | cde7f1b4690094699a550a9021201a399b209d02 (patch) | |
tree | 63bf3b1c0a88e85448577ceb26cc2abe166ba497 /src | |
parent | 9d0a10dc84915508adf60e98ce01a4cc0cf02f70 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qcommandlineoption.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp index 8ab98741f5..14ee674cb9 100644 --- a/src/corelib/tools/qcommandlineoption.cpp +++ b/src/corelib/tools/qcommandlineoption.cpp @@ -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 |