summary refs log tree commit diff stats
path: root/lib/filter.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-01-16 18:02:50 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-01-16 18:02:50 -0500
commit6746da6edd7d9d50efe374eabbb79a3cac882d81 (patch)
treeff20917e08b08d36b9541c1371106596e7bec442 /lib/filter.h
parent4af7e55733098ca42f75a4ffaca1b0f6bab4dd36 (diff)
downloadverbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.tar.gz
verbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.tar.bz2
verbly-6746da6edd7d9d50efe374eabbb79a3cac882d81.zip
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.
Diffstat (limited to 'lib/filter.h')
-rw-r--r--lib/filter.h143
1 files changed, 143 insertions, 0 deletions
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 @@
1#ifndef FILTER_H_932BA9C6
2#define FILTER_H_932BA9C6
3
4#include <list>
5#include <string>
6#include <memory>
7#include "field.h"
8#include "enums.h"
9
10namespace verbly {
11
12 class filter {
13 public:
14 enum class type {
15 empty,
16 singleton,
17 group
18 };
19
20 enum class comparison {
21 int_equals,
22 int_does_not_equal,
23 int_is_at_least,
24 int_is_greater_than,
25 int_is_at_most,
26 int_is_less_than,
27 boolean_equals,
28 string_equals,
29 string_does_not_equal,
30 string_is_like,
31 string_is_not_like,
32 is_null,
33 is_not_null,
34 matches,
35 does_not_match,
36 hierarchally_matches,
37 does_not_hierarchally_match
38 };
39
40 // Copy and move constructors
41
42 filter(const filter& other);
43 filter(filter&& other);
44
45 // Assignment
46
47 filter& operator=(filter other);
48
49 // Swap
50
51 friend void swap(filter& first, filter& second);
52
53 // Destructor
54
55 ~filter();
56
57 // Accessors
58
59 type getType() const
60 {
61 return type_;
62 }
63
64 // Empty
65
66 filter();
67
68 // Singleton
69
70 filter(field filterField, comparison filterType, int filterValue);
71 filter(field filterField, comparison filterType, std::string filterValue);
72 filter(field filterField, comparison filterType, bool filterValue);
73 filter(field filterField, comparison filterType);
74 filter(field joinOn, comparison filterType, filter joinCondition);
75
76 field getField() const;
77
78 comparison getComparison() const;
79
80 filter getJoinCondition() const;
81
82 std::string getStringArgument() const;
83
84 int getIntegerArgument() const;
85
86 bool getBooleanArgument() const;
87
88 // Group
89
90 explicit filter(bool orlogic);
91
92 bool getOrlogic() const;
93
94 filter operator+(filter condition) const;
95
96 filter& operator+=(filter condition);
97
98 using const_iterator = std::list<filter>::const_iterator;
99
100 const_iterator begin() const;
101
102 const_iterator end() const;
103
104 // Negation
105
106 filter operator!() const;
107
108 // Groupifying
109
110 filter operator&&(filter condition) const;
111 filter operator||(filter condition) const;
112
113 filter& operator&=(filter condition);
114 filter& operator|=(filter condition);
115
116 // Utility
117
118 filter normalize(object context) const;
119
120 private:
121 union {
122 struct {
123 field filterField;
124 comparison filterType;
125 union {
126 std::unique_ptr<filter> join;
127 std::string stringValue;
128 int intValue;
129 bool boolValue;
130 };
131 } singleton_;
132 struct {
133 std::list<filter> children;
134 bool orlogic;
135 } group_;
136 };
137 type type_ = type::empty;
138
139 };
140
141};
142
143#endif /* end of include guard: FILTER_H_932BA9C6 */