From 6746da6edd7d9d50efe374eabbb79a3cac882d81 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 16 Jan 2017 18:02:50 -0500 Subject: Started structural rewrite The new object structure was designed to build on the existing WordNet structure, while also adding in all of the data that we get from other sources. More information about this can be found on the project wiki. The generator has already been completely rewritten to generate a datafile that uses the new structure. In addition, a number of indexes are created, which does double the size of the datafile, but also allows for much faster lookups. Finally, the new generator is written modularly and is a lot more readable than the old one. The verbly interface to the new object structure has mostly been completed, but has not been tested fully. There is a completely new search API which utilizes a lot of operator overloading; documentation on how to use it should go up at some point. Token processing and verb frames are currently unimplemented. Source for these have been left in the repository for now. --- lib/filter.h | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 lib/filter.h (limited to 'lib/filter.h') diff --git a/lib/filter.h b/lib/filter.h new file mode 100644 index 0000000..d213d7a --- /dev/null +++ b/lib/filter.h @@ -0,0 +1,143 @@ +#ifndef FILTER_H_932BA9C6 +#define FILTER_H_932BA9C6 + +#include +#include +#include +#include "field.h" +#include "enums.h" + +namespace verbly { + + class filter { + public: + enum class type { + empty, + singleton, + group + }; + + enum class comparison { + int_equals, + int_does_not_equal, + int_is_at_least, + int_is_greater_than, + int_is_at_most, + int_is_less_than, + boolean_equals, + string_equals, + string_does_not_equal, + string_is_like, + string_is_not_like, + is_null, + is_not_null, + matches, + does_not_match, + 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; + + private: + union { + struct { + field filterField; + comparison filterType; + union { + std::unique_ptr join; + std::string stringValue; + int intValue; + bool boolValue; + }; + } singleton_; + struct { + std::list children; + bool orlogic; + } group_; + }; + type type_ = type::empty; + + }; + +}; + +#endif /* end of include guard: FILTER_H_932BA9C6 */ -- cgit 1.4.1