From 0ba0fff06fb679f5cabedd52257fc0c38a600279 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 24 Jan 2017 21:46:18 -0500 Subject: Added word::getGroup --- lib/word.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'lib/word.cpp') diff --git a/lib/word.cpp b/lib/word.cpp index 3edf2d2..d13d0bc 100644 --- a/lib/word.cpp +++ b/lib/word.cpp @@ -93,14 +93,34 @@ namespace verbly { return lemma_; } + const group& word::getGroup() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized word"); + } + + if (!hasGroup_) + { + throw std::domain_error("Word does not have a group"); + } + + if (!group_) + { + group_ = db_->groups(group::id == groupId_).first(); + } + + return group_; + } + std::string word::getBaseForm() const { return getLemma().getBaseForm().getText(); } - std::list word::getInflections(inflection category) const + std::vector word::getInflections(inflection category) const { - std::list result; + std::vector result; for (const form& infl : getLemma().getInflections(category)) { result.push_back(infl.getText()); -- cgit 1.4.1