2 #include "choicecondition.h"
5 #include "rangecondition.h"
16 Category::Category(const string &n, unsigned o):
22 Category::Category(const Category &other):
24 condition(other.condition ? other.condition->clone() : 0),
26 appearance(other.appearance)
29 Category &Category::operator=(const Category &other)
33 condition = (other.condition ? other.condition->clone() : 0);
35 appearance = other.appearance;
44 void Category::create_statements(list<FilterStatement> &st) const
47 st.push_back(FilterStatement());
50 condition->add_lines(st);
54 Category::Loader::Loader(Category &c, const PoeFilter &p, CompoundCondition *n):
55 DataFile::ObjectLoader<Category>(c),
58 app_loader(c.appearance)
60 add("and", &Loader::and_);
61 add("base_type", &Loader::condition<BaseTypeCondition>);
62 add("category", &Loader::category);
63 add("class", &Loader::condition<ClassCondition>);
64 add_range<DropLevelCondition>("drop_level");
65 add_range<HeightCondition>("height");
66 add_range<ItemLevelCondition>("item_level");
67 add("linked_colors", &Loader::linked_colors);
68 add_range<LinkedSocketsCondition>("linked_sockets");
69 add_range<SocketsCondition>("sockets");
70 add("or", &Loader::or_);
71 add_range<QualityCondition>("quality");
72 add_range<RarityCondition>("rarity");
73 add_range<WidthCondition>("width");
75 add_auxiliary_loader(app_loader);
79 void Category::Loader::add_range(const string &keyword)
81 add(keyword, &Loader::condition<T>);
82 add(keyword, &Loader::condition_range<T>);
83 add("min_"+keyword, &Loader::condition_min<T>);
84 add("max_"+keyword, &Loader::condition_max<T>);
87 void Category::Loader::add_condition(Condition *cond)
91 else if(!obj.condition)
95 compound = new AndCondition;
96 compound->add(obj.condition);
98 obj.condition = compound;
102 void Category::Loader::and_()
104 RefPtr<AndCondition> cond = new AndCondition;
105 Loader sub_ldr(obj, poe, cond.get());
106 load_sub_with(sub_ldr);
107 add_condition(cond.release());
110 void Category::Loader::category(const string &name)
112 const Category &categ = poe.get_category(name);
113 add_condition(categ.condition->clone());
117 void Category::Loader::condition(typename T::Type value)
119 add_condition(new T(value));
123 void Category::Loader::condition_max(typename T::Type max)
125 add_condition(new T(T::Traits::get_min(), max));
129 void Category::Loader::condition_min(typename T::Type min)
131 add_condition(new T(min, T::Traits::get_max()));
135 void Category::Loader::condition_range(typename T::Type min, typename T::Type max)
137 add_condition(new T(min, max));
140 void Category::Loader::linked_colors(const LinkedColorsCondition::Colors &colors)
142 add_condition(new LinkedColorsCondition(colors));
145 void Category::Loader::or_()
147 RefPtr<OrCondition> cond = new OrCondition;
148 Loader sub_ldr(obj, poe, cond.get());
149 load_sub_with(sub_ldr);
150 add_condition(cond.release());