From f2b544edddebf0701bad20a889197e650ffa1e56 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 7 Mar 2015 09:25:50 +0100 Subject: o First start of a proper CSV parser. --- apps/sample-convert.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'apps/sample-convert.cpp') diff --git a/apps/sample-convert.cpp b/apps/sample-convert.cpp index 2e448ca..9a0627d 100644 --- a/apps/sample-convert.cpp +++ b/apps/sample-convert.cpp @@ -1,6 +1,7 @@ #include "SoilMoistureIo.h" #include "json.hpp" #include "apps.h" +#include enum class Format { PLAIN, @@ -64,7 +65,7 @@ public: auto desc = execution.desc; auto vm = execution.vm; - shared_ptr sampleStream; + shared_ptr output; auto field_names = vector({ "hostname", @@ -75,13 +76,24 @@ public: "value" }); - sampleStream = make_shared(cout, field_names); + field_names = vector({ + "analog", + "dry", + "water", + "last_watering_started", + "last_watering_stopped", + "now" + }); + + output = make_shared(cout, field_names); - map values; - values["hostname"] = "my-hostname"; - values["extra"] = "wat"; + auto input = make_shared(output); - sampleStream->write(values); + char data[100]; + while (!cin.eof()) { + cin.get(data[0]); + input->process(boost::asio::buffer(data, 1)); + } return EXIT_SUCCESS; } -- cgit v1.2.3