]> git.tdb.fi Git - builder.git/blob - source/booleanevaluator.h
Refactor transitive dependencies to work on all targets
[builder.git] / source / booleanevaluator.h
1 #ifndef BOOLEANEVALUATOR_H_
2 #define BOOLEANEVALUATOR_H_
3
4 #include <string>
5 #include <vector>
6 #include <sigc++/slot.h>
7
8 class BooleanEvaluator
9 {
10 public:
11         typedef sigc::slot<bool, const std::string &, const std::string *> Slot;
12
13 private:
14         Slot slot;
15         std::string ops;
16         std::vector<std::string> var_stack;
17         std::vector<unsigned char> value_stack;
18         std::vector<char> op_stack;
19         bool last_was_op;
20
21 public:
22         BooleanEvaluator(const Slot &, bool = true);
23
24         bool evaluate(const std::string &);
25 private:
26         void push_op(char);
27         bool pop_value();
28         void collapse(unsigned);
29         unsigned precedence(char);
30         bool is_unary(char);
31         bool is_logic(char);
32 };
33
34 #endif