MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / classifyScalar

Function classifyScalar

app/src/DataModel/Importers/ProtoImporter.cpp:294–315  ·  view source on GitHub ↗

* @brief Maps a scalar type keyword to its ProtoScalar enum, or MessageRef if unrecognized. */

Source from the content-addressed store, hash-verified

292 * @brief Maps a scalar type keyword to its ProtoScalar enum, or MessageRef if unrecognized.
293 */
294DataModel::ProtoScalar classifyScalar(const QString& type)
295{
296 using S = DataModel::ProtoScalar;
297 static const QHash<QString, S> table = {
298 { QStringLiteral("double"), S::Double},
299 { QStringLiteral("float"), S::Float},
300 { QStringLiteral("int32"), S::Int32},
301 { QStringLiteral("int64"), S::Int64},
302 { QStringLiteral("uint32"), S::UInt32},
303 { QStringLiteral("uint64"), S::UInt64},
304 { QStringLiteral("sint32"), S::SInt32},
305 { QStringLiteral("sint64"), S::SInt64},
306 { QStringLiteral("fixed32"), S::Fixed32},
307 { QStringLiteral("fixed64"), S::Fixed64},
308 {QStringLiteral("sfixed32"), S::SFixed32},
309 {QStringLiteral("sfixed64"), S::SFixed64},
310 { QStringLiteral("bool"), S::Bool},
311 { QStringLiteral("string"), S::String},
312 { QStringLiteral("bytes"), S::Bytes},
313 };
314 return table.value(type, S::MessageRef);
315}
316
317/**
318 * @brief Recursive-descent parser for a small proto3 subset (messages, scalars, nested types).

Callers 1

parseFieldMethod · 0.85

Calls 1

valueMethod · 0.45

Tested by

no test coverage detected