]> git.tdb.fi Git - poefilter.git/blob - source/filter.h
Associate categories and appearances at filter level
[poefilter.git] / source / filter.h
1 #ifndef FILTER_H_
2 #define FILTER_H_
3
4 #include <list>
5 #include <map>
6 #include <string>
7 #include <msp/datafile/objectloader.h>
8 #include <msp/io/base.h>
9 #include "appearance.h"
10
11 class Category;
12 class PoeFilter;
13 class Theme;
14
15 class FilterStatement
16 {
17 private:
18         bool show;
19         std::list<std::string> lines;
20
21 public:
22         FilterStatement();
23
24         void set_show(bool);
25         void add_line(const std::string &);
26
27         static void add_line(std::list<FilterStatement> &, const std::string &);
28
29         void write(Msp::IO::Base &) const;
30 };
31
32
33 class Filter
34 {
35 public:
36         class Loader: public Msp::DataFile::ObjectLoader<Filter>
37         {
38         private:
39                 const PoeFilter &poe;
40
41         public:
42                 Loader(Filter &, const PoeFilter &);
43
44         private:
45                 static std::string glob_to_re(const std::string &);
46                 static bool category_order(const Category *, const Category *);
47
48                 void hide(const std::string &);
49                 void include(const std::string &);
50                 void show(const std::string &);
51         };
52
53 private:
54         struct Block
55         {
56                 const Category *category;
57                 Appearance appearance;
58         };
59
60         std::list<Block> blocks;
61         bool abstract;
62
63 public:
64         Filter();
65
66         bool is_abstract() const { return abstract; }
67         void write(Msp::IO::Base &) const;
68 };
69
70 #endif