From 1fd518d1c2b1d4e88ad88218b606a284b7128107 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 16 Oct 2017 11:19:23 -0400 Subject: Added length field to form table This commit contains a database update. --- lib/form.cpp | 4 +++- lib/form.h | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'lib') 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 { const object form::objectType = object::form; - const std::list form::select = {"form_id", "form", "complexity", "proper"}; + const std::list form::select = {"form_id", "form", "complexity", "proper", "length"}; const field form::id = field::integerField(object::form, "form_id"); const field form::text = field::stringField(object::form, "form"); const field form::complexity = field::integerField(object::form, "complexity"); const field form::proper = field::booleanField(object::form, "proper"); + const field form::length = field::integerField(object::form, "length"); const field form::pronunciations = field::joinThrough(object::form, "form_id", object::pronunciation, "forms_pronunciations", "pronunciation_id"); @@ -30,6 +31,7 @@ namespace verbly { text_ = std::string(reinterpret_cast(sqlite3_column_text(row, 1))); complexity_ = sqlite3_column_int(row, 2); proper_ = (sqlite3_column_int(row, 3) == 1); + length_ = sqlite3_column_int(row, 4); } const std::vector& 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 { return proper_; } + int getLength() const + { + if (!valid_) + { + throw std::domain_error("Bad access to uninitialized form"); + } + + return length_; + } + const std::vector& getPronunciations() const; // Convenience @@ -91,6 +101,7 @@ namespace verbly { static const field text; static const field complexity; static const field proper; + static const field length; operator filter() const { @@ -123,8 +134,9 @@ namespace verbly { int id_; std::string text_; - int complexity_ ; + int complexity_; bool proper_; + int length_; const database* db_; -- cgit 1.4.1