diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/form.cpp | 4 | ||||
-rw-r--r-- | lib/form.h | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/form.cpp b/lib/form.cpp index 2f9509f..feaf765 100644 --- a/lib/form.cpp +++ b/lib/form.cpp | |||
@@ -10,12 +10,13 @@ namespace verbly { | |||
10 | 10 | ||
11 | const object form::objectType = object::form; | 11 | const object form::objectType = object::form; |
12 | 12 | ||
13 | const std::list<std::string> form::select = {"form_id", "form", "complexity", "proper"}; | 13 | const std::list<std::string> form::select = {"form_id", "form", "complexity", "proper", "length"}; |
14 | 14 | ||
15 | const field form::id = field::integerField(object::form, "form_id"); | 15 | const field form::id = field::integerField(object::form, "form_id"); |
16 | const field form::text = field::stringField(object::form, "form"); | 16 | const field form::text = field::stringField(object::form, "form"); |
17 | const field form::complexity = field::integerField(object::form, "complexity"); | 17 | const field form::complexity = field::integerField(object::form, "complexity"); |
18 | const field form::proper = field::booleanField(object::form, "proper"); | 18 | const field form::proper = field::booleanField(object::form, "proper"); |
19 | const field form::length = field::integerField(object::form, "length"); | ||
19 | 20 | ||
20 | const field form::pronunciations = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id"); | 21 | const field form::pronunciations = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id"); |
21 | 22 | ||
@@ -30,6 +31,7 @@ namespace verbly { | |||
30 | text_ = std::string(reinterpret_cast<const char*>(sqlite3_column_text(row, 1))); | 31 | text_ = std::string(reinterpret_cast<const char*>(sqlite3_column_text(row, 1))); |
31 | complexity_ = sqlite3_column_int(row, 2); | 32 | complexity_ = sqlite3_column_int(row, 2); |
32 | proper_ = (sqlite3_column_int(row, 3) == 1); | 33 | proper_ = (sqlite3_column_int(row, 3) == 1); |
34 | length_ = sqlite3_column_int(row, 4); | ||
33 | } | 35 | } |
34 | 36 | ||
35 | const std::vector<pronunciation>& form::getPronunciations() const | 37 | const std::vector<pronunciation>& form::getPronunciations() const |
diff --git a/lib/form.h b/lib/form.h index e3e1185..479672f 100644 --- a/lib/form.h +++ b/lib/form.h | |||
@@ -73,6 +73,16 @@ namespace verbly { | |||
73 | return proper_; | 73 | return proper_; |
74 | } | 74 | } |
75 | 75 | ||
76 | int getLength() const | ||
77 | { | ||
78 | if (!valid_) | ||
79 | { | ||
80 | throw std::domain_error("Bad access to uninitialized form"); | ||
81 | } | ||
82 | |||
83 | return length_; | ||
84 | } | ||
85 | |||
76 | const std::vector<pronunciation>& getPronunciations() const; | 86 | const std::vector<pronunciation>& getPronunciations() const; |
77 | 87 | ||
78 | // Convenience | 88 | // Convenience |
@@ -91,6 +101,7 @@ namespace verbly { | |||
91 | static const field text; | 101 | static const field text; |
92 | static const field complexity; | 102 | static const field complexity; |
93 | static const field proper; | 103 | static const field proper; |
104 | static const field length; | ||
94 | 105 | ||
95 | operator filter() const | 106 | operator filter() const |
96 | { | 107 | { |
@@ -123,8 +134,9 @@ namespace verbly { | |||
123 | 134 | ||
124 | int id_; | 135 | int id_; |
125 | std::string text_; | 136 | std::string text_; |
126 | int complexity_ ; | 137 | int complexity_; |
127 | bool proper_; | 138 | bool proper_; |
139 | int length_; | ||
128 | 140 | ||
129 | const database* db_; | 141 | const database* db_; |
130 | 142 | ||