File tree 4 files changed +12
-0
lines changed
4 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ class Point
46
46
// / Fields getter
47
47
std::string getFields () const ;
48
48
49
+ // / Tags getter
50
+ std::string getTags () const ;
51
+
49
52
protected:
50
53
// / A value
51
54
std::variant<long long int , std::string, double > mValue ;
Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ std::vector<Point> InfluxDB::query(const std::string& query)
108
108
point.setTimestamp (std::chrono::system_clock::from_time_t (std::mktime (&tm )));
109
109
continue ;
110
110
}
111
+ // cast all values to double, if strings add to tags
111
112
try { point.addField (column, boost::lexical_cast<double >(value)); }
112
113
catch (...) { point.addTag (column, value); }
113
114
}
Original file line number Diff line number Diff line change @@ -81,4 +81,9 @@ std::string Point::getFields() const
81
81
return mFields ;
82
82
}
83
83
84
+ std::string Point::getTags () const
85
+ {
86
+ return mTags .substr (1 , mTags .size ());
87
+ }
88
+
84
89
} // namespace influxdb
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ BOOST_AUTO_TEST_CASE(query1)
20
20
BOOST_CHECK_EQUAL (points[0 ].getFields (), " value=10" );
21
21
BOOST_CHECK_EQUAL (points[1 ].getFields (), " value=20" );
22
22
BOOST_CHECK_EQUAL (points[2 ].getFields (), " value=200" );
23
+ BOOST_CHECK_EQUAL (points[0 ].getTags (), " host=localhost" );
24
+ BOOST_CHECK_EQUAL (points[1 ].getTags (), " host=localhost" );
25
+ BOOST_CHECK_EQUAL (points[2 ].getTags (), " host=localhost" );
23
26
}
24
27
25
28
BOOST_AUTO_TEST_CASE (failedQuery1)
You can’t perform that action at this time.
0 commit comments