diff options
Diffstat (limited to 'lib/form.h')
-rw-r--r-- | lib/form.h | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/form.h b/lib/form.h index 479672f..b365943 100644 --- a/lib/form.h +++ b/lib/form.h | |||
@@ -5,12 +5,11 @@ | |||
5 | #include <vector> | 5 | #include <vector> |
6 | #include <string> | 6 | #include <string> |
7 | #include <stdexcept> | 7 | #include <stdexcept> |
8 | #include <hkutil/database.h> | ||
8 | #include "field.h" | 9 | #include "field.h" |
9 | #include "pronunciation.h" | 10 | #include "pronunciation.h" |
10 | #include "filter.h" | 11 | #include "filter.h" |
11 | 12 | ||
12 | struct sqlite3_stmt; | ||
13 | |||
14 | namespace verbly { | 13 | namespace 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 | form(const database& db, sqlite3_stmt* row); | 26 | form(const database& db, hatkirby::row row); |
28 | 27 | ||
29 | // Accessors | 28 | // Accessors |
30 | 29 | ||
@@ -43,7 +42,7 @@ namespace verbly { | |||
43 | return id_; | 42 | return id_; |
44 | } | 43 | } |
45 | 44 | ||
46 | std::string getText() const | 45 | const std::string& getText() const |
47 | { | 46 | { |
48 | if (!valid_) | 47 | if (!valid_) |
49 | { | 48 | { |
@@ -83,7 +82,15 @@ namespace verbly { | |||
83 | return length_; | 82 | return length_; |
84 | } | 83 | } |
85 | 84 | ||
86 | const std::vector<pronunciation>& getPronunciations() const; | 85 | const std::vector<pronunciation>& getPronunciations() const |
86 | { | ||
87 | if (!valid_) | ||
88 | { | ||
89 | throw std::domain_error("Bad access to uninitialized form"); | ||
90 | } | ||
91 | |||
92 | return pronunciations_; | ||
93 | } | ||
87 | 94 | ||
88 | // Convenience | 95 | // Convenience |
89 | 96 | ||
@@ -130,19 +137,14 @@ namespace verbly { | |||
130 | static const field pronunciations; | 137 | static const field pronunciations; |
131 | 138 | ||
132 | private: | 139 | private: |
133 | bool valid_ = false; | ||
134 | 140 | ||
141 | bool valid_ = false; | ||
135 | int id_; | 142 | int id_; |
136 | std::string text_; | 143 | std::string text_; |
137 | int complexity_; | 144 | int complexity_; |
138 | bool proper_; | 145 | bool proper_; |
139 | int length_; | 146 | int length_; |
140 | 147 | std::vector<pronunciation> pronunciations_; | |
141 | const database* db_; | ||
142 | |||
143 | mutable bool initializedPronunciations_ = false; | ||
144 | mutable std::vector<pronunciation> pronunciations_; | ||
145 | |||
146 | }; | 148 | }; |
147 | 149 | ||
148 | }; | 150 | }; |