From 9e36dbbe74fd9541f0431b7715d3f97895384d28 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 23 Jan 2017 11:44:54 -0500 Subject: Added filter compacting Before statement compilation, empty filters are removed from group filters, and childless group filters become empty filters. --- lib/filter.h | 82 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'lib/filter.h') 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 @@ #include "enums.h" namespace verbly { - + class filter { public: enum class type { @@ -16,7 +16,7 @@ namespace verbly { singleton, group }; - + enum class comparison { int_equals, int_does_not_equal, @@ -36,87 +36,89 @@ namespace verbly { hierarchally_matches, does_not_hierarchally_match }; - + // Copy and move constructors - + filter(const filter& other); filter(filter&& other); - + // Assignment - + filter& operator=(filter other); - + // Swap - + friend void swap(filter& first, filter& second); - + // Destructor - + ~filter(); - + // Accessors - + type getType() const { return type_; } - + // Empty - + filter(); - + // Singleton - + filter(field filterField, comparison filterType, int filterValue); filter(field filterField, comparison filterType, std::string filterValue); filter(field filterField, comparison filterType, bool filterValue); filter(field filterField, comparison filterType); filter(field joinOn, comparison filterType, filter joinCondition); - + field getField() const; - + comparison getComparison() const; - + filter getJoinCondition() const; - + std::string getStringArgument() const; - + int getIntegerArgument() const; - + bool getBooleanArgument() const; - + // Group - + explicit filter(bool orlogic); - + bool getOrlogic() const; - + filter operator+(filter condition) const; - + filter& operator+=(filter condition); - + using const_iterator = std::list::const_iterator; - + const_iterator begin() const; - + const_iterator end() const; - + // Negation - + filter operator!() const; - + // Groupifying - + filter operator&&(filter condition) const; filter operator||(filter condition) const; - + filter& operator&=(filter condition); filter& operator|=(filter condition); - + // Utility - + filter normalize(object context) const; - + + filter compact() const; + private: union { struct { @@ -135,9 +137,9 @@ namespace verbly { } group_; }; type type_ = type::empty; - + }; - + }; #endif /* end of include guard: FILTER_H_932BA9C6 */ -- cgit 1.4.1