diff options
Diffstat (limited to 'apps/SoilMoistureIo.cpp')
-rw-r--r-- | apps/SoilMoistureIo.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/SoilMoistureIo.cpp b/apps/SoilMoistureIo.cpp index c7f3504..a2d50e4 100644 --- a/apps/SoilMoistureIo.cpp +++ b/apps/SoilMoistureIo.cpp @@ -11,7 +11,7 @@ namespace soil_moisture { using namespace std; using json = nlohmann::json; -void VectorSampleOutputStream::write(SampleRecord sample) { +void VectorSampleOutputStream::write(SampleRecord const &sample) { samples.emplace_back(sample); } @@ -19,7 +19,7 @@ CsvSampleOutputStream::CsvSampleOutputStream(shared_ptr<ostream> stream, KeyDict : stream(move(stream)), headerWritten(false), dict(dict) { } -void CsvSampleOutputStream::write(SampleRecord sample) { +void CsvSampleOutputStream::write(SampleRecord const &sample) { // Skip empty records if (sample.empty()) { return; @@ -28,8 +28,8 @@ void CsvSampleOutputStream::write(SampleRecord sample) { // Build the dict with the keys from the first sample. if (dict.empty()) { SampleKeyIndex index = 0; - auto ptr = sample.begin(); - while (ptr != sample.end()) { + auto ptr = sample.cbegin(); + while (ptr != sample.cend()) { auto o = *ptr; if (o) { @@ -88,7 +88,7 @@ JsonSampleOutputStream::JsonSampleOutputStream(shared_ptr<ostream> stream, KeyDi dict(dict), stream(move(stream)) { } -void JsonSampleOutputStream::write(SampleRecord sample) { +void JsonSampleOutputStream::write(SampleRecord const &sample) { // Skip empty records if (sample.empty()) { return; @@ -125,7 +125,7 @@ KeyValueSampleOutputStream::KeyValueSampleOutputStream(shared_ptr<ostream> strea dict(dict), stream(move(stream)) { } -void KeyValueSampleOutputStream::write(SampleRecord sample) { +void KeyValueSampleOutputStream::write(SampleRecord const &sample) { // Skip empty records if (sample.empty()) { return; @@ -146,7 +146,7 @@ void KeyValueSampleOutputStream::write(SampleRecord sample) { } else { s << ", "; } - s << key->name << "=" << value; + s << key->name << "=" << value.get(); } } } else { @@ -173,7 +173,7 @@ SqlSampleOutputStream::SqlSampleOutputStream(shared_ptr<ostream> stream, KeyDict dict(dict), stream(move(stream)), table_name(table_name) { } -void SqlSampleOutputStream::write(SampleRecord values) { +void SqlSampleOutputStream::write(SampleRecord const &values) { throw sample_exception("deimplemented"); // string fs, vs; @@ -305,11 +305,11 @@ string to_string(const sample_format_type &arg) { throw std::runtime_error("Unknown format value: " + to_string(arg)); } -std::ostream& operator<<(std::ostream& os, sample_format_type const& type){ +std::ostream& operator<<(std::ostream& os, sample_format_type const& type) { return os << to_string(type); } -std::istream& operator>>(std::istream& is, sample_format_type& type){ +std::istream& operator>>(std::istream& is, sample_format_type& type) { string s; is >> s; |