summary refs log tree commit diff stats
path: root/lib/word.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/word.h')
-rw-r--r--lib/word.h50
1 files changed, 32 insertions, 18 deletions
diff --git a/lib/word.h b/lib/word.h index 8c8de51..f52cc4d 100644 --- a/lib/word.h +++ b/lib/word.h
@@ -3,14 +3,13 @@
3 3
4#include <stdexcept> 4#include <stdexcept>
5#include <map> 5#include <map>
6#include <hkutil/database.h>
6#include "field.h" 7#include "field.h"
7#include "filter.h" 8#include "filter.h"
8#include "notion.h" 9#include "notion.h"
9#include "frame.h" 10#include "frame.h"
10#include "form.h" 11#include "form.h"
11 12
12struct sqlite3_stmt;
13
14namespace verbly { 13namespace verbly {
15 14
16 class database; 15 class database;
@@ -24,7 +23,7 @@ namespace verbly {
24 23
25 // Construct from database 24 // Construct from database
26 25
27 word(const database& db, sqlite3_stmt* row); 26 word(const database& db, hatkirby::row row);
28 27
29 // Accessors 28 // Accessors
30 29
@@ -93,11 +92,35 @@ namespace verbly {
93 return adjectivePosition_; 92 return adjectivePosition_;
94 } 93 }
95 94
96 const notion& getNotion() const; 95 const notion& getNotion() const
96 {
97 if (!valid_)
98 {
99 throw std::domain_error("Bad access to uninitialized word");
100 }
97 101
98 bool hasFrames() const; 102 return notion_;
103 }
99 104
100 const std::vector<frame>& getFrames() const; 105 bool hasFrames() const
106 {
107 if (!valid_)
108 {
109 throw std::domain_error("Bad access to uninitialized word");
110 }
111
112 return !frames_.empty();
113 }
114
115 const std::vector<frame>& getFrames() const
116 {
117 if (!valid_)
118 {
119 throw std::domain_error("Bad access to uninitialized word");
120 }
121
122 return frames_;
123 }
101 124
102 const form& getBaseForm() const; 125 const form& getBaseForm() const;
103 126
@@ -181,26 +204,17 @@ namespace verbly {
181 private: 204 private:
182 205
183 void initializeForm(inflection category) const; 206 void initializeForm(inflection category) const;
184 void initializeFrames() const;
185 207
186 bool valid_ = false; 208 bool valid_ = false;
187
188 int id_; 209 int id_;
189 bool hasTagCount_ = false; 210 bool hasTagCount_ = false;
190 int tagCount_; 211 int tagCount_;
191 positioning adjectivePosition_ = positioning::undefined; 212 positioning adjectivePosition_ = positioning::undefined;
192 int notionId_; 213 notion notion_;
193 int lemmaId_; 214 std::vector<frame> frames_;
194 bool hasGroup_ = false;
195 int groupId_;
196
197 const database* db_;
198
199 mutable notion notion_;
200 mutable bool initializedFrames_ = false;
201 mutable std::vector<frame> frames_;
202 mutable std::map<inflection, std::vector<form>> forms_; 215 mutable std::map<inflection, std::vector<form>> forms_;
203 216
217 const database& db_;
204 }; 218 };
205 219
206}; 220};