diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-01-23 11:44:54 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-01-23 11:44:54 -0500 |
| commit | 9e36dbbe74fd9541f0431b7715d3f97895384d28 (patch) | |
| tree | 05121ec1fbb2aceb5f60764a290122711d0d7251 /lib/filter.h | |
| parent | d19c329607d611901540e5d3d746c1a94a0b6210 (diff) | |
| download | verbly-9e36dbbe74fd9541f0431b7715d3f97895384d28.tar.gz verbly-9e36dbbe74fd9541f0431b7715d3f97895384d28.tar.bz2 verbly-9e36dbbe74fd9541f0431b7715d3f97895384d28.zip | |
Added filter compacting
Before statement compilation, empty filters are removed from group filters, and childless group filters become empty filters.
Diffstat (limited to 'lib/filter.h')
| -rw-r--r-- | lib/filter.h | 82 |
1 files changed, 42 insertions, 40 deletions
| diff --git a/lib/filter.h b/lib/filter.h index d213d7a..dcadf95 100644 --- a/lib/filter.h +++ b/lib/filter.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "enums.h" | 8 | #include "enums.h" |
| 9 | 9 | ||
| 10 | namespace verbly { | 10 | namespace verbly { |
| 11 | 11 | ||
| 12 | class filter { | 12 | class filter { |
| 13 | public: | 13 | public: |
| 14 | enum class type { | 14 | enum class type { |
| @@ -16,7 +16,7 @@ namespace verbly { | |||
| 16 | singleton, | 16 | singleton, |
| 17 | group | 17 | group |
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | enum class comparison { | 20 | enum class comparison { |
| 21 | int_equals, | 21 | int_equals, |
| 22 | int_does_not_equal, | 22 | int_does_not_equal, |
| @@ -36,87 +36,89 @@ namespace verbly { | |||
| 36 | hierarchally_matches, | 36 | hierarchally_matches, |
| 37 | does_not_hierarchally_match | 37 | does_not_hierarchally_match |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | // Copy and move constructors | 40 | // Copy and move constructors |
| 41 | 41 | ||
| 42 | filter(const filter& other); | 42 | filter(const filter& other); |
| 43 | filter(filter&& other); | 43 | filter(filter&& other); |
| 44 | 44 | ||
| 45 | // Assignment | 45 | // Assignment |
| 46 | 46 | ||
| 47 | filter& operator=(filter other); | 47 | filter& operator=(filter other); |
| 48 | 48 | ||
| 49 | // Swap | 49 | // Swap |
| 50 | 50 | ||
| 51 | friend void swap(filter& first, filter& second); | 51 | friend void swap(filter& first, filter& second); |
| 52 | 52 | ||
| 53 | // Destructor | 53 | // Destructor |
| 54 | 54 | ||
| 55 | ~filter(); | 55 | ~filter(); |
| 56 | 56 | ||
| 57 | // Accessors | 57 | // Accessors |
| 58 | 58 | ||
| 59 | type getType() const | 59 | type getType() const |
| 60 | { | 60 | { |
| 61 | return type_; | 61 | return type_; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | // Empty | 64 | // Empty |
| 65 | 65 | ||
| 66 | filter(); | 66 | filter(); |
| 67 | 67 | ||
| 68 | // Singleton | 68 | // Singleton |
| 69 | 69 | ||
| 70 | filter(field filterField, comparison filterType, int filterValue); | 70 | filter(field filterField, comparison filterType, int filterValue); |
| 71 | filter(field filterField, comparison filterType, std::string filterValue); | 71 | filter(field filterField, comparison filterType, std::string filterValue); |
| 72 | filter(field filterField, comparison filterType, bool filterValue); | 72 | filter(field filterField, comparison filterType, bool filterValue); |
| 73 | filter(field filterField, comparison filterType); | 73 | filter(field filterField, comparison filterType); |
| 74 | filter(field joinOn, comparison filterType, filter joinCondition); | 74 | filter(field joinOn, comparison filterType, filter joinCondition); |
| 75 | 75 | ||
| 76 | field getField() const; | 76 | field getField() const; |
| 77 | 77 | ||
| 78 | comparison getComparison() const; | 78 | comparison getComparison() const; |
| 79 | 79 | ||
| 80 | filter getJoinCondition() const; | 80 | filter getJoinCondition() const; |
| 81 | 81 | ||
| 82 | std::string getStringArgument() const; | 82 | std::string getStringArgument() const; |
| 83 | 83 | ||
| 84 | int getIntegerArgument() const; | 84 | int getIntegerArgument() const; |
| 85 | 85 | ||
| 86 | bool getBooleanArgument() const; | 86 | bool getBooleanArgument() const; |
| 87 | 87 | ||
| 88 | // Group | 88 | // Group |
| 89 | 89 | ||
| 90 | explicit filter(bool orlogic); | 90 | explicit filter(bool orlogic); |
| 91 | 91 | ||
| 92 | bool getOrlogic() const; | 92 | bool getOrlogic() const; |
| 93 | 93 | ||
| 94 | filter operator+(filter condition) const; | 94 | filter operator+(filter condition) const; |
| 95 | 95 | ||
| 96 | filter& operator+=(filter condition); | 96 | filter& operator+=(filter condition); |
| 97 | 97 | ||
| 98 | using const_iterator = std::list<filter>::const_iterator; | 98 | using const_iterator = std::list<filter>::const_iterator; |
| 99 | 99 | ||
| 100 | const_iterator begin() const; | 100 | const_iterator begin() const; |
| 101 | 101 | ||
| 102 | const_iterator end() const; | 102 | const_iterator end() const; |
| 103 | 103 | ||
| 104 | // Negation | 104 | // Negation |
| 105 | 105 | ||
| 106 | filter operator!() const; | 106 | filter operator!() const; |
| 107 | 107 | ||
| 108 | // Groupifying | 108 | // Groupifying |
| 109 | 109 | ||
| 110 | filter operator&&(filter condition) const; | 110 | filter operator&&(filter condition) const; |
| 111 | filter operator||(filter condition) const; | 111 | filter operator||(filter condition) const; |
| 112 | 112 | ||
| 113 | filter& operator&=(filter condition); | 113 | filter& operator&=(filter condition); |
| 114 | filter& operator|=(filter condition); | 114 | filter& operator|=(filter condition); |
| 115 | 115 | ||
| 116 | // Utility | 116 | // Utility |
| 117 | 117 | ||
| 118 | filter normalize(object context) const; | 118 | filter normalize(object context) const; |
| 119 | 119 | ||
| 120 | filter compact() const; | ||
| 121 | |||
| 120 | private: | 122 | private: |
| 121 | union { | 123 | union { |
| 122 | struct { | 124 | struct { |
| @@ -135,9 +137,9 @@ namespace verbly { | |||
| 135 | } group_; | 137 | } group_; |
| 136 | }; | 138 | }; |
| 137 | type type_ = type::empty; | 139 | type type_ = type::empty; |
| 138 | 140 | ||
| 139 | }; | 141 | }; |
| 140 | 142 | ||
| 141 | }; | 143 | }; |
| 142 | 144 | ||
| 143 | #endif /* end of include guard: FILTER_H_932BA9C6 */ | 145 | #endif /* end of include guard: FILTER_H_932BA9C6 */ |
