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/word.h | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'lib/word.h') 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 @@ #include #include +#include #include "field.h" #include "filter.h" #include "notion.h" #include "frame.h" #include "form.h" -struct sqlite3_stmt; - namespace verbly { class database; @@ -24,7 +23,7 @@ namespace verbly { // Construct from database - word(const database& db, sqlite3_stmt* row); + word(const database& db, hatkirby::row row); // Accessors @@ -93,11 +92,35 @@ namespace verbly { return adjectivePosition_; } - const notion& getNotion() const; + const notion& getNotion() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized word"); + } - bool hasFrames() const; + return notion_; + } - const std::vector& getFrames() const; + bool hasFrames() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized word"); + } + + return !frames_.empty(); + } + + const std::vector& getFrames() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized word"); + } + + return frames_; + } const form& getBaseForm() const; @@ -181,26 +204,17 @@ namespace verbly { private: void initializeForm(inflection category) const; - void initializeFrames() const; bool valid_ = false; - int id_; bool hasTagCount_ = false; int tagCount_; positioning adjectivePosition_ = positioning::undefined; - int notionId_; - int lemmaId_; - bool hasGroup_ = false; - int groupId_; - - const database* db_; - - mutable notion notion_; - mutable bool initializedFrames_ = false; - mutable std::vector frames_; + notion notion_; + std::vector frames_; mutable std::map> forms_; + const database& db_; }; }; -- cgit 1.4.1