2017-02-19 22:59:39 +00:00
|
|
|
#ifndef LAUNCHERARGUMENTTOKENIZER_HXX
|
|
|
|
#define LAUNCHERARGUMENTTOKENIZER_HXX
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QList>
|
2017-12-15 15:42:36 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QJSValue>
|
2017-02-19 22:59:39 +00:00
|
|
|
|
2017-12-15 15:42:36 +00:00
|
|
|
class ArgumentToken
|
2017-02-19 22:59:39 +00:00
|
|
|
{
|
2017-12-15 15:42:36 +00:00
|
|
|
public:
|
|
|
|
explicit ArgumentToken(QString k, QString v = QString()) : arg(k), value(v) {}
|
|
|
|
|
|
|
|
QString arg;
|
|
|
|
QString value;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LauncherArgumentTokenizer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(QString argString READ argString WRITE setArgString NOTIFY argStringChanged)
|
|
|
|
Q_PROPERTY(QVariantList tokens READ tokens NOTIFY argStringChanged)
|
2017-02-19 22:59:39 +00:00
|
|
|
public:
|
|
|
|
LauncherArgumentTokenizer();
|
|
|
|
|
2017-12-15 15:42:36 +00:00
|
|
|
|
|
|
|
Q_INVOKABLE QList<ArgumentToken> tokenize(QString in) const;
|
|
|
|
|
|
|
|
QString argString() const
|
2017-02-19 22:59:39 +00:00
|
|
|
{
|
2017-12-15 15:42:36 +00:00
|
|
|
return m_argString;
|
|
|
|
}
|
2017-02-19 22:59:39 +00:00
|
|
|
|
2017-12-15 15:42:36 +00:00
|
|
|
QVariantList tokens() const;
|
2017-02-19 22:59:39 +00:00
|
|
|
|
2017-12-15 15:42:36 +00:00
|
|
|
public slots:
|
|
|
|
void setArgString(QString argString);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void argStringChanged(QString argString);
|
2017-02-19 22:59:39 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum State {
|
|
|
|
Start = 0,
|
|
|
|
Key,
|
|
|
|
Value,
|
|
|
|
Quoted,
|
|
|
|
Comment
|
|
|
|
};
|
|
|
|
|
2017-12-15 15:42:36 +00:00
|
|
|
QString m_argString;
|
|
|
|
};
|
2017-02-19 22:59:39 +00:00
|
|
|
|
|
|
|
#endif // LAUNCHERARGUMENTTOKENIZER_HXX
|