| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qcommandlineparser.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | extern void __attribute__((visibility("default"))) qt_call_post_routines(); | - | ||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | typedef QHash<QString, int> NameHash_t; | - | ||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | class QCommandLineParserPrivate | - | ||||||||||||||||||
| 15 | { | - | ||||||||||||||||||
| 16 | public: | - | ||||||||||||||||||
| 17 | inline QCommandLineParserPrivate() | - | ||||||||||||||||||
| 18 | : singleDashWordOptionMode(QCommandLineParser::ParseAsCompactedShortOptions), | - | ||||||||||||||||||
| 19 | optionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsOptions), | - | ||||||||||||||||||
| 20 | builtinVersionOption(false), | - | ||||||||||||||||||
| 21 | builtinHelpOption(false), | - | ||||||||||||||||||
| 22 | needsParsing(true) | - | ||||||||||||||||||
| 23 |     { } executed 161 times by 2 tests:  end of blockExecuted by: 
  | 161 | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | bool parse(const QStringList &args); | - | ||||||||||||||||||
| 26 | void checkParsed(const char *method); | - | ||||||||||||||||||
| 27 | QStringList aliases(const QString &name) const; | - | ||||||||||||||||||
| 28 | QString helpText() const; | - | ||||||||||||||||||
| 29 | bool registerFoundOption(const QString &optionName); | - | ||||||||||||||||||
| 30 | bool parseOptionValue(const QString &optionName, const QString &argument, | - | ||||||||||||||||||
| 31 | QStringList::const_iterator *argumentIterator, | - | ||||||||||||||||||
| 32 | QStringList::const_iterator argsEnd); | - | ||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | QString errorText; | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | QList<QCommandLineOption> commandLineOptionList; | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | NameHash_t nameHash; | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | QHash<int, QStringList> optionValuesHash; | - | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | QStringList optionNames; | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | QStringList positionalArgumentList; | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | QStringList unknownOptionNames; | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | QString description; | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | struct PositionalArgumentDefinition | - | ||||||||||||||||||
| 60 | { | - | ||||||||||||||||||
| 61 | QString name; | - | ||||||||||||||||||
| 62 | QString description; | - | ||||||||||||||||||
| 63 | QString syntax; | - | ||||||||||||||||||
| 64 | }; | - | ||||||||||||||||||
| 65 | QVector<PositionalArgumentDefinition> positionalArgumentDefinitions; | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode; | - | ||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | QCommandLineParser::OptionsAfterPositionalArgumentsMode optionsAfterPositionalArgumentsMode; | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | bool builtinVersionOption; | - | ||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | bool builtinHelpOption; | - | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | bool needsParsing; | - | ||||||||||||||||||
| 81 | }; | - | ||||||||||||||||||
| 82 | template<> class QTypeInfo<QCommandLineParserPrivate::PositionalArgumentDefinition > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QCommandLineParserPrivate::PositionalArgumentDefinition)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QCommandLineParserPrivate::PositionalArgumentDefinition >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QCommandLineParserPrivate::PositionalArgumentDefinition) }; static inline const char *name() { return "QCommandLineParserPrivate::PositionalArgumentDefinition"; } }; | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const | - | ||||||||||||||||||
| 85 | { | - | ||||||||||||||||||
| 86 | const NameHash_t::const_iterator it = nameHash.constFind(optionName); | - | ||||||||||||||||||
| 87 |     if (it == nameHash.cend()
  | 2-507 | ||||||||||||||||||
| 88 | QMessageLogger(__FILE__, 133, __PRETTY_FUNCTION__).warning("QCommandLineParser: option not defined: \"%s\"", QString(optionName).toLocal8Bit().constData()); | - | ||||||||||||||||||
| 89 |         return executed 2 times by 1 test:   QStringList();return QStringList();Executed by: 
 executed 2 times by 1 test:  return QStringList();Executed by: 
  | 2 | ||||||||||||||||||
| 90 | } | - | ||||||||||||||||||
| 91 |     return executed 507 times by 2 tests:   commandLineOptionList.at(*it).names();return commandLineOptionList.at(*it).names();Executed by: 
 executed 507 times by 2 tests:  return commandLineOptionList.at(*it).names();Executed by: 
  | 507 | ||||||||||||||||||
| 92 | } | - | ||||||||||||||||||
| 93 | QCommandLineParser::QCommandLineParser() | - | ||||||||||||||||||
| 94 | : d(new QCommandLineParserPrivate) | - | ||||||||||||||||||
| 95 | { | - | ||||||||||||||||||
| 96 | } executed 161 times by 2 tests:  end of blockExecuted by: 
  | 161 | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | QCommandLineParser::~QCommandLineParser() | - | ||||||||||||||||||
| 102 | { | - | ||||||||||||||||||
| 103 | delete d; | - | ||||||||||||||||||
| 104 | } executed 161 times by 2 tests:  end of blockExecuted by: 
  | 161 | ||||||||||||||||||
| 105 | void QCommandLineParser::setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode) | - | ||||||||||||||||||
| 106 | { | - | ||||||||||||||||||
| 107 | d->singleDashWordOptionMode = singleDashWordOptionMode; | - | ||||||||||||||||||
| 108 | } executed 28 times by 1 test:  end of blockExecuted by: 
  | 28 | ||||||||||||||||||
