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

Method read

app/src/DataModel/Frame.cpp:120–141  ·  view source on GitHub ↗

* @brief Deserializes a RegisterDef from a QJsonObject. */

Source from the content-addressed store, hash-verified

118 * @brief Deserializes a RegisterDef from a QJsonObject.
119 */
120bool DataModel::read(RegisterDef& r, const QJsonObject& obj)
121{
122 if (obj.isEmpty())
123 return false;
124
125 r.name = ss_jsr(obj, Keys::Name, "").toString().simplified();
126 if (r.name.isEmpty())
127 return false;
128
129 const auto typeStr = ss_jsr(obj, Keys::RegisterTypeName, "constant").toString();
130 r.type = (typeStr == QLatin1String("computed")) ? RegisterType::Computed : RegisterType::Constant;
131
132 const auto val = obj.value(Keys::Value);
133 if (val.isDouble())
134 r.defaultValue = SerialStudio::toDouble(val);
135 else if (val.isString())
136 r.defaultValue = val.toString();
137 else
138 r.defaultValue = QVariant(0.0);
139
140 return true;
141}
142
143//--------------------------------------------------------------------------------------------------
144// Table folder paths (single source of truth for the store key + script accessor)

Callers

nothing calls this directly

Calls 5

ss_jsrFunction · 0.85
normalizeDatasetRangesFunction · 0.85
isEmptyMethod · 0.80
valueMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected