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 | { } | - | ||||||||||||||||||
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()) { | - | ||||||||||||||||||
88 | QMessageLogger(__FILE__, 127133, __PRETTY_FUNCTION__).warning("QCommandLineParser: option not defined: \"%s\"", QString(optionName).toLocal8Bit().constData()); | - | ||||||||||||||||||
89 | return QStringList(); | - | ||||||||||||||||||
90 | } | - | ||||||||||||||||||
91 | return commandLineOptionList.at(*it).names(); | - | ||||||||||||||||||
92 | } | - | ||||||||||||||||||
93 | QCommandLineParser::QCommandLineParser() | - | ||||||||||||||||||
94 | : d(new QCommandLineParserPrivate) | - | ||||||||||||||||||
95 | { | - | ||||||||||||||||||
96 | } | - | ||||||||||||||||||
97 | - | |||||||||||||||||||
98 | - | |||||||||||||||||||
99 | - | |||||||||||||||||||
100 | - | |||||||||||||||||||
101 | QCommandLineParser::~QCommandLineParser() | - | ||||||||||||||||||
102 | { | - | ||||||||||||||||||
103 | delete d; | - | ||||||||||||||||||
104 | } | - | ||||||||||||||||||
105 | void QCommandLineParser::setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode) | - | ||||||||||||||||||
106 | { | - | ||||||||||||||||||
107 | d->singleDashWordOptionMode = singleDashWordOptionMode; | - | ||||||||||||||||||
108 | } | - | ||||||||||||||||||
109 | void QCommandLineParser::setOptionsAfterPositionalArgumentsMode(QCommandLineParser::OptionsAfterPositionalArgumentsMode parsingMode) | - | ||||||||||||||||||
110 | { | - | ||||||||||||||||||
111 | d->optionsAfterPositionalArgumentsMode = parsingMode; | - | ||||||||||||||||||
112 | } | - | ||||||||||||||||||
113 | bool QCommandLineParser::addOption(const QCommandLineOption &option) | - | ||||||||||||||||||
114 | { | - | ||||||||||||||||||
115 | const QStringList optionNames = option.names(); | - | ||||||||||||||||||
116 | - | |||||||||||||||||||
117 | if (!optionNames.isEmpty()
| 1-1275 | ||||||||||||||||||
118 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(optionNames)>::type> _container_((optionNames)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const QString &name = *_container_.i; _container_.control; _container_.control = 0: 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 block Executed by:
| 2385 | ||||||||||||||||||
122 | - | |||||||||||||||||||
123 | d->commandLineOptionList.append(option); | - | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | const int offset = d->commandLineOptionList.size() - 1; | - | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(optionNames)>::type> _container_((optionNames)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||
126 | ++_container_.i, _container_.control ^= 1)for (const QString &name = *_container_.i; _container_.control; _container_.control = 0: 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; ++it) | - | ||||||||||||||||||
139 | result &= addOption(*it); | - | ||||||||||||||||||
140 | return result; | - | ||||||||||||||||||
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 qstring_literal_temp; }()) << ([]() -> 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); return qstring_literal_temp; }()), tr("Displays version information.")); | - | ||||||||||||||||||
145 | addOption(opt); | - | ||||||||||||||||||
146 | d->builtinVersionOption = true; | - | ||||||||||||||||||
147 | return opt; | - | ||||||||||||||||||
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 qstring_literal_temp; }()) | - | ||||||||||||||||||
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 qstring_literal_temp; }()), tr("Displays this help.")); | - | ||||||||||||||||||
157 | addOption(opt); | - | ||||||||||||||||||
158 | d->builtinHelpOption = true; | - | ||||||||||||||||||
159 | return opt; | - | ||||||||||||||||||
160 | } | - | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | - | |||||||||||||||||||
163 | - | |||||||||||||||||||
164 | - | |||||||||||||||||||
165 | void QCommandLineParser::setApplicationDescription(const QString &description) | - | ||||||||||||||||||
166 | { | - | ||||||||||||||||||
167 | d->description = description; | - | ||||||||||||||||||
168 | } | - | ||||||||||||||||||
169 | - | |||||||||||||||||||
170 | - | |||||||||||||||||||
171 | - | |||||||||||||||||||
172 | - | |||||||||||||||||||
173 | QString QCommandLineParser::applicationDescription() const | - | ||||||||||||||||||
174 | { | - | ||||||||||||||||||
175 | return d->description; | - | ||||||||||||||||||
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() ? name : syntax; | - | ||||||||||||||||||
183 | d->positionalArgumentDefinitions.append(arg); | - | ||||||||||||||||||
184 | } | - | ||||||||||||||||||
185 | void QCommandLineParser::clearPositionalArguments() | - | ||||||||||||||||||
186 | { | - | ||||||||||||||||||
187 | d->positionalArgumentDefinitions.clear(); | - | ||||||||||||||||||
188 | } | - | ||||||||||||||||||
189 | bool QCommandLineParser::parse(const QStringList &arguments) | - | ||||||||||||||||||
190 | { | - | ||||||||||||||||||
191 | return d->parse(arguments); | - | ||||||||||||||||||
192 | } | - | ||||||||||||||||||
193 | - | |||||||||||||||||||
194 | - | |||||||||||||||||||
195 | - | |||||||||||||||||||
196 | - | |||||||||||||||||||
197 | - | |||||||||||||||||||
198 | QString QCommandLineParser::errorText() const | - | ||||||||||||||||||
199 | { | - | ||||||||||||||||||
200 | if (!d->errorText.isEmpty()) | - | ||||||||||||||||||
201 | return d->errorText; | - | ||||||||||||||||||
202 | if (d->unknownOptionNames.count() == 1) | - | ||||||||||||||||||
203 | return tr("Unknown option '%1'.").arg(d->unknownOptionNames.first()); | - | ||||||||||||||||||
204 | if (d->unknownOptionNames.count() > 1) | - | ||||||||||||||||||
205 | 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; }()))); | - | ||||||||||||||||||
206 | return QString(); | - | ||||||||||||||||||
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 | } | - | ||||||||||||||||||
214 | void QCommandLineParser::process(const QStringList &arguments) | - | ||||||||||||||||||
215 | { | - | ||||||||||||||||||
216 | if (!d->parse(arguments)) { | - | ||||||||||||||||||
217 | showParserMessage(errorText() + QLatin1Char('\n'), ErrorMessage); | - | ||||||||||||||||||
218 | qt_call_post_routines(); | - | ||||||||||||||||||
219 | ::exit(1); | - | ||||||||||||||||||
220 | } | - | ||||||||||||||||||
221 | - | |||||||||||||||||||
222 | if (d->builtinVersionOption && isSet(([]() -> 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); return qstring_literal_temp; }()))) | - | ||||||||||||||||||
223 | showVersion(); | - | ||||||||||||||||||
224 | - | |||||||||||||||||||
225 | if (d->builtinHelpOption && isSet(([]() -> 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 qstring_literal_temp; }()))) | - | ||||||||||||||||||
226 | showHelp(0); | - | ||||||||||||||||||
227 | } | - | ||||||||||||||||||
228 | - | |||||||||||||||||||
229 | - | |||||||||||||||||||
230 | - | |||||||||||||||||||
231 | - | |||||||||||||||||||
232 | - | |||||||||||||||||||
233 | - | |||||||||||||||||||
234 | void QCommandLineParser::process(const QCoreApplication &app) | - | ||||||||||||||||||
235 | { | - | ||||||||||||||||||
236 | - | |||||||||||||||||||
237 | (void)app;; | - | ||||||||||||||||||
238 | process(QCoreApplication::arguments()); | - | ||||||||||||||||||
239 | } | - | ||||||||||||||||||
240 | - | |||||||||||||||||||
241 | void QCommandLineParserPrivate::checkParsed(const char *method) | - | ||||||||||||||||||
242 | { | - | ||||||||||||||||||
243 | if (needsParsing) | - | ||||||||||||||||||
244 | QMessageLogger(__FILE__, 611617, __PRETTY_FUNCTION__).warning("QCommandLineParser: call process() or parse() before %s", method); | - | ||||||||||||||||||
245 | } | - | ||||||||||||||||||
246 | - | |||||||||||||||||||
247 | - | |||||||||||||||||||
248 | - | |||||||||||||||||||
249 | - | |||||||||||||||||||
250 | - | |||||||||||||||||||
251 | - | |||||||||||||||||||
252 | bool QCommandLineParserPrivate::registerFoundOption(const QString &optionName) | - | ||||||||||||||||||
253 | { | - | ||||||||||||||||||
254 | if (nameHash.contains(optionName)) { | - | ||||||||||||||||||
255 | optionNames.append(optionName); | - | ||||||||||||||||||
256 | return true; | - | ||||||||||||||||||
257 | } else { | - | ||||||||||||||||||
258 | unknownOptionNames.append(optionName); | - | ||||||||||||||||||
259 | return false; | - | ||||||||||||||||||
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()) { | - | ||||||||||||||||||
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) { | - | ||||||||||||||||||
272 | if (assignPos == -1) { | - | ||||||||||||||||||
273 | ++(*argumentIterator); | - | ||||||||||||||||||
274 | if (*argumentIterator == argsEnd) { | - | ||||||||||||||||||
275 | errorText = QCommandLineParser::tr("Missing value after '%1'.").arg(argument); | - | ||||||||||||||||||
276 | return false; | - | ||||||||||||||||||
277 | } | - | ||||||||||||||||||
278 | optionValuesHash[optionOffset].append(*(*argumentIterator)); | - | ||||||||||||||||||
279 | } else { | - | ||||||||||||||||||
280 | optionValuesHash[optionOffset].append(argument.mid(assignPos + 1)); | - | ||||||||||||||||||
281 | } | - | ||||||||||||||||||
282 | } else { | - | ||||||||||||||||||
283 | if (assignPos != -1) { | - | ||||||||||||||||||
284 | errorText = QCommandLineParser::tr("Unexpected value after '%1'.").arg(argument.left(assignPos)); | - | ||||||||||||||||||
285 | return false; | - | ||||||||||||||||||
286 | } | - | ||||||||||||||||||
287 | } | - | ||||||||||||||||||
288 | } | - | ||||||||||||||||||
289 | return true; | - | ||||||||||||||||||
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 qstring_literal_temp; }())); | - | ||||||||||||||||||
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()) { | - | ||||||||||||||||||
308 | QMessageLogger(__FILE__, 700706, __PRETTY_FUNCTION__).warning("QCommandLineParser: argument list cannot be empty, it should contain at least the executable name"); | - | ||||||||||||||||||
309 | return false; | - | ||||||||||||||||||
310 | } | - | ||||||||||||||||||
311 | - | |||||||||||||||||||
312 | QStringList::const_iterator argumentIterator = args.begin(); | - | ||||||||||||||||||
313 | ++argumentIterator; | - | ||||||||||||||||||
314 | - | |||||||||||||||||||
315 | for (; argumentIterator != args.end() ; ++argumentIterator) { | - | ||||||||||||||||||
316 | QString argument = *argumentIterator; | - | ||||||||||||||||||
317 | - | |||||||||||||||||||
318 | if (forcePositional) { | - | ||||||||||||||||||
319 | positionalArgumentList.append(argument); | - | ||||||||||||||||||
320 | } else if (argument.startsWith(doubleDashString)) { | - | ||||||||||||||||||
321 | if (argument.length() > 2) { | - | ||||||||||||||||||
322 | QString optionName = argument.mid(2).section(assignChar, 0, 0); | - | ||||||||||||||||||
323 | if (registerFoundOption(optionName)) { | - | ||||||||||||||||||
324 | if (!parseOptionValue(optionName, argument, &argumentIterator, args.end())) | - | ||||||||||||||||||
325 | error = true; | - | ||||||||||||||||||
326 | } else { | - | ||||||||||||||||||
327 | error = true; | - | ||||||||||||||||||
328 | } | - | ||||||||||||||||||
329 | } else { | - | ||||||||||||||||||
330 | forcePositional = true; | - | ||||||||||||||||||
331 | } | - | ||||||||||||||||||
332 | } else if (argument.startsWith(dashChar)) { | - | ||||||||||||||||||
333 | if (argument.size() == 1) { | - | ||||||||||||||||||
334 | positionalArgumentList.append(argument); | - | ||||||||||||||||||
335 | continue; | - | ||||||||||||||||||
336 | } | - | ||||||||||||||||||
337 | switch (singleDashWordOptionMode) { | - | ||||||||||||||||||
338 | case QCommandLineParser::ParseAsCompactedShortOptions: | - | ||||||||||||||||||
339 | { | - | ||||||||||||||||||
340 | QString optionName; | - | ||||||||||||||||||
341 | bool valueFound = false; | - | ||||||||||||||||||
342 | for (int pos = 1 ; pos < argument.size(); ++pos) { | - | ||||||||||||||||||
343 | optionName = argument.mid(pos, 1); | - | ||||||||||||||||||
344 | if (!registerFoundOption(optionName)) { | - | ||||||||||||||||||
345 | error = true; | - | ||||||||||||||||||
346 | } else { | - | ||||||||||||||||||
347 | const NameHash_t::const_iterator nameHashIt = nameHash.constFind(optionName); | - | ||||||||||||||||||
348 | ((!(nameHashIt != nameHash.constEnd())) ? qt_assert("nameHashIt != nameHash.constEnd()",__FILE__,740746) : qt_noop()); | - | ||||||||||||||||||
349 | const NameHash_t::mapped_type optionOffset = *nameHashIt; | - | ||||||||||||||||||
350 | const bool withValue = !commandLineOptionList.at(optionOffset).valueName().isEmpty(); | - | ||||||||||||||||||
351 | if (withValue) { | - | ||||||||||||||||||
352 | if (pos + 1 < argument.size()) { | - | ||||||||||||||||||
353 | if (argument.at(pos + 1) == assignChar) | - | ||||||||||||||||||
354 | ++pos; | - | ||||||||||||||||||
355 | optionValuesHash[optionOffset].append(argument.mid(pos + 1)); | - | ||||||||||||||||||
356 | valueFound = true; | - | ||||||||||||||||||
357 | } | - | ||||||||||||||||||
358 | break; | - | ||||||||||||||||||
359 | } | - | ||||||||||||||||||
360 | if (pos + 1 < argument.size() && argument.at(pos + 1) == assignChar) | - | ||||||||||||||||||
361 | break; | - | ||||||||||||||||||
362 | } | - | ||||||||||||||||||
363 | } | - | ||||||||||||||||||
364 | if (!valueFound && !parseOptionValue(optionName, argument, &argumentIterator, args.end())) | - | ||||||||||||||||||
365 | error = true; | - | ||||||||||||||||||
366 | break; | - | ||||||||||||||||||
367 | } | - | ||||||||||||||||||
368 | case QCommandLineParser::ParseAsLongOptions: | - | ||||||||||||||||||
369 | { | - | ||||||||||||||||||
370 | const QString optionName = argument.mid(1).section(assignChar, 0, 0); | - | ||||||||||||||||||
371 | if (registerFoundOption(optionName)) { | - | ||||||||||||||||||
372 | if (!parseOptionValue(optionName, argument, &argumentIterator, args.end())) | - | ||||||||||||||||||
373 | error = true; | - | ||||||||||||||||||
374 | } else { | - | ||||||||||||||||||
375 | error = true; | - | ||||||||||||||||||
376 | } | - | ||||||||||||||||||
377 | break; | - | ||||||||||||||||||
378 | } | - | ||||||||||||||||||
379 | } | - | ||||||||||||||||||
380 | } else { | - | ||||||||||||||||||
381 | positionalArgumentList.append(argument); | - | ||||||||||||||||||
382 | if (optionsAfterPositionalArgumentsMode == QCommandLineParser::ParseAsPositionalArguments) | - | ||||||||||||||||||
383 | forcePositional = true; | - | ||||||||||||||||||
384 | } | - | ||||||||||||||||||
385 | if (argumentIterator == args.end()) | - | ||||||||||||||||||
386 | break; | - | ||||||||||||||||||
387 | } | - | ||||||||||||||||||
388 | return !error; | - | ||||||||||||||||||
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 (QForeachContainer<typename QtPrivate::remove_reference<decltypeconst QString &optionName : qAsConst(d->optionNames)>::type> _container_((d->optionNames)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QString &optionName = *_container_.i; _container_.control; _container_.control = 0))) { | - | ||||||||||||||||||
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 block Executed 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()) | - | ||||||||||||||||||
408 | return valueList.last(); | - | ||||||||||||||||||
409 | - | |||||||||||||||||||
410 | return QString(); | - | ||||||||||||||||||
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()) { | - | ||||||||||||||||||
417 | const int optionOffset = *it; | - | ||||||||||||||||||
418 | QStringList values = d->optionValuesHash.value(optionOffset); | - | ||||||||||||||||||
419 | if (values.isEmpty()) | - | ||||||||||||||||||
420 | values = d->commandLineOptionList.at(optionOffset).defaultValues(); | - | ||||||||||||||||||
421 | return values; | - | ||||||||||||||||||
422 | } | - | ||||||||||||||||||
423 | - | |||||||||||||||||||
424 | QMessageLogger(__FILE__, 869875, __PRETTY_FUNCTION__).warning("QCommandLineParser: option not defined: \"%s\"", QString(optionName).toLocal8Bit().constData()); | - | ||||||||||||||||||
425 | return QStringList(); | - | ||||||||||||||||||
426 | } | - | ||||||||||||||||||
427 | bool QCommandLineParser::isSet(const QCommandLineOption &option) const | - | ||||||||||||||||||
428 | { | - | ||||||||||||||||||
429 | - | |||||||||||||||||||
430 | return !const auto names = option.names().(); | - | ||||||||||||||||||
431 | return executed 368 times by 2 tests: !names.return !names.isEmpty() && isSet(names.first()); Executed by:
executed 368 times by 2 tests: return !names.isEmpty() && isSet(names.first()); Executed by:
executed 368 times by 2 tests: isEmpty() && isSet(option.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().firstconstFirst());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().firstconstFirst());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 d->positionalArgumentList; | - | ||||||||||||||||||
445 | } | - | ||||||||||||||||||
446 | QStringList QCommandLineParser::optionNames() const | - | ||||||||||||||||||
447 | { | - | ||||||||||||||||||
448 | d->checkParsed("optionNames"); | - | ||||||||||||||||||
449 | return d->optionNames; | - | ||||||||||||||||||
450 | } | - | ||||||||||||||||||
451 | QStringList QCommandLineParser::unknownOptionNames() const | - | ||||||||||||||||||
452 | { | - | ||||||||||||||||||
453 | d->checkParsed("unknownOptionNames"); | - | ||||||||||||||||||
454 | return d->unknownOptionNames; | - | ||||||||||||||||||
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 | ::exit(0); | - | ||||||||||||||||||
463 | } | - | ||||||||||||||||||
464 | __attribute__((__noreturn__)) void QCommandLineParser::showHelp(int exitCode) | - | ||||||||||||||||||
465 | { | - | ||||||||||||||||||
466 | showParserMessage(d->helpText(), UsageMessage); | - | ||||||||||||||||||
467 | qt_call_post_routines(); | - | ||||||||||||||||||
468 | ::exit(exitCode); | - | ||||||||||||||||||
469 | } | - | ||||||||||||||||||
470 | - | |||||||||||||||||||
471 | - | |||||||||||||||||||
472 | - | |||||||||||||||||||
473 | - | |||||||||||||||||||
474 | - | |||||||||||||||||||
475 | - | |||||||||||||||||||
476 | QString QCommandLineParser::helpText() const | - | ||||||||||||||||||
477 | { | - | ||||||||||||||||||
478 | return d->helpText(); | - | ||||||||||||||||||
479 | } | - | ||||||||||||||||||
480 | - | |||||||||||||||||||
481 | static QString wrapText(const QString &names, int longestOptionNameString, const QString &description) | - | ||||||||||||||||||
482 | { | - | ||||||||||||||||||
483 | const QLatin1Char nl('\n'); | - | ||||||||||||||||||
484 | QString text = ([]() -> QString { enum { Size= sizeofQLatin1String(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; }())+ 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 block Executed 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 block Executed by:
| 1 | ||||||||||||||||||
527 | } executed 30 times by 1 test: end of block Executed 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 | constQString exeName =usage; | - | ||||||||||||||||||
537 | usage += QCoreApplication::instance()->arguments().firstconstFirst(); | - | ||||||||||||||||||
538 | QString usage = exeName;if (!commandLineOptionList.isEmpty()
| 0-1 | ||||||||||||||||||
539 | {usage += QLatin1Char(' '); executed 1 time by 1 test: usage += QLatin1Char(' ') + QCommandLineParser::tr("[options]"); Executed by:
| 1 | ||||||||||||||||||
usage += executed 1 time by 1 test: usage += QLatin1Char(' ') + QCommandLineParser::tr("[options]"); Executed by:
executed 1 time by 1 test: ) + QCommandLineParser::tr("[options]");usage += QLatin1Char(' ') + QCommandLineParser::tr("[options]"); Executed by:
executed 1 time by 1 test: usage += QLatin1Char(' ') + QCommandLineParser::tr("[options]"); Executed by:
| ||||||||||||||||||||
540 | } | - | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(positionalArgumentDefinitions)>::type> _container_((positionalArgumentDefinitions)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const PositionalArgumentDefinition &arg = *_container_.i; _container_.control; _container_.control = 0: positionalArgumentDefinitions) | ||||||||||||||||||||
541 | {usage += QLatin1Char(' '); never executed: usage += QLatin1Char(' ') + arg.syntax; | 0 | ||||||||||||||||||
usage += never executed: usage += QLatin1Char(' ') + arg.syntax; never executed: ) + arg.syntax;usage += QLatin1Char(' ') + arg.syntax; never executed: usage += QLatin1Char(' ') + arg.syntax; | ||||||||||||||||||||
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; | - | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(commandLineOptionList)>::type> _container_((commandLineOptionList)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||
551 | ++_container_.i, _container_.control ^= 1)for (const QCommandLineOption &option = *_container_.i; _container_.control; _container_.control = 0: commandLineOptionList) { | - | ||||||||||||||||||
552 | QStringList optionNames; | 0-1 | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltypeif (option.names())>::type> _container_((isHidden()
| ||||||||||||||||||||
553 | continue; never executed: continue; | 0 | ||||||||||||||||||
554 | const QStringList optionNames = option.names())); _container_.control && _container_.i != _container_.e(); | - | ||||||||||||||||||
555 | QString optionNamesString; | - | ||||||||||||||||||
556 | ++_container_.i, _container_.control ^= 1)for (const QString &optionName = *_container_.i; _container_.control; _container_.control = 0: optionNames) { | - | ||||||||||||||||||
557 | if (const int numDashes = optionName.length() == 1
| 0-1 | ||||||||||||||||||
optionNames.append(QLatin1Char('-') + optionName); | ||||||||||||||||||||
else | ||||||||||||||||||||
optionNames.append(([]() -> QString { enum { Size = sizeof? 1 : 2; | ||||||||||||||||||||
558 | optionNamesString += QLatin1String(u"" "--")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringDatanumDashes) }, u"" "--" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())+ optionName + QLatin1String(", "); | - | ||||||||||||||||||
559 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
560 | QString optionNamesString =if (!
| 0-1 | ||||||||||||||||||
561 | optionNamesString.chop executed 1 time by 1 test: optionNamesString.chop(2); Executed by:
executed 1 time by 1 test: (u"" ", ")/2- 1 }; static);optionNamesString.chop(2); Executed by:
executed 1 time by 1 test: optionNamesString.chop(2); Executed by:
| 1 | ||||||||||||||||||
562 | const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ", " }; QStringDataPtr holderauto valueName = { qstring_literaloption.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));valueName(); | - | ||||||||||||||||||
563 | if (!option.valueName()..isEmpty()
| 0-1 | ||||||||||||||||||
564 | optionNamesString += ([]() -> QString { enum { Size = sizeofQLatin1String(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; }())+ option.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 block Executed by:
| 1 | ||||||||||||||||||
568 | ++longestOptionNameString; | - | ||||||||||||||||||
569 | for (int iauto optionNameIterator = 0; i < commandLineOptionListoptionNameList.countcbegin(); | - | ||||||||||||||||||
570 | ++i) {for (const QCommandLineOption &option =: commandLineOptionList.at(i);) { | - | ||||||||||||||||||
571 | if (option.isHidden()
| 0-1 | ||||||||||||||||||
572 | continue; never executed: continue; | 0 | ||||||||||||||||||
573 | text += wrapText(optionNameList.at(i),(*optionNameIterator, longestOptionNameString, option.description()); | - | ||||||||||||||||||
574 | ++optionNameIterator; | - | ||||||||||||||||||
575 | } executed 1 time by 1 test: end of block Executed 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; | - | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(positionalArgumentDefinitions)>::type> _container_((positionalArgumentDefinitions)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||
580 | ++_container_.i, _container_.control ^= 1)for (const PositionalArgumentDefinition &arg = *_container_.i; _container_.control; _container_.control = 0: 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 |