| 109 | void QCommandLineParser::setOptionsAfterPositionalArgumentsMode(QCommandLineParser::OptionsAfterPositionalArgumentsMode parsingMode) | - | ||||||||||||||||||
| 110 | { | - | ||||||||||||||||||
| 111 | d->optionsAfterPositionalArgumentsMode = parsingMode; | - | ||||||||||||||||||
| 112 | } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||
| 113 | bool QCommandLineParser::addOption(const QCommandLineOption &option) | - | ||||||||||||||||||
| 114 | { | - | ||||||||||||||||||
| 115 | const QStringList optionNames = option.names(); | - | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 |     if (!optionNames.isEmpty()
  | 1-1275 | ||||||||||||||||||
| 118 | for (const QString &name : optionNames) { | - | ||||||||||||||||||
| 119 |             if (d->nameHash.contains(name)
  | 0-2385 | ||||||||||||||||||
| 120 |                 return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 121 |         } executed 2385 times by 2 tests:  end of blockExecuted by: 
  | 2385 | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | d->commandLineOptionList.append(option); | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | const int offset = d->commandLineOptionList.size() - 1; | - | ||||||||||||||||||
| 126 | for (const QString &name : optionNames) | - | ||||||||||||||||||
| 127 |             d->nameHash.insert(name, offset); executed 2385 times by 2 tests:  d->nameHash.insert(name, offset);Executed by: 
  | 2385 | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 |         return executed 1275 times by 2 tests:   true;return true;Executed by: 
 executed 1275 times by 2 tests:  return true;Executed by: 
  | 1275 | ||||||||||||||||||
| 130 | } | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 |     return executed 1 time by 1 test:   false;return false;Executed by: 
 executed 1 time by 1 test:  return false;Executed by: 
  | 1 | ||||||||||||||||||
| 133 | } | - | ||||||||||||||||||
| 134 | bool QCommandLineParser::addOptions(const QList<QCommandLineOption> &options) | - | ||||||||||||||||||
| 135 | { | - | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | bool result = true; | - | ||||||||||||||||||
| 138 |     for (QList<QCommandLineOption>::const_iterator it = options.begin(), end = options.end(); it != end
  | 1-3 | ||||||||||||||||||
| 139 |         result &= addOption(*it); executed 3 times by 1 test:  result &= addOption(*it);Executed by: 
  | 3 | ||||||||||||||||||
| 140 |     return executed 1 time by 1 test:   result;return result;Executed by: 
 executed 1 time by 1 test:  return result;Executed by: 
  | 1 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | QCommandLineOption QCommandLineParser::addVersionOption() | - | ||||||||||||||||||
| 143 | { | - | ||||||||||||||||||
| 144 |     QCommandLineOption opt(QStringList() << ([]() -> QString { enum { Size = sizeof(u"" "v")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "v" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 120 times by 1 test:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 120 times by 1 test:   }()) << ([]() -> QString { enum { Size = sizeof(u"" "version")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "version" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn qstring_literal_temp;Executed by: 
 executed 120 times by 1 test:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 120 times by 1 test:   }()), tr("Displays version information."));return qstring_literal_temp;Executed by: 
  | 120 | ||||||||||||||||||
| 145 | addOption(opt); | - | ||||||||||||||||||
| 146 | d->builtinVersionOption = true; | - | ||||||||||||||||||
| 147 |     return executed 120 times by 1 test:   opt;return opt;Executed by: 
 executed 120 times by 1 test:  return opt;Executed by: 
  | 120 | ||||||||||||||||||
| 148 | } | - | ||||||||||||||||||
| 149 | QCommandLineOption QCommandLineParser::addHelpOption() | - | ||||||||||||||||||
| 150 | { | - | ||||||||||||||||||
| 151 | QCommandLineOption opt(QStringList() | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 |                 << ([]() -> QString { enum { Size = sizeof(u"" "h")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "h" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 120 times by 1 test:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 120 times by 1 test:   }())return qstring_literal_temp;Executed by: 
  | 120 | ||||||||||||||||||
| 156 |                 << ([]() -> QString { enum { Size = sizeof(u"" "help")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "help" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 120 times by 1 test:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 120 times by 1 test:   }()), tr("Displays this help."));return qstring_literal_temp;Executed by: 
  | 120 | ||||||||||||||||||
| 157 | addOption(opt); | - | ||||||||||||||||||
| 158 | d->builtinHelpOption = true; | - | ||||||||||||||||||
| 159 |     return executed 120 times by 1 test:   opt;return opt;Executed by: 
 executed 120 times by 1 test:  return opt;Executed by: 
  | 120 | ||||||||||||||||||
| 160 | } | - | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | void QCommandLineParser::setApplicationDescription(const QString &description) | - | ||||||||||||||||||
| 166 | { | - | ||||||||||||||||||
| 167 | d->description = description; | - | ||||||||||||||||||
| 168 | } executed 120 times by 1 test:  end of blockExecuted by: 
  | 120 | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | QString QCommandLineParser::applicationDescription() const | - | ||||||||||||||||||
| 174 | { | - | ||||||||||||||||||
| 175 |     return never executed:   d->description;return d->description;never executed:  return d->description; | 0 | ||||||||||||||||||
| 176 | } | - | ||||||||||||||||||
| 177 | void QCommandLineParser::addPositionalArgument(const QString &name, const QString &description, const QString &syntax) | - | ||||||||||||||||||
| 178 | { | - | ||||||||||||||||||
| 179 | QCommandLineParserPrivate::PositionalArgumentDefinition arg; | - | ||||||||||||||||||
| 180 | arg.name = name; | - | ||||||||||||||||||
| 181 | arg.description = description; | - | ||||||||||||||||||
| 182 |     arg.syntax = syntax.isEmpty()
  | 120 | ||||||||||||||||||
| 183 | d->positionalArgumentDefinitions.append(arg); | - | ||||||||||||||||||
| 184 | } executed 240 times by 1 test:  end of blockExecuted by: 
  | 240 | ||||||||||||||||||
| 185 | void QCommandLineParser::clearPositionalArguments() | - | ||||||||||||||||||
| 186 | { | - | ||||||||||||||||||
| 187 | d->positionalArgumentDefinitions.clear(); | - | ||||||||||||||||||
| 188 | } never executed:  end of block | 0 | ||||||||||||||||||
| 189 | bool QCommandLineParser::parse(const QStringList &arguments) | - | ||||||||||||||||||
| 190 | { | - | ||||||||||||||||||
| 191 |     return executed 50 times by 1 test:   d->parse(arguments);return d->parse(arguments);Executed by: 
 executed 50 times by 1 test:  return d->parse(arguments);Executed by: 
  | 50 | ||||||||||||||||||
| 192 | } | - | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | QString QCommandLineParser::errorText() const | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 |     if (!d->errorText.isEmpty()
  | 3 | ||||||||||||||||||
| 201 |         return executed 3 times by 1 test:   d->errorText;return d->errorText;Executed by: 
 executed 3 times by 1 test:  return d->errorText;Executed by: 
  | 3 | ||||||||||||||||||
| 202 |     if (d->unknownOptionNames.count() == 1
  | 1-2 | ||||||||||||||||||
| 203 |         return executed 2 times by 1 test:   tr("Unknown option '%1'.").arg(d->unknownOptionNames.first());return tr("Unknown option '%1'.").arg(d->unknownOptionNames.first());Executed by: 
 executed 2 times by 1 test:  return tr("Unknown option '%1'.").arg(d->unknownOptionNames.first());Executed by: 
  | 2 | ||||||||||||||||||
| 204 |     if (d->unknownOptionNames.count() > 1
  | 0-1 | ||||||||||||||||||
| 205 |         return executed 1 time by 1 test:   tr("Unknown options: %1.").arg(d->unknownOptionNames.join(([]() -> QString { enum { Size = sizeof(u"" ", ")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ", " }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn tr("Unknown options: %1.").arg(d->unknownOptionNames.join(([]() -> QString { enum { Size = sizeof(u"" ", ")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ", " }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));Executed by: 
 executed 1 time by 1 test:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 1 time by 1 test:   }())));return qstring_literal_temp;Executed by: 
 executed 1 time by 1 test:  return tr("Unknown options: %1.").arg(d->unknownOptionNames.join(([]() -> QString { enum { Size = sizeof(u"" ", ")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ", " }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())));Executed by: 
  | 1 | ||||||||||||||||||
| 206 |     return never executed:   QString();return QString();never executed:  return QString(); | 0 | ||||||||||||||||||
| 207 | } | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | enum MessageType { UsageMessage, ErrorMessage }; | - | ||||||||||||||||||
| 210 | static void showParserMessage(const QString &message, MessageType type) | - | ||||||||||||||||||
| 211 | { | - | ||||||||||||||||||
| 212 | fputs(QString(message).toLocal8Bit().constData(), type == UsageMessage ? stdout : stderr); | - | ||||||||||||||||||
| 213 | } never executed:  end of block | 0 | ||||||||||||||||||
| 214 | void QCommandLineParser::process(const QStringList &arguments) | - | ||||||||||||||||||
| 215 | { | - | ||||||||||||||||||
| 216 |     if (!d->parse(arguments)
  | 0-120 | ||||||||||||||||||
| 217 | showParserMessage(errorText() + QLatin1Char('\n'), ErrorMessage); | - | ||||||||||||||||||
| 218 | qt_call_post_routines(); | - | ||||||||||||||||||
| 219 |         :: never executed:  exit(1);::exit(1);never executed:  ::exit(1); | 0 | ||||||||||||||||||
| 220 | } | - | ||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 |     if (d->builtinVersionOption
 executed 120 times by 1 test:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 120 times by 1 test:   }()))return qstring_literal_temp;Executed by: 
 
  | 0-120 | ||||||||||||||||||
| 223 |         showVersion(); never executed:  showVersion(); | 0 | ||||||||||||||||||
| 224 | - | |||||||||||||||||||
| 225 |     if (d->builtinHelpOption
 executed 120 times by 1 test:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 120 times by 1 test:   }()))return qstring_literal_temp;Executed by: 
 
  | 0-120 | ||||||||||||||||||
| 226 |         showHelp(0); never executed:  showHelp(0); | 0 | ||||||||||||||||||
| 227 | } executed 120 times by 1 test:  end of blockExecuted by: 
  | 120 | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | void QCommandLineParser::process(const QCoreApplication &app) | - | ||||||||||||||||||
| 235 | { | - | ||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | (void)app;; | - | ||||||||||||||||||
| 238 | process(QCoreApplication::arguments()); | - | ||||||||||||||||||
| 239 | } executed 120 times by 1 test:  end of blockExecuted by: 
  | 120 | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | void QCommandLineParserPrivate::checkParsed(const char *method) | - | ||||||||||||||||||
| 242 | { | - | ||||||||||||||||||
| 243 |     if (needsParsing
  | 2-2060 | ||||||||||||||||||
| 244 |         QMessageLogger(__FILE__, 617, __PRETTY_FUNCTION__).warning("QCommandLineParser: call process() or parse() before %s", method); executed 2 times by 1 test:  QMessageLogger(__FILE__, 617, __PRETTY_FUNCTION__).warning("QCommandLineParser: call process() or parse() before %s", method);Executed by: 
  | 2 | ||||||||||||||||||
| 245 | } executed 2062 times by 2 tests:  end of blockExecuted by: 
  | 2062 | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | bool QCommandLineParserPrivate::registerFoundOption(const QString &optionName) | - | ||||||||||||||||||
| 253 | { | - | ||||||||||||||||||
| 254 |     if (nameHash.contains(optionName)
  | 5-287 | ||||||||||||||||||
| 255 | optionNames.append(optionName); | - | ||||||||||||||||||
| 256 |         return executed 287 times by 2 tests:   true;return true;Executed by: 
 executed 287 times by 2 tests:  return true;Executed by: 
  | 287 | ||||||||||||||||||
| 257 | } else { | - | ||||||||||||||||||
| 258 | unknownOptionNames.append(optionName); | - | ||||||||||||||||||
| 259 |         return executed 5 times by 1 test:   false;return false;Executed by: 
 executed 5 times by 1 test:  return false;Executed by: 
  | 5 | ||||||||||||||||||
| 260 | } | - | ||||||||||||||||||
| 261 | } | - | ||||||||||||||||||
| 262 | bool QCommandLineParserPrivate::parseOptionValue(const QString &optionName, const QString &argument, | - | ||||||||||||||||||
| 263 | QStringList::const_iterator *argumentIterator, QStringList::const_iterator argsEnd) | - | ||||||||||||||||||
| 264 | { | - | ||||||||||||||||||
| 265 | const QLatin1Char assignChar('='); | - | ||||||||||||||||||
| 266 | const NameHash_t::const_iterator nameHashIt = nameHash.constFind(optionName); | - | ||||||||||||||||||
| 267 |     if (nameHashIt != nameHash.constEnd()
  | 1-278 | ||||||||||||||||||
| 268 | const int assignPos = argument.indexOf(assignChar); | - | ||||||||||||||||||
| 269 | const NameHash_t::mapped_type optionOffset = *nameHashIt; | - | ||||||||||||||||||
| 270 | const bool withValue = !commandLineOptionList.at(optionOffset).valueName().isEmpty(); | - | ||||||||||||||||||
| 271 |         if (withValue
  | 134-144 | ||||||||||||||||||
| 272 |             if (assignPos == -1
  | 4-140 | ||||||||||||||||||
| 273 | ++(*argumentIterator); | - | ||||||||||||||||||
| 274 |                 if (*
 
  | 1-139 | ||||||||||||||||||
| 275 | errorText = QCommandLineParser::tr("Missing value after '%1'.").arg(argument); | - | ||||||||||||||||||
| 276 |                     return executed 1 time by 1 test:   false;return false;Executed by: 
 executed 1 time by 1 test:  return false;Executed by: 
  | 1 | ||||||||||||||||||
| 277 | } | - | ||||||||||||||||||
| 278 | optionValuesHash[optionOffset].append(*(*argumentIterator)); | - | ||||||||||||||||||
| 279 |             } executed 139 times by 2 tests:   else {end of blockExecuted by: 
  | 139 | ||||||||||||||||||
| 280 | optionValuesHash[optionOffset].append(argument.mid(assignPos + 1)); | - | ||||||||||||||||||
| 281 |             } executed 4 times by 1 test:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||
| 282 | } else { | - | ||||||||||||||||||
| 283 |             if (assignPos != -1
  | 2-132 | ||||||||||||||||||
| 284 | errorText = QCommandLineParser::tr("Unexpected value after '%1'.").arg(argument.left(assignPos)); | - | ||||||||||||||||||
| 285 |                 return executed 2 times by 1 test:   false;return false;Executed by: 
 executed 2 times by 1 test:  return false;Executed by: 
  | 2 | ||||||||||||||||||
| 286 | } | - | ||||||||||||||||||
| 287 |         } executed 132 times by 2 tests:  end of blockExecuted by: 
  | 132 | ||||||||||||||||||
| 288 | } | - | ||||||||||||||||||
| 289 |     return executed 276 times by 2 tests:   true;return true;Executed by: 
 executed 276 times by 2 tests:  return true;Executed by: 
  | 276 | ||||||||||||||||||
| 290 | } | - | ||||||||||||||||||
| 291 | bool QCommandLineParserPrivate::parse(const QStringList &args) | - | ||||||||||||||||||
| 292 | { | - | ||||||||||||||||||
| 293 | needsParsing = false; | - | ||||||||||||||||||
| 294 | bool error = false; | - | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 |     const QString doubleDashString(([]() -> QString { enum { Size = sizeof(u"" "--")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "--" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 170 times by 2 tests:   qstring_literal_temp;return qstring_literal_temp;Executed by: 
 executed 170 times by 2 tests:   }()));return qstring_literal_temp;Executed by: 
  | 170 | ||||||||||||||||||
| 297 | const QLatin1Char dashChar('-'); | - | ||||||||||||||||||
| 298 | const QLatin1Char assignChar('='); | - | ||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | bool forcePositional = false; | - | ||||||||||||||||||
| 301 | errorText.clear(); | - | ||||||||||||||||||
| 302 | positionalArgumentList.clear(); | - | ||||||||||||||||||
| 303 | optionNames.clear(); | - | ||||||||||||||||||
| 304 | unknownOptionNames.clear(); | - | ||||||||||||||||||
| 305 | optionValuesHash.clear(); | - | ||||||||||||||||||
| 306 | - | |||||||||||||||||||
| 307 |     if (args.isEmpty()
  | 1-169 | ||||||||||||||||||
| 308 | QMessageLogger(__FILE__, 706, __PRETTY_FUNCTION__).warning("QCommandLineParser: argument list cannot be empty, it should contain at least the executable name"); | - | ||||||||||||||||||
| 309 |         return executed 1 time by 1 test:   false;return false;Executed by: 
 executed 1 time by 1 test:  return false;Executed by: 
  | 1 | ||||||||||||||||||
| 310 | } | - | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | QStringList::const_iterator argumentIterator = args.begin(); | - | ||||||||||||||||||
| 313 | ++argumentIterator; | - | ||||||||||||||||||
| 314 | - | |||||||||||||||||||
| 315 |     for (; argumentIterator != args.end()
  | 168-303 | ||||||||||||||||||
| 316 | QString argument = *argumentIterator; | - | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 |         if (forcePositional
  | 9-294 | ||||||||||||||||||
| 319 | positionalArgumentList.append(argument); | - | ||||||||||||||||||
| 320 |         } executed 9 times by 1 test:   else if (argument.startsWith(doubleDashString)end of blockExecuted by: 
 
  | 9-270 | ||||||||||||||||||
| 321 |             if (argument.length() > 2
  | 2-22 | ||||||||||||||||||
| 322 | QString optionName = argument.mid(2).section(assignChar, 0, 0); | - | ||||||||||||||||||
| 323 |                 if (registerFoundOption(optionName)
  | 2-20 | ||||||||||||||||||
| 324 |                     if (!parseOptionValue(optionName, argument, &argumentIterator, args.end())
  | 1-19 | ||||||||||||||||||
| 325 |                         error = true; executed 1 time by 1 test:  error = true;Executed by: 
  | 1 | ||||||||||||||||||
| 326 |                 } executed 20 times by 1 test:   else {end of blockExecuted by: 
  | 20 | ||||||||||||||||||
| 327 | error = true; | - | ||||||||||||||||||
| 328 |                 } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 329 | } else { | - | ||||||||||||||||||
| 330 | forcePositional = true; | - | ||||||||||||||||||
| 331 |             } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 332 |         } else if (argument.startsWith(dashChar)
  | 7-263 | ||||||||||||||||||
| 333 |             if (argument.size() == 1
  | 2-261 | ||||||||||||||||||
| 334 | positionalArgumentList.append(argument); | - | ||||||||||||||||||
| 335 |                 continue; executed 2 times by 1 test:  continue;Executed by: 
  | 2 | ||||||||||||||||||
| 336 | } | - | ||||||||||||||||||
| 337 | switch (singleDashWordOptionMode) { | - | ||||||||||||||||||
| 338 |             case executed 256 times by 2 tests:   QCommandLineParser::ParseAsCompactedShortOptions:case QCommandLineParser::ParseAsCompactedShortOptions:Executed by: 
 executed 256 times by 2 tests:  case QCommandLineParser::ParseAsCompactedShortOptions:Executed by: 
  | 256 | ||||||||||||||||||
| 339 | { | - | ||||||||||||||||||
| 340 | QString optionName; | - | ||||||||||||||||||
| 341 | bool valueFound = false; | - | ||||||||||||||||||
| 342 |                 for (int pos = 1 ; pos < argument.size()
  | 129-265 | ||||||||||||||||||
| 343 | optionName = argument.mid(pos, 1); | - | ||||||||||||||||||
| 344 |                     if (!registerFoundOption(optionName)
  | 3-262 | ||||||||||||||||||
| 345 | error = true; | - | ||||||||||||||||||
| 346 |                     } executed 3 times by 1 test:   else {end of blockExecuted by: 
  | 3 | ||||||||||||||||||
| 347 | const NameHash_t::const_iterator nameHashIt = nameHash.constFind(optionName); | - | ||||||||||||||||||
| 348 | ((!(nameHashIt != nameHash.constEnd())) ? qt_assert("nameHashIt != nameHash.constEnd()",__FILE__,746) : qt_noop()); | - | ||||||||||||||||||
| 349 | const NameHash_t::mapped_type optionOffset = *nameHashIt; | - | ||||||||||||||||||
| 350 | const bool withValue = !commandLineOptionList.at(optionOffset).valueName().isEmpty(); | - | ||||||||||||||||||
| 351 |                         if (withValue
  | 126-136 | ||||||||||||||||||
| 352 |                             if (pos + 1 < argument.size()
  | 2-124 | ||||||||||||||||||
| 353 |                                 if (argument.at(pos + 1) == assignChar
  | 1 | ||||||||||||||||||
| 354 |                                     ++ executed 1 time by 1 test:  pos;++pos;Executed by: 
 executed 1 time by 1 test:  ++pos;Executed by: 
  | 1 | ||||||||||||||||||
| 355 | optionValuesHash[optionOffset].append(argument.mid(pos + 1)); | - | ||||||||||||||||||
| 356 | valueFound = true; | - | ||||||||||||||||||
| 357 |                             } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 358 |                             break; executed 126 times by 2 tests:  break;Executed by: 
  | 126 | ||||||||||||||||||
| 359 | } | - | ||||||||||||||||||
| 360 |                         if (pos + 1 < argument.size()
 
  | 1-128 | ||||||||||||||||||
| 361 |                             break; executed 1 time by 1 test:  break;Executed by: 
  | 1 | ||||||||||||||||||
| 362 |                     } executed 135 times by 2 tests:  end of blockExecuted by: 
  | 135 | ||||||||||||||||||
| 363 | } | - | ||||||||||||||||||
| 364 |                 if (!valueFound
 
  | 1-254 | ||||||||||||||||||
| 365 |                     error = true; executed 1 time by 1 test:  error = true;Executed by: 
  | 1 | ||||||||||||||||||
| 366 |                 break; executed 256 times by 2 tests:  break;Executed by: 
  | 256 | ||||||||||||||||||
| 367 | } | - | ||||||||||||||||||
| 368 |             case executed 5 times by 1 test:   QCommandLineParser::ParseAsLongOptions:case QCommandLineParser::ParseAsLongOptions:Executed by: 
 executed 5 times by 1 test:  case QCommandLineParser::ParseAsLongOptions:Executed by: 
  | 5 | ||||||||||||||||||
| 369 | { | - | ||||||||||||||||||
| 370 | const QString optionName = argument.mid(1).section(assignChar, 0, 0); | - | ||||||||||||||||||
| 371 |                 if (registerFoundOption(optionName)
  | 0-5 | ||||||||||||||||||
| 372 |                     if (!parseOptionValue(optionName, argument, &argumentIterator, args.end())
  | 1-4 | ||||||||||||||||||
| 373 |                         error = true; executed 1 time by 1 test:  error = true;Executed by: 
  | 1 | ||||||||||||||||||
| 374 |                 } executed 5 times by 1 test:   else {end of blockExecuted by: 
  | 5 | ||||||||||||||||||
| 375 | error = true; | - | ||||||||||||||||||
| 376 |                 } never executed:  end of block | 0 | ||||||||||||||||||
| 377 |                 break; executed 5 times by 1 test:  break;Executed by: 
  | 5 | ||||||||||||||||||
| 378 | } | - | ||||||||||||||||||
| 379 | } | - | ||||||||||||||||||
| 380 |         } executed 261 times by 2 tests:   else {end of blockExecuted by: 
  | 261 | ||||||||||||||||||
| 381 | positionalArgumentList.append(argument); | - | ||||||||||||||||||
| 382 |             if (optionsAfterPositionalArgumentsMode == QCommandLineParser::ParseAsPositionalArguments
  | 2-5 | ||||||||||||||||||
| 383 |                 forcePositional = true; executed 2 times by 1 test:  forcePositional = true;Executed by: 
  | 2 | ||||||||||||||||||
| 384 |         } executed 7 times by 1 test:  end of blockExecuted by: 
  | 7 | ||||||||||||||||||
| 385 |         if (argumentIterator == args.end()
  | 1-300 | ||||||||||||||||||
| 386 |             break; executed 1 time by 1 test:  break;Executed by: 
  | 1 | ||||||||||||||||||
| 387 |     } executed 300 times by 2 tests:  end of blockExecuted by: 
  | 300 | ||||||||||||||||||
| 388 |     return executed 169 times by 2 tests:   !error;return !error;Executed by: 
 executed 169 times by 2 tests:  return !error;Executed by: 
  | 169 | ||||||||||||||||||
| 389 | } | - | ||||||||||||||||||
| 390 | bool QCommandLineParser::isSet(const QString &name) const | - | ||||||||||||||||||
| 391 | { | - | ||||||||||||||||||
| 392 | d->checkParsed("isSet"); | - | ||||||||||||||||||
| 393 |     if (d->optionNames.contains(name)
  | 138-509 | ||||||||||||||||||
| 394 |         return executed 138 times by 2 tests:   true;return true;Executed by: 
 executed 138 times by 2 tests:  return true;Executed by: 
  | 138 | ||||||||||||||||||
| 395 | const QStringList aliases = d->aliases(name); | - | ||||||||||||||||||
| 396 | for (const QString &optionName : qAsConst(d->optionNames)) { | - | ||||||||||||||||||
| 397 |         if (aliases.contains(optionName)
  | 12-961 | ||||||||||||||||||
| 398 |             return executed 12 times by 1 test:   true;return true;Executed by: 
 executed 12 times by 1 test:  return true;Executed by: 
  | 12 | ||||||||||||||||||
| 399 |     } executed 961 times by 2 tests:  end of blockExecuted by: 
  | 961 | ||||||||||||||||||
| 400 |     return executed 497 times by 2 tests:   false;return false;Executed by: 
 executed 497 times by 2 tests:  return false;Executed by: 
  | 497 | ||||||||||||||||||
| 401 | } | - | ||||||||||||||||||
| 402 | QString QCommandLineParser::value(const QString &optionName) const | - | ||||||||||||||||||
| 403 | { | - | ||||||||||||||||||
| 404 | d->checkParsed("value"); | - | ||||||||||||||||||
| 405 | const QStringList valueList = values(optionName); | - | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 |     if (!valueList.isEmpty()
  | 154-371 | ||||||||||||||||||
| 408 |         return executed 154 times by 2 tests:   valueList.last();return valueList.last();Executed by: 
 executed 154 times by 2 tests:  return valueList.last();Executed by: 
  | 154 | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 |     return executed 371 times by 2 tests:   QString();return QString();Executed by: 
 executed 371 times by 2 tests:  return QString();Executed by: 
  | 371 | ||||||||||||||||||
| 411 | } | - | ||||||||||||||||||
| 412 | QStringList QCommandLineParser::values(const QString &optionName) const | - | ||||||||||||||||||
| 413 | { | - | ||||||||||||||||||
| 414 | d->checkParsed("values"); | - | ||||||||||||||||||
| 415 | const NameHash_t::const_iterator it = d->nameHash.constFind(optionName); | - | ||||||||||||||||||
| 416 |     if (it != d->nameHash.cend()
  | 4-680 | ||||||||||||||||||
| 417 | const int optionOffset = *it; | - | ||||||||||||||||||
| 418 | QStringList values = d->optionValuesHash.value(optionOffset); | - | ||||||||||||||||||
| 419 |         if (values.isEmpty()
  | 170-510 | ||||||||||||||||||
| 420 |             values = d->commandLineOptionList.at(optionOffset).defaultValues(); executed 510 times by 2 tests:  values = d->commandLineOptionList.at(optionOffset).defaultValues();Executed by: 
  | 510 | ||||||||||||||||||
| 421 |         return executed 680 times by 2 tests:   values;return values;Executed by: 
 executed 680 times by 2 tests:  return values;Executed by: 
  | 680 | ||||||||||||||||||
| 422 | } | - | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | QMessageLogger(__FILE__, 875, __PRETTY_FUNCTION__).warning("QCommandLineParser: option not defined: \"%s\"", QString(optionName).toLocal8Bit().constData()); | - | ||||||||||||||||||
| 425 |     return executed 4 times by 1 test:   QStringList();return QStringList();Executed by: 
 executed 4 times by 1 test:  return QStringList();Executed by: 
  | 4 | ||||||||||||||||||
| 426 | } | - | ||||||||||||||||||
| 427 | bool QCommandLineParser::isSet(const QCommandLineOption &option) const | - | ||||||||||||||||||
| 428 | { | - | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | const auto names = option.names(); | - | ||||||||||||||||||
| 431 |     return executed 368 times by 2 tests:   !names.isEmpty() && isSet(names.first());return !names.isEmpty() && isSet(names.first());Executed by: 
 executed 368 times by 2 tests:  return !names.isEmpty() && isSet(names.first());Executed by: 
  | 368 | ||||||||||||||||||
| 432 | } | - | ||||||||||||||||||
| 433 | QString QCommandLineParser::value(const QCommandLineOption &option) const | - | ||||||||||||||||||
| 434 | { | - | ||||||||||||||||||
| 435 |     return executed 480 times by 1 test:   value(option.names().constFirst());return value(option.names().constFirst());Executed by: 
 executed 480 times by 1 test:  return value(option.names().constFirst());Executed by: 
  | 480 | ||||||||||||||||||
| 436 | } | - | ||||||||||||||||||
| 437 | QStringList QCommandLineParser::values(const QCommandLineOption &option) const | - | ||||||||||||||||||
| 438 | { | - | ||||||||||||||||||
| 439 |     return executed 128 times by 2 tests:   values(option.names().constFirst());return values(option.names().constFirst());Executed by: 
 executed 128 times by 2 tests:  return values(option.names().constFirst());Executed by: 
  | 128 | ||||||||||||||||||
| 440 | } | - | ||||||||||||||||||
| 441 | QStringList QCommandLineParser::positionalArguments() const | - | ||||||||||||||||||
| 442 | { | - | ||||||||||||||||||
| 443 | d->checkParsed("positionalArguments"); | - | ||||||||||||||||||
| 444 |     return executed 145 times by 2 tests:   d->positionalArgumentList;return d->positionalArgumentList;Executed by: 
 executed 145 times by 2 tests:  return d->positionalArgumentList;Executed by: 
  | 145 | ||||||||||||||||||
| 445 | } | - | ||||||||||||||||||
| 446 | QStringList QCommandLineParser::optionNames() const | - | ||||||||||||||||||
| 447 | { | - | ||||||||||||||||||
| 448 | d->checkParsed("optionNames"); | - | ||||||||||||||||||
| 449 |     return executed 35 times by 1 test:   d->optionNames;return d->optionNames;Executed by: 
 executed 35 times by 1 test:  return d->optionNames;Executed by: 
  | 35 | ||||||||||||||||||
| 450 | } | - | ||||||||||||||||||
| 451 | QStringList QCommandLineParser::unknownOptionNames() const | - | ||||||||||||||||||
| 452 | { | - | ||||||||||||||||||
| 453 | d->checkParsed("unknownOptionNames"); | - | ||||||||||||||||||
| 454 |     return executed 26 times by 1 test:   d->unknownOptionNames;return d->unknownOptionNames;Executed by: 
 executed 26 times by 1 test:  return d->unknownOptionNames;Executed by: 
  | 26 | ||||||||||||||||||
| 455 | } | - | ||||||||||||||||||
| 456 | __attribute__((__noreturn__)) void QCommandLineParser::showVersion() | - | ||||||||||||||||||
| 457 | { | - | ||||||||||||||||||
| 458 | showParserMessage(QCoreApplication::applicationName() + QLatin1Char(' ') | - | ||||||||||||||||||
| 459 | + QCoreApplication::applicationVersion() + QLatin1Char('\n'), | - | ||||||||||||||||||
| 460 | UsageMessage); | - | ||||||||||||||||||
| 461 | qt_call_post_routines(); | - | ||||||||||||||||||
| 462 |     :: never executed:  exit(0);::exit(0);never executed:  ::exit(0); | 0 | ||||||||||||||||||
| 463 | } | - | ||||||||||||||||||
| 464 | __attribute__((__noreturn__)) void QCommandLineParser::showHelp(int exitCode) | - | ||||||||||||||||||
| 465 | { | - | ||||||||||||||||||
| 466 | showParserMessage(d->helpText(), UsageMessage); | - | ||||||||||||||||||
| 467 | qt_call_post_routines(); | - | ||||||||||||||||||
| 468 |     :: never executed:  exit(exitCode);::exit(exitCode);never executed:  ::exit(exitCode); | 0 | ||||||||||||||||||
| 469 | } | - | ||||||||||||||||||
| 470 | - | |||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 | - | |||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | - | |||||||||||||||||||
| 475 | - | |||||||||||||||||||
| 476 | QString QCommandLineParser::helpText() const | - | ||||||||||||||||||
| 477 | { | - | ||||||||||||||||||
| 478 |     return executed 1 time by 1 test:   d->helpText();return d->helpText();Executed by: 
 executed 1 time by 1 test:  return d->helpText();Executed by: 
  | 1 | ||||||||||||||||||
| 479 | } | - | ||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | static QString wrapText(const QString &names, int longestOptionNameString, const QString &description) | - | ||||||||||||||||||
| 482 | { | - | ||||||||||||||||||
| 483 | const QLatin1Char nl('\n'); | - | ||||||||||||||||||
| 484 | QString text = QLatin1String(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' '); | - | ||||||||||||||||||
| 485 | const int indent = text.length(); | - | ||||||||||||||||||
| 486 | int lineStart = 0; | - | ||||||||||||||||||
| 487 | int lastBreakable = -1; | - | ||||||||||||||||||
| 488 | const int max = 79 - indent; | - | ||||||||||||||||||
| 489 | int x = 0; | - | ||||||||||||||||||
| 490 | const int len = description.length(); | - | ||||||||||||||||||
| 491 | - | |||||||||||||||||||
| 492 |     for (int i = 0; i < len
  | 1-30 | ||||||||||||||||||
| 493 | ++x; | - | ||||||||||||||||||
| 494 | const QChar c = description.at(i); | - | ||||||||||||||||||
| 495 |         if (c.isSpace()
  | 4-26 | ||||||||||||||||||
| 496 |             lastBreakable = i; executed 4 times by 1 test:  lastBreakable = i;Executed by: 
  | 4 | ||||||||||||||||||
| 497 | - | |||||||||||||||||||
| 498 | int breakAt = -1; | - | ||||||||||||||||||
| 499 | int nextLineStart = -1; | - | ||||||||||||||||||
| 500 |         if (x > max
 
  | 0-30 | ||||||||||||||||||
| 501 | - | |||||||||||||||||||
| 502 | breakAt = lastBreakable; | - | ||||||||||||||||||
| 503 | nextLineStart = lastBreakable + 1; | - | ||||||||||||||||||
| 504 |         } never executed:   else if ((x > max - 1end of block
 
 
  | 0-30 | ||||||||||||||||||
| 505 | - | |||||||||||||||||||
| 506 | breakAt = i + 1; | - | ||||||||||||||||||
| 507 | nextLineStart = breakAt; | - | ||||||||||||||||||
| 508 |         } executed 1 time by 1 test:   else if (c == nlend of blockExecuted by: 
 
  | 0-29 | ||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | breakAt = i; | - | ||||||||||||||||||
| 511 | nextLineStart = i + 1; | - | ||||||||||||||||||
| 512 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 |         if (breakAt != -1
  | 1-29 | ||||||||||||||||||
| 515 | const int numChars = breakAt - lineStart; | - | ||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 |             if (lineStart > 0
  | 0-1 | ||||||||||||||||||
| 518 |                 text += QString(indent, QLatin1Char(' ')); never executed:  text += QString(indent, QLatin1Char(' ')); | 0 | ||||||||||||||||||
| 519 | text += description.midRef(lineStart, numChars) + nl; | - | ||||||||||||||||||
| 520 | x = 0; | - | ||||||||||||||||||
| 521 | lastBreakable = -1; | - | ||||||||||||||||||
| 522 | lineStart = nextLineStart; | - | ||||||||||||||||||
| 523 |             if (lineStart < len
 
  | 0-1 | ||||||||||||||||||
| 524 |                 ++ never executed:  lineStart;++lineStart;never executed:  ++lineStart; | 0 | ||||||||||||||||||
| 525 | i = lineStart; | - | ||||||||||||||||||
| 526 |         } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 527 |     } executed 30 times by 1 test:  end of blockExecuted by: 
  | 30 | ||||||||||||||||||
| 528 | - | |||||||||||||||||||
| 529 |     return executed 1 time by 1 test:   text;return text;Executed by: 
 executed 1 time by 1 test:  return text;Executed by: 
  | 1 | ||||||||||||||||||
| 530 | } | - | ||||||||||||||||||
| 531 | - | |||||||||||||||||||
| 532 | QString QCommandLineParserPrivate::helpText() const | - | ||||||||||||||||||
| 533 | { | - | ||||||||||||||||||
| 534 | const QLatin1Char nl('\n'); | - | ||||||||||||||||||
| 535 | QString text; | - | ||||||||||||||||||
| 536 | QString usage; | - | ||||||||||||||||||
| 537 | usage += QCoreApplication::instance()->arguments().constFirst(); | - | ||||||||||||||||||
| 538 |     if (!commandLineOptionList.isEmpty()
  | 0-1 | ||||||||||||||||||
| 539 |         usage += QLatin1Char(' ') + QCommandLineParser::tr("[options]"); executed 1 time by 1 test:  usage += QLatin1Char(' ') + QCommandLineParser::tr("[options]");Executed by: 
  | 1 | ||||||||||||||||||
| 540 | for (const PositionalArgumentDefinition &arg : positionalArgumentDefinitions) | - | ||||||||||||||||||
| 541 |         usage += QLatin1Char(' ') + arg.syntax; never executed:  usage += QLatin1Char(' ') + arg.syntax; | 0 | ||||||||||||||||||
| 542 | text += QCommandLineParser::tr("Usage: %1").arg(usage) + nl; | - | ||||||||||||||||||
| 543 |     if (!description.isEmpty()
  | 0-1 | ||||||||||||||||||
| 544 |        text += description + nl; never executed:  text += description + nl; | 0 | ||||||||||||||||||
| 545 | text += nl; | - | ||||||||||||||||||
| 546 |     if (!commandLineOptionList.isEmpty()
  | 0-1 | ||||||||||||||||||
| 547 |         text += QCommandLineParser::tr("Options:") + nl; executed 1 time by 1 test:  text += QCommandLineParser::tr("Options:") + nl;Executed by: 
  | 1 | ||||||||||||||||||
| 548 | QStringList optionNameList; | - | ||||||||||||||||||
| 549 | optionNameList.reserve(commandLineOptionList.size()); | - | ||||||||||||||||||
| 550 | int longestOptionNameString = 0; | - | ||||||||||||||||||
| 551 | for (const QCommandLineOption &option : commandLineOptionList) { | - | ||||||||||||||||||
| 552 |         if (option.isHidden()
  | 0-1 | ||||||||||||||||||
| 553 |             continue; never executed:  continue; | 0 | ||||||||||||||||||
| 554 | const QStringList optionNames = option.names(); | - | ||||||||||||||||||
| 555 | QString optionNamesString; | - | ||||||||||||||||||
| 556 | for (const QString &optionName : optionNames) { | - | ||||||||||||||||||
| 557 |             const int numDashes = optionName.length() == 1
  | 0-1 | ||||||||||||||||||
| 558 | optionNamesString += QLatin1String("--", numDashes) + optionName + QLatin1String(", "); | - | ||||||||||||||||||
| 559 |         } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 560 |         if (!optionNames.isEmpty()
  | 0-1 | ||||||||||||||||||
| 561 |             optionNamesString.chop(2); executed 1 time by 1 test:  optionNamesString.chop(2);Executed by: 
  | 1 | ||||||||||||||||||
| 562 | const auto valueName = option.valueName(); | - | ||||||||||||||||||
| 563 |         if (!valueName.isEmpty()
  | 0-1 | ||||||||||||||||||
| 564 |             optionNamesString += QLatin1String(" <") + valueName + QLatin1Char('>'); executed 1 time by 1 test:  optionNamesString += QLatin1String(" <") + valueName + QLatin1Char('>');Executed by: 
  | 1 | ||||||||||||||||||
| 565 | optionNameList.append(optionNamesString); | - | ||||||||||||||||||
| 566 | longestOptionNameString = qMax(longestOptionNameString, optionNamesString.length()); | - | ||||||||||||||||||
| 567 |     } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 568 | ++longestOptionNameString; | - | ||||||||||||||||||
| 569 | auto optionNameIterator = optionNameList.cbegin(); | - | ||||||||||||||||||
| 570 | for (const QCommandLineOption &option : commandLineOptionList) { | - | ||||||||||||||||||
| 571 |         if (option.isHidden()
  | 0-1 | ||||||||||||||||||
| 572 |             continue; never executed:  continue; | 0 | ||||||||||||||||||
| 573 | text += wrapText(*optionNameIterator, longestOptionNameString, option.description()); | - | ||||||||||||||||||
| 574 | ++optionNameIterator; | - | ||||||||||||||||||
| 575 |     } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 576 |     if (!positionalArgumentDefinitions.isEmpty()
  | 0-1 | ||||||||||||||||||
| 577 |         if (!commandLineOptionList.isEmpty()
  | 0 | ||||||||||||||||||
| 578 |             text += nl; never executed:  text += nl; | 0 | ||||||||||||||||||
| 579 | text += QCommandLineParser::tr("Arguments:") + nl; | - | ||||||||||||||||||
| 580 | for (const PositionalArgumentDefinition &arg : positionalArgumentDefinitions) | - | ||||||||||||||||||
| 581 |             text += wrapText(arg.name, longestOptionNameString, arg.description); never executed:  text += wrapText(arg.name, longestOptionNameString, arg.description); | 0 | ||||||||||||||||||
| 582 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 583 |     return executed 1 time by 1 test:   text;return text;Executed by: 
 executed 1 time by 1 test:  return text;Executed by: 
  | 1 | ||||||||||||||||||
| 584 | } | - | ||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |