"Fossies" - the Fresh Open Source Software Archive

Member "flightgear-2020.3.8/src/GUI/LauncherArgumentTokenizer.hxx" (24 Mar 2021, 1622 Bytes) of package /linux/privat/flightgear-2020.3.8.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "LauncherArgumentTokenizer.hxx" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2020.3.7_vs_2020.3.8.

    1 #ifndef LAUNCHERARGUMENTTOKENIZER_HXX
    2 #define LAUNCHERARGUMENTTOKENIZER_HXX
    3 
    4 #include <set>
    5 
    6 #include <QString>
    7 #include <QList>
    8 #include <QObject>
    9 #include <QJSValue>
   10 
   11 class ArgumentToken
   12 {
   13 public:
   14     explicit ArgumentToken(QString k, QString v = QString()) : arg(k), value(v) {}
   15 
   16     QString arg;
   17     QString value;
   18 };
   19 
   20 class LauncherArgumentTokenizer : public QObject
   21 {
   22     Q_OBJECT
   23 
   24     Q_PROPERTY(QString argString READ argString WRITE setArgString NOTIFY argStringChanged)
   25     Q_PROPERTY(QVariantList tokens READ tokens NOTIFY argStringChanged)
   26 
   27     Q_PROPERTY(bool valid READ isValid NOTIFY argStringChanged)
   28     Q_PROPERTY(bool havePositionalArgs READ havePositionalArgs NOTIFY argStringChanged)
   29     Q_PROPERTY(bool haveUnsupportedArgs READ haveUnsupportedArgs NOTIFY argStringChanged)
   30     Q_PROPERTY(bool haveAircraftArgs READ haveAircraftArgs NOTIFY argStringChanged)
   31 
   32 public:
   33     LauncherArgumentTokenizer();
   34 
   35 
   36     QString argString() const
   37     {
   38         return m_argString;
   39     }
   40 
   41     QVariantList tokens() const;
   42 
   43     bool isValid() const;
   44 
   45     bool haveUnsupportedArgs() const;
   46     bool havePositionalArgs() const;
   47     bool haveAircraftArgs() const;
   48 public slots:
   49     void setArgString(QString argString);
   50 
   51 signals:
   52     void argStringChanged(QString argString);
   53 
   54 private:
   55     bool haveArgsIn(const std::set<std::string> &args) const;
   56 
   57     void tokenize(QString in);
   58 
   59     enum State {
   60         Start = 0,
   61         Key,
   62         Value,
   63         Quoted,
   64         Comment
   65     };
   66 
   67     std::vector<ArgumentToken> m_tokens;
   68     QString m_argString;
   69     bool m_valid = false;
   70 };
   71 
   72 #endif // LAUNCHERARGUMENTTOKENIZER_HXX