#include "trygvis/sensor.h" #include "json.hpp" #include #include #include #include namespace trygvis { namespace sensor { using namespace std; string to_string(const sample_format_type &arg) { if (arg == sample_format_type::AUTO) return "auto"; else if (arg == sample_format_type::CSV) return "csv"; else if (arg == sample_format_type::JSON) return "json"; else if (arg == sample_format_type::KEY_VALUE) return "key-value"; else if (arg == sample_format_type::SQL) return "sql"; else if (arg == sample_format_type::RRD) return "rrd"; else return "unknown"; } 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) { string s; is >> s; if (s == "auto") { type = sample_format_type::AUTO; } else if (s == "csv") { type = sample_format_type::CSV; } else if (s == "key-value") { type = sample_format_type::KEY_VALUE; } else if (s == "json") { type = sample_format_type::JSON; } else if (s == "sql") { type = sample_format_type::SQL; } else if (s == "rrd") { type = sample_format_type::RRD; } return is; } template<> const o SampleRecord::lexical_at(const SampleKey *key) const { auto value = at(key); if (!value) { return o(); } return o(boost::lexical_cast(value.get())); } // //template //const o SampleRecord::lexical_at(const SampleKey *key) const { // auto value = at(key); // // if (!value) { // return o(); // } // // return o(boost::lexical_cast(value.get())); //} } }