Cute Chess  0.1
matchparser.h
1 /*
2  This file is part of Cute Chess.
3 
4  Cute Chess is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Cute Chess is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef MATCHPARSER_H
19 #define MATCHPARSER_H
20 
21 #include <QMap>
22 #include <QMultiMap>
23 #include <QStringList>
24 #include <QVariant>
25 
26 
33 {
34  public:
36  struct Option
37  {
49  QMap<QString, QString> toMap(const QString& validArgs) const;
50 
53  };
54 
56  MatchParser(const QStringList& args);
57 
71  void addOption(const QString& name,
72  QVariant::Type type,
73  int minArgs = 0,
74  int maxArgs = -1,
75  bool duplicates = false);
83  QVariant takeOption(const QString& name);
85  QList<Option> options() const;
90  bool parse();
91 
92  private:
93  struct PrivateOption
94  {
95  QVariant::Type type;
96  int priority;
97  int minArgs;
98  int maxArgs;
99  bool duplicates;
100  };
101 
102  bool contains(const QString& optionName) const;
103 
104  QStringList m_args;
105  QMultiMap<int, Option> m_options;
106  QMap<QString, PrivateOption> m_validOptions;
107  int m_priority;
108 };
109 
110 #endif // MATCHPARSER_H
MatchParser(const QStringList &args)
Definition: matchparser.cpp:21
QVariant takeOption(const QString &name)
Definition: matchparser.cpp:44
bool parse()
Definition: matchparser.cpp:82
QMap< QString, QString > toMap(const QString &validArgs) const
Definition: matchparser.cpp:161
Definition: matchparser.h:36
void addOption(const QString &name, QVariant::Type type, int minArgs=0, int maxArgs=-1, bool duplicates=false)
Definition: matchparser.cpp:27
QList< Option > options() const
Definition: matchparser.cpp:55
QString name
The name of the option.
Definition: matchparser.h:51
QVariant value
The value of the option.
Definition: matchparser.h:52
A command line parser for EngineMatch options.
Definition: matchparser.h:32