MCPcopy Create free account
hub / github.com/KDE/labplot / parseValues

Method parseValues

src/backend/notebook/VariableParser.cpp:228–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228void VariableParser::parseValues(const QStringList& values, VariableParser::Datatype dataType) {
229 PERFTRACE(QStringLiteral("parsing variable values string list"));
230 if (values.isEmpty())
231 return;
232
233 switch (dataType) {
234 case Datatype::uint8:
235 case Datatype::int8:
236 case Datatype::uint16:
237 case Datatype::int16:
238 case Datatype::int32:
239 m_values = new QVector<int>(values.size());
240 m_dataType = AbstractColumn::ColumnMode::Integer;
241 break;
242 case Datatype::uint32:
243 case Datatype::int64:
244 m_values = new QVector<qint64>(values.size());
245 m_dataType = AbstractColumn::ColumnMode::BigInt;
246 break;
247 case Datatype::uint64: // larger than qint64!
248 case Datatype::float32:
249 case Datatype::float64:
250 m_values = new QVector<double>(values.size());
251 m_dataType = AbstractColumn::ColumnMode::Double;
252 break;
253 case Datatype::datetime64_D:
254 case Datatype::datetime64_h:
255 case Datatype::datetime64_m:
256 case Datatype::datetime64_s:
257 case Datatype::datetime64_ms:
258 case Datatype::datetime64_ns:
259 m_values = new QVector<QDateTime>(values.size());
260 m_dataType = AbstractColumn::ColumnMode::DateTime;
261 break;
262 case Datatype::text:
263 m_values = new QVector<QString>(values.size());
264 m_dataType = AbstractColumn::ColumnMode::Text;
265 }
266
267 int i = 0;
268 bool isNumber = false;
269 switch (dataType) {
270 case Datatype::uint8:
271 case Datatype::int8:
272 case Datatype::uint16:
273 case Datatype::int16:
274 case Datatype::int32: {
275 for (const auto& v : values) {
276 int value = v.trimmed().toUInt(&isNumber);
277
278 // accept the variable only if there is at least one numerical value in the array.
279 if (isNumber) {
280 m_parsed = true;
281 } else
282 value = 0;
283
284 integers()[i] = value;
285 i++;

Callers

nothing calls this directly

Calls 4

dateTimeFunction · 0.85
isEmptyMethod · 0.45
sizeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected