diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-01-24 21:50:39 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2017-01-24 21:50:39 -0500 |
commit | e1fa4a088dd95caef22045f905a9d5d22b71bef0 (patch) | |
tree | 09f30eadcbb5a7352f19a6070dc363298f16aff8 /generator/part.cpp | |
parent | 0ba0fff06fb679f5cabedd52257fc0c38a600279 (diff) | |
download | verbly-e1fa4a088dd95caef22045f905a9d5d22b71bef0.tar.gz verbly-e1fa4a088dd95caef22045f905a9d5d22b71bef0.tar.bz2 verbly-e1fa4a088dd95caef22045f905a9d5d22b71bef0.zip |
Whitespace changes
Diffstat (limited to 'generator/part.cpp')
-rw-r--r-- | generator/part.cpp | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/generator/part.cpp b/generator/part.cpp index b69ec65..8a75ed4 100644 --- a/generator/part.cpp +++ b/generator/part.cpp | |||
@@ -3,56 +3,56 @@ | |||
3 | 3 | ||
4 | namespace verbly { | 4 | namespace verbly { |
5 | namespace generator { | 5 | namespace generator { |
6 | 6 | ||
7 | part part::createNounPhrase(std::string role, selrestr selrestrs, std::set<std::string> synrestrs) | 7 | part part::createNounPhrase(std::string role, selrestr selrestrs, std::set<std::string> synrestrs) |
8 | { | 8 | { |
9 | part p(type::noun_phrase); | 9 | part p(type::noun_phrase); |
10 | 10 | ||
11 | new(&p.noun_phrase_.role) std::string(std::move(role)); | 11 | new(&p.noun_phrase_.role) std::string(std::move(role)); |
12 | new(&p.noun_phrase_.selrestrs) selrestr(std::move(selrestrs)); | 12 | new(&p.noun_phrase_.selrestrs) selrestr(std::move(selrestrs)); |
13 | new(&p.noun_phrase_.synrestrs) std::set<std::string>(std::move(synrestrs)); | 13 | new(&p.noun_phrase_.synrestrs) std::set<std::string>(std::move(synrestrs)); |
14 | 14 | ||
15 | return p; | 15 | return p; |
16 | } | 16 | } |
17 | 17 | ||
18 | part part::createVerb() | 18 | part part::createVerb() |
19 | { | 19 | { |
20 | return part(type::verb); | 20 | return part(type::verb); |
21 | } | 21 | } |
22 | 22 | ||
23 | part part::createPreposition(std::set<std::string> choices, bool literal) | 23 | part part::createPreposition(std::set<std::string> choices, bool literal) |
24 | { | 24 | { |
25 | part p(type::preposition); | 25 | part p(type::preposition); |
26 | 26 | ||
27 | new(&p.preposition_.choices) std::set<std::string>(std::move(choices)); | 27 | new(&p.preposition_.choices) std::set<std::string>(std::move(choices)); |
28 | p.preposition_.literal = literal; | 28 | p.preposition_.literal = literal; |
29 | 29 | ||
30 | return p; | 30 | return p; |
31 | } | 31 | } |
32 | 32 | ||
33 | part part::createAdjective() | 33 | part part::createAdjective() |
34 | { | 34 | { |
35 | return part(type::adjective); | 35 | return part(type::adjective); |
36 | } | 36 | } |
37 | 37 | ||
38 | part part::createAdverb() | 38 | part part::createAdverb() |
39 | { | 39 | { |
40 | return part(type::adverb); | 40 | return part(type::adverb); |
41 | } | 41 | } |
42 | 42 | ||
43 | part part::createLiteral(std::string value) | 43 | part part::createLiteral(std::string value) |
44 | { | 44 | { |
45 | part p(type::literal); | 45 | part p(type::literal); |
46 | 46 | ||
47 | new(&p.literal_) std::string(std::move(value)); | 47 | new(&p.literal_) std::string(std::move(value)); |
48 | 48 | ||
49 | return p; | 49 | return p; |
50 | } | 50 | } |
51 | 51 | ||
52 | part::part(const part& other) | 52 | part::part(const part& other) |
53 | { | 53 | { |
54 | type_ = other.type_; | 54 | type_ = other.type_; |
55 | 55 | ||
56 | switch (type_) | 56 | switch (type_) |
57 | { | 57 | { |
58 | case type::noun_phrase: | 58 | case type::noun_phrase: |
@@ -60,25 +60,25 @@ namespace verbly { | |||
60 | new(&noun_phrase_.role) std::string(other.noun_phrase_.role); | 60 | new(&noun_phrase_.role) std::string(other.noun_phrase_.role); |
61 | new(&noun_phrase_.selrestrs) selrestr(other.noun_phrase_.selrestrs); | 61 | new(&noun_phrase_.selrestrs) selrestr(other.noun_phrase_.selrestrs); |
62 | new(&noun_phrase_.synrestrs) std::set<std::string>(other.noun_phrase_.synrestrs); | 62 | new(&noun_phrase_.synrestrs) std::set<std::string>(other.noun_phrase_.synrestrs); |
63 | 63 | ||
64 | break; | 64 | break; |
65 | } | 65 | } |
66 | 66 | ||
67 | case type::preposition: | 67 | case type::preposition: |
68 | { | 68 | { |
69 | new(&preposition_.choices) std::set<std::string>(other.preposition_.choices); | 69 | new(&preposition_.choices) std::set<std::string>(other.preposition_.choices); |
70 | preposition_.literal = other.preposition_.literal; | 70 | preposition_.literal = other.preposition_.literal; |
71 | 71 | ||
72 | break; | 72 | break; |
73 | } | 73 | } |
74 | 74 | ||
75 | case type::literal: | 75 | case type::literal: |
76 | { | 76 | { |
77 | new(&literal_) std::string(other.literal_); | 77 | new(&literal_) std::string(other.literal_); |
78 | 78 | ||
79 | break; | 79 | break; |
80 | } | 80 | } |
81 | 81 | ||
82 | case type::verb: | 82 | case type::verb: |
83 | case type::adjective: | 83 | case type::adjective: |
84 | case type::adverb: | 84 | case type::adverb: |
@@ -88,23 +88,23 @@ namespace verbly { | |||
88 | } | 88 | } |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | part::part(part&& other) : part() | 92 | part::part(part&& other) : part() |
93 | { | 93 | { |
94 | swap(*this, other); | 94 | swap(*this, other); |
95 | } | 95 | } |
96 | 96 | ||
97 | part& part::operator=(part other) | 97 | part& part::operator=(part other) |
98 | { | 98 | { |
99 | swap(*this, other); | 99 | swap(*this, other); |
100 | 100 | ||
101 | return *this; | 101 | return *this; |
102 | } | 102 | } |
103 | 103 | ||
104 | void swap(part& first, part& second) | 104 | void swap(part& first, part& second) |
105 | { | 105 | { |
106 | using type = part::type; | 106 | using type = part::type; |
107 | 107 | ||
108 | type tempType = first.type_; | 108 | type tempType = first.type_; |
109 | std::string tempRole; | 109 | std::string tempRole; |
110 | selrestr tempSelrestrs; | 110 | selrestr tempSelrestrs; |
@@ -112,7 +112,7 @@ namespace verbly { | |||
112 | std::set<std::string> tempChoices; | 112 | std::set<std::string> tempChoices; |
113 | bool tempPrepLiteral; | 113 | bool tempPrepLiteral; |
114 | std::string tempLiteralValue; | 114 | std::string tempLiteralValue; |
115 | 115 | ||
116 | switch (tempType) | 116 | switch (tempType) |
117 | { | 117 | { |
118 | case type::noun_phrase: | 118 | case type::noun_phrase: |
@@ -120,25 +120,25 @@ namespace verbly { | |||
120 | tempRole = std::move(first.noun_phrase_.role); | 120 | tempRole = std::move(first.noun_phrase_.role); |
121 | tempSelrestrs = std::move(first.noun_phrase_.selrestrs); | 121 | tempSelrestrs = std::move(first.noun_phrase_.selrestrs); |
122 | tempSynrestrs = std::move(first.noun_phrase_.synrestrs); | 122 | tempSynrestrs = std::move(first.noun_phrase_.synrestrs); |
123 | 123 | ||
124 | break; | 124 | break; |
125 | } | 125 | } |
126 | 126 | ||
127 | case type::preposition: | 127 | case type::preposition: |
128 | { | 128 | { |
129 | tempChoices = std::move(first.preposition_.choices); | 129 | tempChoices = std::move(first.preposition_.choices); |
130 | tempPrepLiteral = first.preposition_.literal; | 130 | tempPrepLiteral = first.preposition_.literal; |
131 | 131 | ||
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | 134 | ||
135 | case type::literal: | 135 | case type::literal: |
136 | { | 136 | { |
137 | tempLiteralValue = std::move(first.literal_); | 137 | tempLiteralValue = std::move(first.literal_); |
138 | 138 | ||
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | 141 | ||
142 | case type::verb: | 142 | case type::verb: |
143 | case type::adjective: | 143 | case type::adjective: |
144 | case type::adverb: | 144 | case type::adverb: |
@@ -147,11 +147,11 @@ namespace verbly { | |||
147 | break; | 147 | break; |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | first.~part(); | 151 | first.~part(); |
152 | 152 | ||
153 | first.type_ = second.type_; | 153 | first.type_ = second.type_; |
154 | 154 | ||
155 | switch (first.type_) | 155 | switch (first.type_) |
156 | { | 156 | { |
157 | case type::noun_phrase: | 157 | case type::noun_phrase: |
@@ -159,25 +159,25 @@ namespace verbly { | |||
159 | new(&first.noun_phrase_.role) std::string(std::move(second.noun_phrase_.role)); | 159 | new(&first.noun_phrase_.role) std::string(std::move(second.noun_phrase_.role)); |
160 | new(&first.noun_phrase_.selrestrs) selrestr(std::move(second.noun_phrase_.selrestrs)); | 160 | new(&first.noun_phrase_.selrestrs) selrestr(std::move(second.noun_phrase_.selrestrs)); |
161 | new(&first.noun_phrase_.synrestrs) std::set<std::string>(std::move(second.noun_phrase_.synrestrs)); | 161 | new(&first.noun_phrase_.synrestrs) std::set<std::string>(std::move(second.noun_phrase_.synrestrs)); |
162 | 162 | ||
163 | break; | 163 | break; |
164 | } | 164 | } |
165 | 165 | ||
166 | case type::preposition: | 166 | case type::preposition: |
167 | { | 167 | { |
168 | new(&first.preposition_.choices) std::set<std::string>(std::move(second.preposition_.choices)); | 168 | new(&first.preposition_.choices) std::set<std::string>(std::move(second.preposition_.choices)); |
169 | first.preposition_.literal = second.preposition_.literal; | 169 | first.preposition_.literal = second.preposition_.literal; |
170 | 170 | ||
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | 173 | ||
174 | case type::literal: | 174 | case type::literal: |
175 | { | 175 | { |
176 | new(&first.literal_) std::string(std::move(second.literal_)); | 176 | new(&first.literal_) std::string(std::move(second.literal_)); |
177 | 177 | ||
178 | break; | 178 | break; |
179 | } | 179 | } |
180 | 180 | ||
181 | case type::verb: | 181 | case type::verb: |
182 | case type::adjective: | 182 | case type::adjective: |
183 | case type::adverb: | 183 | case type::adverb: |
@@ -186,11 +186,11 @@ namespace verbly { | |||
186 | break; | 186 | break; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | second.~part(); | 190 | second.~part(); |
191 | 191 | ||
192 | second.type_ = tempType; | 192 | second.type_ = tempType; |
193 | 193 | ||
194 | switch (second.type_) | 194 | switch (second.type_) |
195 | { | 195 | { |
196 | case type::noun_phrase: | 196 | case type::noun_phrase: |
@@ -198,25 +198,25 @@ namespace verbly { | |||
198 | new(&second.noun_phrase_.role) std::string(std::move(tempRole)); | 198 | new(&second.noun_phrase_.role) std::string(std::move(tempRole)); |
199 | new(&second.noun_phrase_.selrestrs) selrestr(std::move(tempSelrestrs)); | 199 | new(&second.noun_phrase_.selrestrs) selrestr(std::move(tempSelrestrs)); |
200 | new(&second.noun_phrase_.synrestrs) std::set<std::string>(std::move(tempSynrestrs)); | 200 | new(&second.noun_phrase_.synrestrs) std::set<std::string>(std::move(tempSynrestrs)); |
201 | 201 | ||
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | 204 | ||
205 | case type::preposition: | 205 | case type::preposition: |
206 | { | 206 | { |
207 | new(&second.preposition_.choices) std::set<std::string>(std::move(tempChoices)); | 207 | new(&second.preposition_.choices) std::set<std::string>(std::move(tempChoices)); |
208 | second.preposition_.literal = tempPrepLiteral; | 208 | second.preposition_.literal = tempPrepLiteral; |
209 | 209 | ||
210 | break; | 210 | break; |
211 | } | 211 | } |
212 | 212 | ||
213 | case type::literal: | 213 | case type::literal: |
214 | { | 214 | { |
215 | new(&second.literal_) std::string(std::move(tempLiteralValue)); | 215 | new(&second.literal_) std::string(std::move(tempLiteralValue)); |
216 | 216 | ||
217 | break; | 217 | break; |
218 | } | 218 | } |
219 | 219 | ||
220 | case type::verb: | 220 | case type::verb: |
221 | case type::adjective: | 221 | case type::adjective: |
222 | case type::adverb: | 222 | case type::adverb: |
@@ -226,7 +226,7 @@ namespace verbly { | |||
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | part::~part() | 230 | part::~part() |
231 | { | 231 | { |
232 | switch (type_) | 232 | switch (type_) |
@@ -235,32 +235,32 @@ namespace verbly { | |||
235 | { | 235 | { |
236 | using string_type = std::string; | 236 | using string_type = std::string; |
237 | using set_type = std::set<std::string>; | 237 | using set_type = std::set<std::string>; |
238 | 238 | ||
239 | noun_phrase_.role.~string_type(); | 239 | noun_phrase_.role.~string_type(); |
240 | noun_phrase_.selrestrs.~selrestr(); | 240 | noun_phrase_.selrestrs.~selrestr(); |
241 | noun_phrase_.synrestrs.~set_type(); | 241 | noun_phrase_.synrestrs.~set_type(); |
242 | 242 | ||
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | 245 | ||
246 | case type::preposition: | 246 | case type::preposition: |
247 | { | 247 | { |
248 | using set_type = std::set<std::string>; | 248 | using set_type = std::set<std::string>; |
249 | 249 | ||
250 | preposition_.choices.~set_type(); | 250 | preposition_.choices.~set_type(); |
251 | 251 | ||
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | 254 | ||
255 | case type::literal: | 255 | case type::literal: |
256 | { | 256 | { |
257 | using string_type = std::string; | 257 | using string_type = std::string; |
258 | 258 | ||
259 | literal_.~string_type(); | 259 | literal_.~string_type(); |
260 | 260 | ||
261 | break; | 261 | break; |
262 | } | 262 | } |
263 | 263 | ||
264 | case type::verb: | 264 | case type::verb: |
265 | case type::adjective: | 265 | case type::adjective: |
266 | case type::adverb: | 266 | case type::adverb: |
@@ -270,7 +270,7 @@ namespace verbly { | |||
270 | } | 270 | } |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | std::string part::getNounRole() const | 274 | std::string part::getNounRole() const |
275 | { | 275 | { |
276 | if (type_ == type::noun_phrase) | 276 | if (type_ == type::noun_phrase) |
@@ -280,7 +280,7 @@ namespace verbly { | |||
280 | throw std::domain_error("part::getNounRole is only valid for noun phrase parts"); | 280 | throw std::domain_error("part::getNounRole is only valid for noun phrase parts"); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | selrestr part::getNounSelrestrs() const | 284 | selrestr part::getNounSelrestrs() const |
285 | { | 285 | { |
286 | if (type_ == type::noun_phrase) | 286 | if (type_ == type::noun_phrase) |
@@ -290,7 +290,7 @@ namespace verbly { | |||
290 | throw std::domain_error("part::getNounSelrestrs is only valid for noun phrase parts"); | 290 | throw std::domain_error("part::getNounSelrestrs is only valid for noun phrase parts"); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | std::set<std::string> part::getNounSynrestrs() const | 294 | std::set<std::string> part::getNounSynrestrs() const |
295 | { | 295 | { |
296 | if (type_ == type::noun_phrase) | 296 | if (type_ == type::noun_phrase) |
@@ -300,7 +300,7 @@ namespace verbly { | |||
300 | throw std::domain_error("part::getNounSynrestrs is only valid for noun phrase parts"); | 300 | throw std::domain_error("part::getNounSynrestrs is only valid for noun phrase parts"); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | std::set<std::string> part::getPrepositionChoices() const | 304 | std::set<std::string> part::getPrepositionChoices() const |
305 | { | 305 | { |
306 | if (type_ == type::preposition) | 306 | if (type_ == type::preposition) |
@@ -310,7 +310,7 @@ namespace verbly { | |||
310 | throw std::domain_error("part::getPrepositionChoices is only valid for preposition parts"); | 310 | throw std::domain_error("part::getPrepositionChoices is only valid for preposition parts"); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | bool part::isPrepositionLiteral() const | 314 | bool part::isPrepositionLiteral() const |
315 | { | 315 | { |
316 | if (type_ == type::preposition) | 316 | if (type_ == type::preposition) |
@@ -320,7 +320,7 @@ namespace verbly { | |||
320 | throw std::domain_error("part::isPrepositionLiteral is only valid for preposition parts"); | 320 | throw std::domain_error("part::isPrepositionLiteral is only valid for preposition parts"); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | std::string part::getLiteralValue() const | 324 | std::string part::getLiteralValue() const |
325 | { | 325 | { |
326 | if (type_ == type::literal) | 326 | if (type_ == type::literal) |
@@ -330,6 +330,6 @@ namespace verbly { | |||
330 | throw std::domain_error("part::getLiteralValue is only valid for literal parts"); | 330 | throw std::domain_error("part::getLiteralValue is only valid for literal parts"); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | }; | 334 | }; |
335 | }; | 335 | }; |