1 #ifndef FILTER_STRING_H
2 #define FILTER_STRING_H
3 
4 #include "carddatabase.h"
5 #include "filtertree.h"
6 
7 #include <QMap>
8 #include <QString>
9 #include <functional>
10 #include <utility>
11 
12 typedef CardInfoPtr CardData;
13 typedef std::function<bool(const CardData &)> Filter;
14 typedef std::function<bool(const QString &)> StringMatcher;
15 typedef std::function<bool(int)> NumberMatcher;
16 
17 namespace peg
18 {
19 template <typename Annotation> struct AstBase;
20 struct EmptyType;
21 typedef AstBase<EmptyType> Ast;
22 } // namespace peg
23 
24 class FilterString
25 {
26 public:
27     explicit FilterString(const QString &exp);
check(const CardData & card)28     bool check(const CardData &card)
29     {
30         return result(card);
31     }
32 
valid()33     bool valid()
34     {
35         return _error.isEmpty();
36     }
37 
error()38     QString error()
39     {
40         return _error;
41     }
42 
43 private:
44     QString _error;
45     Filter result;
46 };
47 
48 #endif
49