diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-03-07 09:25:50 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-03-07 09:25:50 +0100 |
commit | f2b544edddebf0701bad20a889197e650ffa1e56 (patch) | |
tree | 54e5d863b27a397a560abbedae32c2a598d3c44e /apps/sample-convert.cpp | |
parent | 1cd0616a0ca9ecffcd1b523f1fc069a22fa4609d (diff) | |
download | ble-toys-f2b544edddebf0701bad20a889197e650ffa1e56.tar.gz ble-toys-f2b544edddebf0701bad20a889197e650ffa1e56.tar.bz2 ble-toys-f2b544edddebf0701bad20a889197e650ffa1e56.tar.xz ble-toys-f2b544edddebf0701bad20a889197e650ffa1e56.zip |
o First start of a proper CSV parser.
Diffstat (limited to 'apps/sample-convert.cpp')
-rw-r--r-- | apps/sample-convert.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
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 <istream> enum class Format { PLAIN, @@ -64,7 +65,7 @@ public: auto desc = execution.desc; auto vm = execution.vm; - shared_ptr<SampleOutputStream> sampleStream; + shared_ptr<SampleOutputStream> output; auto field_names = vector<string>({ "hostname", @@ -75,13 +76,24 @@ public: "value" }); - sampleStream = make_shared<JsonSampleOutputStream>(cout, field_names); + field_names = vector<string>({ + "analog", + "dry", + "water", + "last_watering_started", + "last_watering_stopped", + "now" + }); + + output = make_shared<JsonSampleOutputStream>(cout, field_names); - map<string, string> values; - values["hostname"] = "my-hostname"; - values["extra"] = "wat"; + auto input = make_shared<CsvParser>(output); - sampleStream->write(values); + char data[100]; + while (!cin.eof()) { + cin.get(data[0]); + input->process(boost::asio::buffer(data, 1)); + } return EXIT_SUCCESS; } |