From 38c17f093615a16a4b4ec6dc2b5d3edb5c1d3895 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 27 Sep 2018 21:40:52 -0400 Subject: More hkutil refactoring All database access goes through hatkirby::database now. verbly::token, verbly::statement::condition, and verbly::part have been converted to use mpark::variant now. verbly::binding has been deleted, and replaced with a mpark::variant typedef in statement.h. This means that the only remaining tagged union class is verbly::generator::part. refs #5 --- lib/form.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'lib/form.h') 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 @@ #include #include #include +#include #include "field.h" #include "pronunciation.h" #include "filter.h" -struct sqlite3_stmt; - namespace verbly { class database; @@ -24,7 +23,7 @@ namespace verbly { // Construct from database - form(const database& db, sqlite3_stmt* row); + form(const database& db, hatkirby::row row); // Accessors @@ -43,7 +42,7 @@ namespace verbly { return id_; } - std::string getText() const + const std::string& getText() const { if (!valid_) { @@ -83,7 +82,15 @@ namespace verbly { return length_; } - const std::vector& getPronunciations() const; + const std::vector& getPronunciations() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + return pronunciations_; + } // Convenience @@ -130,19 +137,14 @@ namespace verbly { static const field pronunciations; private: - bool valid_ = false; + bool valid_ = false; int id_; std::string text_; int complexity_; bool proper_; int length_; - - const database* db_; - - mutable bool initializedPronunciations_ = false; - mutable std::vector pronunciations_; - + std::vector pronunciations_; }; }; -- cgit 1.4.1