From af49d3435302118d036c512aef1def848fb88089 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 27 Mar 2018 17:13:37 -0400 Subject: Migrated to hkutil --- generator/generator.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'generator/generator.cpp') diff --git a/generator/generator.cpp b/generator/generator.cpp index 54f5d69..19eba70 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -4,9 +4,8 @@ #include #include #include -#include "progress.h" -#include "field.h" -#include "../util.h" +#include +#include #include "mood.h" namespace cadence { @@ -16,7 +15,7 @@ namespace cadence { std::string inputpath, std::string outputpath) : inputpath_(inputpath), - db_(outputpath) + db_(outputpath, hatkirby::dbmode::create) { // Add directory separator to input path if ((inputpath_.back() != '/') && (inputpath_.back() != '\\')) @@ -61,13 +60,13 @@ namespace cadence { } std::string schema = schemaBuilder.str(); - auto queries = split>(schema, ";"); - progress ppgs("Writing database schema...", queries.size()); + auto queries = hatkirby::split>(schema, ";"); + hatkirby::progress ppgs("Writing database schema...", queries.size()); for (std::string query : queries) { if (!queries.empty()) { - db_.runQuery(query); + db_.execute(query); } ppgs.update(); @@ -134,7 +133,9 @@ namespace cadence { void generator::parseData() { - progress ppgs("Parsing AcousticBrainz data files...", datafiles_.size()); + hatkirby::progress ppgs( + "Parsing AcousticBrainz data files...", + datafiles_.size()); for (std::string datafile : datafiles_) { @@ -163,12 +164,12 @@ namespace cadence { return left.getProbability() > right.getProbability(); }); - std::list fields; - fields.emplace_back("title", jsonData["metadata"]["tags"]["title"][0].get()); - fields.emplace_back("artist", jsonData["metadata"]["tags"]["artist"][0].get()); - fields.emplace_back("category", moods.front().getCategory()); + std::list columns; + columns.emplace_back("title", jsonData["metadata"]["tags"]["title"][0].get()); + columns.emplace_back("artist", jsonData["metadata"]["tags"]["artist"][0].get()); + columns.emplace_back("category", moods.front().getCategory()); - db_.insertIntoTable("songs", std::move(fields)); + db_.insertIntoTable("songs", std::move(columns)); } catch (const std::domain_error& ex) { // Weird data. Ignore silently. -- cgit 1.4.1