6 #ifndef SWIFT_MISC_SIMPLECOMMANDPARSER_H
7 #define SWIFT_MISC_SIMPLECOMMANDPARSER_H
10 #include <QStringList>
30 void parse(
const QString &commandLine);
33 bool matchesCommand(
const QString &checkCommand,
const QString &alias1 =
"",
const QString &alias2 =
"");
36 bool commandStartsWith(
const QString &startPattern)
const;
39 bool commandEndsWith(
const QString &endPattern)
const;
42 const QString &part(
int index)
const;
46 QString partAndRemainingStringAfter(
int index)
const;
49 int countParts()
const;
52 bool hasPart(
int index)
const;
55 int countPartsWithoutCommand()
const;
58 bool isInt(
int index)
const;
61 bool isDouble(
int index)
const;
64 int toInt(
int index,
int def = -1)
const;
67 bool toBool(
int index,
bool def =
false)
const;
70 double toDouble(
int index,
double def = -1.0)
const;
73 bool matchesPart(
int index,
const QString &toMatch, Qt::CaseSensitivity cs = Qt::CaseInsensitive)
const;
82 CommandHtmlHelp(
const QString &command,
const QString &help) : command(command), help(help) {}
89 static void registerCommand(
const CommandHtmlHelp &command);
92 static bool registered(
const QString &helpContext);
95 static QString commandsHtmlHelp();
98 QString m_originalLine;
99 QString m_cleanedLine;
100 QString m_commandPart;
101 QStringList m_splitParts;
102 QStringList m_knownCommands;
103 bool m_knownCommand =
false;
105 static QList<CommandHtmlHelp> s_commands;
106 static QSet<QString> s_registered;
109 void setCheckedCommandList(
const QStringList &commands);
112 static QString removeLeadingDot(
const QString &candidate);
115 static QString formatCommand(
const QString &command);
118 static bool isCommand(
const QString &candidate);
Utility methods for simple line parsing used with the command line.
bool isKnownCommand() const
Known command?
Free functions in swift::misc.
CommandHtmlHelp(const QString &command, const QString &help)
Constructor.
static bool less(const CommandHtmlHelp &a, const CommandHtmlHelp &b)
Compare by command.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.