44 #include <private/qcoreapplication_p.h>
48 #if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
135 qWarning(
"QCommandLineParser: option not defined: \"%ls\"", qUtf16Printable(optionName));
368 qWarning() <<
"QCommandLineParser: already having an option named" <<
name;
483 arg.description = description;
545 #if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
548 static inline bool displayMessageBox()
550 if (GetConsoleWindow())
552 STARTUPINFO startupInfo;
553 startupInfo.cb =
sizeof(STARTUPINFO);
554 GetStartupInfo(&startupInfo);
555 return !(startupInfo.dwFlags & STARTF_USESTDHANDLES);
561 #if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
562 if (displayMessageBox()) {
563 const UINT
flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND
570 MessageBoxW(0,
reinterpret_cast<const wchar_t *
>(
message.utf16()),
625 qWarning(
"QCommandLineParser: call process() or parse() before %s",
method);
662 const int assignPos =
argument.indexOf(assignChar);
666 if (assignPos == -1) {
667 ++(*argumentIterator);
668 if (*argumentIterator == argsEnd) {
677 if (assignPos != -1) {
706 bool forcePositional =
false;
713 if (
args.isEmpty()) {
714 qWarning(
"QCommandLineParser: argument list cannot be empty, it should contain at least the executable name");
721 for (; argumentIterator !=
args.end() ; ++argumentIterator) {
724 if (forcePositional) {
726 }
else if (
argument.startsWith(doubleDashString)) {
736 forcePositional =
true;
738 }
else if (
argument.startsWith(dashChar)) {
747 bool valueFound =
false;
801 forcePositional =
true;
803 if (argumentIterator ==
args.end())
830 if (aliases.contains(optionName))
859 if (!valueList.isEmpty())
860 return valueList.last();
888 const int optionOffset = *
it;
895 qWarning(
"QCommandLineParser: option not defined: \"%ls\"", qUtf16Printable(optionName));
1024 ::exit(EXIT_SUCCESS);
1067 auto nextNameSection = [&]() {
1069 nameIndex += section.
size();
1075 int lastBreakable = -1;
1076 const int max = 79 - (indentation.size() + optionNameMaxWidth + 1);
1080 for (
int i = 0;
i <
len; ++
i) {
1087 int nextLineStart = -1;
1088 if (
x > max && lastBreakable != -1) {
1090 breakAt = lastBreakable;
1091 nextLineStart = lastBreakable + 1;
1092 }
else if ((
x > max - 1 && lastBreakable == -1) ||
i ==
len - 1) {
1095 nextLineStart = breakAt;
1096 }
else if (
c == nl) {
1099 nextLineStart =
i + 1;
1102 if (breakAt != -1) {
1103 const int numChars = breakAt - lineStart;
1109 lineStart = nextLineStart;
1110 if (lineStart <
len && description.
at(lineStart).
isSpace())
1116 while (nameIndex <
names.size()) {
1117 text += indentation + nextNameSection() + nl;
1131 if (includeQtOptions &&
qApp)
1132 qApp->d_func()->addQtOptions(&options);
1144 optionNameList.reserve(options.
size());
1145 int longestOptionNameString = 0;
1152 const int numDashes = optionName.
length() == 1 ? 1 : 2;
1156 optionNamesString.
chop(2);
1157 const auto valueName =
option.valueName();
1158 if (!valueName.isEmpty())
1160 optionNameList.append(optionNamesString);
1161 longestOptionNameString = qMax(longestOptionNameString, optionNamesString.
length());
1163 ++longestOptionNameString;
1164 const int optionNameMaxWidth = qMin(50, longestOptionNameString);
1165 auto optionNameIterator = optionNameList.cbegin();
1169 text += wrapText(*optionNameIterator, optionNameMaxWidth,
option.description());
1170 ++optionNameIterator;
1177 text += wrapText(
arg.name, optionNameMaxWidth,
arg.description);
small capitals from c petite p scientific i
[1]
The QChar class provides a 16-bit Unicode character.
constexpr bool isSpace() const noexcept
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
QString valueName() const
QStringList defaultValues() const
QStringList names() const
The QCommandLineParser class provides a means for handling the command line options.
QString value(const QString &name) const
bool parse(const QStringList &arguments)
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax=QString())
QString applicationDescription() const
QStringList positionalArguments() const
QStringList unknownOptionNames() const
void setSingleDashWordOptionMode(SingleDashWordOptionMode parsingMode)
Q_NORETURN void showVersion()
QStringList values(const QString &name) const
void setApplicationDescription(const QString &description)
bool addOptions(const QList< QCommandLineOption > &options)
bool addOption(const QCommandLineOption &commandLineOption)
Q_NORETURN void showHelp(int exitCode=0)
QString errorText() const
@ ParseAsCompactedShortOptions
bool isSet(const QString &name) const
QStringList optionNames() const
void process(const QStringList &arguments)
void clearPositionalArguments()
OptionsAfterPositionalArgumentsMode
@ ParseAsPositionalArguments
void setOptionsAfterPositionalArgumentsMode(OptionsAfterPositionalArgumentsMode mode)
QCommandLineOption addVersionOption()
QCommandLineOption addHelpOption()
QStringList aliases(const QString &name) const
bool parseOptionValue(const QString &optionName, const QString &argument, QStringList::const_iterator *argumentIterator, QStringList::const_iterator argsEnd)
bool registerFoundOption(const QString &optionName)
NameHash_t nameHash
Hash mapping option names to their offsets in commandLineOptionList and optionArgumentList.
bool builtinVersionOption
Whether addVersionOption was called.
QStringList optionNames
Names of options found on the command line.
QString helpText(bool includeQtOptions) const
QCommandLineParserPrivate()
QString description
Application description.
bool needsParsing
True if parse() needs to be called.
void checkParsed(const char *method)
QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode
The parsing mode for "-abc".
bool parse(const QStringList &args)
bool builtinHelpOption
Whether addHelpOption was called.
QStringList unknownOptionNames
Names of options which were unknown.
QCommandLineParser::OptionsAfterPositionalArgumentsMode optionsAfterPositionalArgumentsMode
How to parse "arg -option".
QStringList positionalArgumentList
Arguments which did not belong to any option.
QList< PositionalArgumentDefinition > positionalArgumentDefinitions
Q_NORETURN void showHelp(int exitCode, bool includeQtOptions)
QList< QCommandLineOption > commandLineOptionList
The command line options used for parsing.
QHash< int, QStringList > optionValuesHash
Option values found (only for options with a value)
QString errorText
Error text set when parse() returns false.
The QCoreApplication class provides an event loop for Qt applications without UI.
static QCoreApplication * instance()
QString applicationVersion
the version of this application
static QStringList arguments()
QString applicationName
the name of this application
const_iterator constFind(const Key &key) const noexcept
const_iterator constEnd() const noexcept
bool contains(const Key &key) const noexcept
T value(const Key &key) const noexcept
friend class const_iterator
const_iterator cend() const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
iterator insert(const Key &key, const T &value)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
QVariant property(const char *name) const
The QString class provides a Unicode character string.
QString leftJustified(qsizetype width, QChar fill=QLatin1Char(' '), bool trunc=false) const
const ushort * utf16() const
QString mid(qsizetype position, qsizetype n=-1) const
const QChar at(qsizetype i) const
The QStringList class provides a list of strings.
The QStringView class provides a unified view on UTF-16 strings with a read-only subset of the QStrin...
QList< QVariant > arguments
typename C::const_iterator const_iterator
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld endif[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if
Q_DECLARE_TYPEINFO(QCommandLineParserPrivate::PositionalArgumentDefinition, Q_RELOCATABLE_TYPE)
QHash< QString, int > NameHash_t
QT_BEGIN_NAMESPACE void Q_CORE_EXPORT qt_call_post_routines()
QList< QString > QStringList
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
GLenum GLuint GLenum GLsizei const GLchar * message
GLenum GLsizei GLsizei GLint * values
[16]
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr offset
GLsizeiptr const void GLenum usage
#define QStringLiteral(str)
QApplication app(argc, argv)
[0]
Documentation for positional arguments.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.