17 auto ToChar = [](
const auto*
ptr) {
return reinterpret_cast<const char*
>(
ptr); };
19 const auto str = QString::fromLocal8Bit(ToChar(
msg.data()),
msg.size());
27 if (parts.size() != 2 && parts.size() != 3)
33 if (tags.size() < 1 || fields.size() < 1)
37 uint64_t timestamp = 0;
38 if (parts.size() == 3)
40 timestamp = parts[2].toULongLong();
44 using namespace std::chrono;
45 auto now = steady_clock::now();
46 timestamp = duration_cast<nanoseconds>(now.time_since_epoch()).count();
48 const double ts_sec = double(timestamp) * 1e-9;
54 auto tag_str = tag.toLocal8Bit();
55 prefix.append(tag_str.data(), tag_str.size());
57 for (
auto field : fields)
59 const auto field_parts =
field.split(
'=');
60 const auto name = field_parts[0].toLocal8Bit();
61 auto value = field_parts[1].toLocal8Bit();
65 key.append(name.data(), name.size());
67 if (value.startsWith(
'"') && value.endsWith(
'"'))
69 auto&
data = _plot_data.getOrCreateStringSeries(key);
71 ts_sec,
StringRef(value.data() + 1, value.size() - 2)));
73 else if (value ==
"t" || value ==
"T" || value ==
"true" || value ==
"True" ||
76 auto&
data = _plot_data.getOrCreateNumeric(key);
77 data.pushBack({ ts_sec, 1.0 });
79 else if (value ==
"f" || value ==
"F" || value ==
"false" || value ==
"False" ||
82 auto&
data = _plot_data.getOrCreateNumeric(key);
83 data.pushBack({ ts_sec, 0.0 });
89 if (value.endsWith(
'i') || value.endsWith(
'u'))
93 double num = value.toDouble(&
ok);
96 auto&
data = _plot_data.getOrCreateNumeric(key);
97 data.pushBack({ ts_sec, num });
106 std::string topic_name_;
111 const std::string& schema,
114 return std::make_shared<MsgParserImpl>(topic_name,
type_name, schema,
data);