summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-02-10 11:48:58 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-02-10 11:48:58 -0500
commitf625e90a0721483f7f44b94b9bb57cc9d59565e8 (patch)
tree6d8bfe0fb1f1bea9e9c1cc96805ffd77c32411e6
parent4208387c4a6b7ecf43d756a8bba96b9cfc5227b9 (diff)
downloadverbly-f625e90a0721483f7f44b94b9bb57cc9d59565e8.tar.gz
verbly-f625e90a0721483f7f44b94b9bb57cc9d59565e8.tar.bz2
verbly-f625e90a0721483f7f44b94b9bb57cc9d59565e8.zip
Added negative filter conversions to objects
-rw-r--r--lib/form.h10
-rw-r--r--lib/frame.h10
-rw-r--r--lib/notion.h15
-rw-r--r--lib/pronunciation.h91
-rw-r--r--lib/word.h17
5 files changed, 103 insertions, 40 deletions
diff --git a/lib/form.h b/lib/form.h index f501ed2..e3e1185 100644 --- a/lib/form.h +++ b/lib/form.h
@@ -102,6 +102,16 @@ namespace verbly {
102 return (id == id_); 102 return (id == id_);
103 } 103 }
104 104
105 filter operator!() const
106 {
107 if (!valid_)
108 {
109 throw std::domain_error("Bad access to uninitialized form");
110 }
111
112 return (id != id_);
113 }
114
105 // Relationships to other objects 115 // Relationships to other objects
106 116
107 static field words(inflection category); 117 static field words(inflection category);
diff --git a/lib/frame.h b/lib/frame.h index dfe67c0..5fa6c6b 100644 --- a/lib/frame.h +++ b/lib/frame.h
@@ -83,6 +83,16 @@ namespace verbly {
83 return (id == id_); 83 return (id == id_);
84 } 84 }
85 85
86 filter operator!() const
87 {
88 if (!valid_)
89 {
90 throw std::domain_error("Bad access to uninitialized frame");
91 }
92
93 return (id != id_);
94 }
95
86 // Relationships to other objects 96 // Relationships to other objects
87 97
88 static const field words; 98 static const field words;
diff --git a/lib/notion.h b/lib/notion.h index 69f5cef..5388e17 100644 --- a/lib/notion.h +++ b/lib/notion.h
@@ -119,9 +119,24 @@ namespace verbly {
119 119
120 operator filter() const 120 operator filter() const
121 { 121 {
122 if (!valid_)
123 {
124 throw std::domain_error("Bad access to uninitialized notion");
125 }
126
122 return (id == id_); 127 return (id == id_);
123 } 128 }
124 129
130 filter operator!() const
131 {
132 if (!valid_)
133 {
134 throw std::domain_error("Bad access to uninitialized notion");
135 }
136
137 return (id != id_);
138 }
139
125 // Relationships with other objects 140 // Relationships with other objects
126 141
127 static const field words; 142 static const field words;
diff --git a/lib/pronunciation.h b/lib/pronunciation.h index 4723143..73329e4 100644 --- a/lib/pronunciation.h +++ b/lib/pronunciation.h
@@ -10,128 +10,143 @@
10struct sqlite3_stmt; 10struct sqlite3_stmt;
11 11
12namespace verbly { 12namespace verbly {
13 13
14 class form; 14 class form;
15 class word; 15 class word;
16 class database; 16 class database;
17 17
18 class pronunciation { 18 class pronunciation {
19 public: 19 public:
20 20
21 // Default constructor 21 // Default constructor
22 22
23 pronunciation() = default; 23 pronunciation() = default;
24 24
25 // Construct from database 25 // Construct from database
26 26
27 pronunciation(const database& db, sqlite3_stmt* row); 27 pronunciation(const database& db, sqlite3_stmt* row);
28 28
29 // Accessors 29 // Accessors
30 30
31 bool isValid() const 31 bool isValid() const
32 { 32 {
33 return valid_; 33 return valid_;
34 } 34 }
35 35
36 int getId() const 36 int getId() const
37 { 37 {
38 if (!valid_) 38 if (!valid_)
39 { 39 {
40 throw std::domain_error("Bad access to uninitialized pronunciation"); 40 throw std::domain_error("Bad access to uninitialized pronunciation");
41 } 41 }
42 42
43 return id_; 43 return id_;
44 } 44 }
45 45
46 const std::vector<std::string>& getPhonemes() const 46 const std::vector<std::string>& getPhonemes() const
47 { 47 {
48 if (!valid_) 48 if (!valid_)
49 { 49 {
50 throw std::domain_error("Bad access to uninitialized pronunciation"); 50 throw std::domain_error("Bad access to uninitialized pronunciation");
51 } 51 }
52 52
53 return phonemes_; 53 return phonemes_;
54 } 54 }
55 55
56 int getSyllables() const 56 int getSyllables() const
57 { 57 {
58 if (!valid_) 58 if (!valid_)
59 { 59 {
60 throw std::domain_error("Bad access to uninitialized pronunciation"); 60 throw std::domain_error("Bad access to uninitialized pronunciation");
61 } 61 }
62 62
63 return syllables_; 63 return syllables_;
64 } 64 }
65 65
66 std::string getStress() const 66 std::string getStress() const
67 { 67 {
68 if (!valid_) 68 if (!valid_)
69 { 69 {
70 throw std::domain_error("Bad access to uninitialized pronunciation"); 70 throw std::domain_error("Bad access to uninitialized pronunciation");
71 } 71 }
72 72
73 return stress_; 73 return stress_;
74 } 74 }
75 75
76 bool hasRhyme() const 76 bool hasRhyme() const
77 { 77 {
78 if (!valid_) 78 if (!valid_)
79 { 79 {
80 throw std::domain_error("Bad access to uninitialized pronunciation"); 80 throw std::domain_error("Bad access to uninitialized pronunciation");
81 } 81 }
82 82
83 return hasRhyme_; 83 return hasRhyme_;
84 } 84 }
85 85
86 std::string getPrerhyme() const 86 std::string getPrerhyme() const
87 { 87 {
88 if (!valid_) 88 if (!valid_)
89 { 89 {
90 throw std::domain_error("Bad access to uninitialized pronunciation"); 90 throw std::domain_error("Bad access to uninitialized pronunciation");
91 } 91 }
92 92
93 if (!hasRhyme_) 93 if (!hasRhyme_)
94 { 94 {
95 throw std::domain_error("This pronunciation has no rhyme"); 95 throw std::domain_error("This pronunciation has no rhyme");
96 } 96 }
97 97
98 return prerhyme_; 98 return prerhyme_;
99 } 99 }
100 100
101 std::string getRhyme() const 101 std::string getRhyme() const
102 { 102 {
103 if (!valid_) 103 if (!valid_)
104 { 104 {
105 throw std::domain_error("Bad access to uninitialized pronunciation"); 105 throw std::domain_error("Bad access to uninitialized pronunciation");
106 } 106 }
107 107
108 if (!hasRhyme_) 108 if (!hasRhyme_)
109 { 109 {
110 throw std::domain_error("This pronunciation has no rhyme"); 110 throw std::domain_error("This pronunciation has no rhyme");
111 } 111 }
112 112
113 return rhyme_; 113 return rhyme_;
114 } 114 }
115 115
116 // Type info 116 // Type info
117 117
118 static const object objectType; 118 static const object objectType;
119 119
120 static const std::list<std::string> select; 120 static const std::list<std::string> select;
121 121
122 // Query fields 122 // Query fields
123 123
124 static const field id; 124 static const field id;
125 static const field numOfSyllables; 125 static const field numOfSyllables;
126 static const field stress; 126 static const field stress;
127 127
128 operator filter() const 128 operator filter() const
129 { 129 {
130 if (!valid_)
131 {
132 throw std::domain_error("Bad access to uninitialized pronunciation");
133 }
134
130 return (id == id_); 135 return (id == id_);
131 } 136 }
132 137
138 filter operator!() const
139 {
140 if (!valid_)
141 {
142 throw std::domain_error("Bad access to uninitialized pronunciation");
143 }
144
145 return (id != id_);
146 }
147
133 // Relationships to other objects 148 // Relationships to other objects
134 149
135 static const field forms; 150 static const field forms;
136 151
137 // Rhyming relationship 152 // Rhyming relationship
@@ -150,10 +165,10 @@ namespace verbly {
150 }; 165 };
151 166
152 static const rhymes_field rhymes; 167 static const rhymes_field rhymes;
153 168
154 private: 169 private:
155 bool valid_ = false; 170 bool valid_ = false;
156 171
157 int id_; 172 int id_;
158 std::vector<std::string> phonemes_; 173 std::vector<std::string> phonemes_;
159 int syllables_; 174 int syllables_;
@@ -161,14 +176,14 @@ namespace verbly {
161 bool hasRhyme_ = false; 176 bool hasRhyme_ = false;
162 std::string prerhyme_; 177 std::string prerhyme_;
163 std::string rhyme_; 178 std::string rhyme_;
164 179
165 const database* db_; 180 const database* db_;
166 181
167 static const field prerhyme; 182 static const field prerhyme;
168 static const field rhyme; 183 static const field rhyme;
169 184
170 }; 185 };
171 186
172}; 187};
173 188
174#endif /* end of include guard: PRONUNCIATION_H_C68F86B0 */ 189#endif /* end of include guard: PRONUNCIATION_H_C68F86B0 */
diff --git a/lib/word.h b/lib/word.h index dd72c39..e866f09 100644 --- a/lib/word.h +++ b/lib/word.h
@@ -105,8 +105,6 @@ namespace verbly {
105 105
106 const std::vector<form>& getInflections(inflection category) const; 106 const std::vector<form>& getInflections(inflection category) const;
107 107
108
109
110 // Type info 108 // Type info
111 109
112 static const object objectType; 110 static const object objectType;
@@ -121,9 +119,24 @@ namespace verbly {
121 119
122 operator filter() const 120 operator filter() const
123 { 121 {
122 if (!valid_)
123 {
124 throw std::domain_error("Bad access to uninitialized word");
125 }
126
124 return (id == id_); 127 return (id == id_);
125 } 128 }
126 129
130 filter operator!() const
131 {
132 if (!valid_)
133 {
134 throw std::domain_error("Bad access to uninitialized word");
135 }
136
137 return (id != id_);
138 }
139
127 // Relationships with other objects 140 // Relationships with other objects
128 141
129 static const field notions; 142 static const field notions;