From b99017a7938cb36e234025d9ae592bac06ec3ec6 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 30 Aug 2018 14:24:52 +0200 Subject: sm-db-insert: fixing headers and warnings. --- apps/sm-db-insert.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'apps') diff --git a/apps/sm-db-insert.cpp b/apps/sm-db-insert.cpp index 57a633c..46a64e2 100644 --- a/apps/sm-db-insert.cpp +++ b/apps/sm-db-insert.cpp @@ -1,7 +1,7 @@ #include +#include #include #include -#include #include #include "apps.h" #include @@ -16,7 +16,7 @@ class sm_db_insert : public app { public: sm_db_insert() : app("sm-db-insert") {} - ~sm_db_insert() = default; + ~sm_db_insert() override = default; void add_options(po::options_description_easy_init &options) override { options("file", po::value()->required(), "The file to read"); @@ -41,7 +41,7 @@ public: auto select_device = "select id from soil_moisture_device where mac=$1"; auto rs = work.parameterized(select_device)(mac).exec(); - if (!rs.size()) { + if (rs.empty()) { cout << "New device: " << mac << endl; auto insert_device = "insert into soil_moisture_device(mac) values($1) returning id"; @@ -55,7 +55,7 @@ public: auto select_sensor = "select id from soil_moisture_sensor where device=$1 and sensor=$2"; rs = work.parameterized(select_sensor)(deviceId)(sensor).exec(); - if (!rs.size()) { + if (rs.empty()) { cout << "New sensor: " << sensor << endl; auto insert_sensor = "insert into soil_moisture_sensor(device, sensor) values($1, $2) returning id"; @@ -63,8 +63,8 @@ public: } auto sensorId = rs.begin()["id"].as(); - unsigned long timestamp = get(j, "timestamp"); - unsigned int value = get(j, "value"); + auto timestamp = get(j, "timestamp"); + auto value = get(j, "value"); auto insert_sample = "insert into soil_moisture_sample(sensor, timestamp, value) values($1, $2, $3)"; work.parameterized(insert_sample)(sensorId)(timestamp)(value).exec(); -- cgit v1.2.3