summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/word.cpp9
-rw-r--r--lib/word.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/word.cpp b/lib/word.cpp index 60657ba..2fccb9f 100644 --- a/lib/word.cpp +++ b/lib/word.cpp
@@ -44,7 +44,7 @@ namespace verbly {
44 return field::joinThroughWhere(object::word, "lemma_id", object::form, "lemmas_forms", "form_id", "category", static_cast<int>(category)); 44 return field::joinThroughWhere(object::word, "lemma_id", object::form, "lemmas_forms", "form_id", "category", static_cast<int>(category));
45 } 45 }
46 46
47 word::word(const database& db, hatkirby::row row) : db_(db), valid_(true) 47 word::word(const database& db, hatkirby::row row) : db_(&db), valid_(true)
48 { 48 {
49 id_ = mpark::get<int>(row[0]); 49 id_ = mpark::get<int>(row[0]);
50 50
@@ -104,7 +104,12 @@ namespace verbly {
104 104
105 void word::initializeForm(inflection infl) const 105 void word::initializeForm(inflection infl) const
106 { 106 {
107 forms_[infl] = db_.forms(form::words(infl) %= *this, verbly::form::id, -1).all(); 107 if (!db_)
108 {
109 throw std::domain_error("Database not present");
110 }
111
112 forms_[infl] = db_->forms(form::words(infl) %= *this, verbly::form::id, -1).all();
108 } 113 }
109 114
110 filter word::synonyms_field::operator%=(filter joinCondition) const 115 filter word::synonyms_field::operator%=(filter joinCondition) const
diff --git a/lib/word.h b/lib/word.h index f52cc4d..6c3a5d7 100644 --- a/lib/word.h +++ b/lib/word.h
@@ -214,7 +214,7 @@ namespace verbly {
214 std::vector<frame> frames_; 214 std::vector<frame> frames_;
215 mutable std::map<inflection, std::vector<form>> forms_; 215 mutable std::map<inflection, std::vector<form>> forms_;
216 216
217 const database& db_; 217 const database* db_ = nullptr;
218 }; 218 };
219 219
220}; 220};