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/pronunciation.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'lib/pronunciation.cpp') diff --git a/lib/pronunciation.cpp b/lib/pronunciation.cpp index 1f36899..3aef815 100644 --- a/lib/pronunciation.cpp +++ b/lib/pronunciation.cpp @@ -1,5 +1,4 @@ #include "pronunciation.h" -#include #include #include "form.h" #include "word.h" @@ -22,22 +21,27 @@ namespace verbly { const field pronunciation::rhymes_field::rhymeJoin = field::joinField(object::pronunciation, "rhyme", object::pronunciation); const pronunciation::rhymes_field pronunciation::rhymes = {}; - pronunciation::pronunciation(const database& db, sqlite3_stmt* row) : db_(&db), valid_(true) + pronunciation::pronunciation( + const database& db, + hatkirby::row row) : + valid_(true) { - id_ = sqlite3_column_int(row, 0); + id_ = mpark::get(row[0]); - std::string phonemesStr(reinterpret_cast(sqlite3_column_text(row, 1))); - phonemes_ = hatkirby::split>(phonemesStr, " "); + phonemes_ = + hatkirby::split>( + mpark::get(row[1]), + " "); - syllables_ = sqlite3_column_int(row, 2); - stress_ = std::string(reinterpret_cast(sqlite3_column_text(row, 3))); + syllables_ = mpark::get(row[2]); + stress_ = mpark::get(row[3]); - if (sqlite3_column_type(row, 5) != SQLITE_NULL) + if (!mpark::holds_alternative(row[5])) { hasRhyme_ = true; - prerhyme_ = std::string(reinterpret_cast(sqlite3_column_text(row, 4))); - rhyme_ = std::string(reinterpret_cast(sqlite3_column_text(row, 5))); + prerhyme_ = mpark::get(row[4]); + rhyme_ = mpark::get(row[5]); } } -- cgit 1.4.1