diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-09-27 21:40:52 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-09-27 21:40:52 -0400 |
commit | 38c17f093615a16a4b4ec6dc2b5d3edb5c1d3895 (patch) | |
tree | 8da5a3d0eacf5e2fd04c33f57d592e4c1ca303ad /lib/pronunciation.cpp | |
parent | 3a8bfa95a5df04d97f05545d5bb8df5f3c3f96a3 (diff) | |
download | verbly-38c17f093615a16a4b4ec6dc2b5d3edb5c1d3895.tar.gz verbly-38c17f093615a16a4b4ec6dc2b5d3edb5c1d3895.tar.bz2 verbly-38c17f093615a16a4b4ec6dc2b5d3edb5c1d3895.zip |
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
Diffstat (limited to 'lib/pronunciation.cpp')
-rw-r--r-- | lib/pronunciation.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
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 @@ | |||
1 | #include "pronunciation.h" | 1 | #include "pronunciation.h" |
2 | #include <sqlite3.h> | ||
3 | #include <hkutil/string.h> | 2 | #include <hkutil/string.h> |
4 | #include "form.h" | 3 | #include "form.h" |
5 | #include "word.h" | 4 | #include "word.h" |
@@ -22,22 +21,27 @@ namespace verbly { | |||
22 | const field pronunciation::rhymes_field::rhymeJoin = field::joinField(object::pronunciation, "rhyme", object::pronunciation); | 21 | const field pronunciation::rhymes_field::rhymeJoin = field::joinField(object::pronunciation, "rhyme", object::pronunciation); |
23 | const pronunciation::rhymes_field pronunciation::rhymes = {}; | 22 | const pronunciation::rhymes_field pronunciation::rhymes = {}; |
24 | 23 | ||
25 | pronunciation::pronunciation(const database& db, sqlite3_stmt* row) : db_(&db), valid_(true) | 24 | pronunciation::pronunciation( |
25 | const database& db, | ||
26 | hatkirby::row row) : | ||
27 | valid_(true) | ||
26 | { | 28 | { |
27 | id_ = sqlite3_column_int(row, 0); | 29 | id_ = mpark::get<int>(row[0]); |
28 | 30 | ||
29 | std::string phonemesStr(reinterpret_cast<const char*>(sqlite3_column_text(row, 1))); | 31 | phonemes_ = |
30 | phonemes_ = hatkirby::split<std::vector<std::string>>(phonemesStr, " "); | 32 | hatkirby::split<std::vector<std::string>>( |
33 | mpark::get<std::string>(row[1]), | ||
34 | " "); | ||
31 | 35 | ||
32 | syllables_ = sqlite3_column_int(row, 2); | 36 | syllables_ = mpark::get<int>(row[2]); |
33 | stress_ = std::string(reinterpret_cast<const char*>(sqlite3_column_text(row, 3))); | 37 | stress_ = mpark::get<std::string>(row[3]); |
34 | 38 | ||
35 | if (sqlite3_column_type(row, 5) != SQLITE_NULL) | 39 | if (!mpark::holds_alternative<std::nullptr_t>(row[5])) |
36 | { | 40 | { |
37 | hasRhyme_ = true; | 41 | hasRhyme_ = true; |
38 | 42 | ||
39 | prerhyme_ = std::string(reinterpret_cast<const char*>(sqlite3_column_text(row, 4))); | 43 | prerhyme_ = mpark::get<std::string>(row[4]); |
40 | rhyme_ = std::string(reinterpret_cast<const char*>(sqlite3_column_text(row, 5))); | 44 | rhyme_ = mpark::get<std::string>(row[5]); |
41 | } | 45 | } |
42 | } | 46 | } |
43 | 47 | ||