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

Method load

src/backend/datasources/MQTTTopic.cpp:199–306  ·  view source on GitHub ↗

! Loads from XML. */

Source from the content-addressed store, hash-verified

197 Loads from XML.
198*/
199bool MQTTTopic::load(XmlStreamReader* reader, bool preview) {
200 removeColumns(0, columnCount());
201 if (!readBasicAttributes(reader))
202 return false;
203
204 bool isFilterPrepared = false;
205 QString separator;
206
207 QString attributeWarning = i18n("Attribute '%1' missing or empty, default value is used");
208 QXmlStreamAttributes attribs;
209 QString str;
210
211 while (!reader->atEnd()) {
212 reader->readNext();
213 if (reader->isEndElement() && reader->name() == QLatin1String("MQTTTopic"))
214 break;
215
216 if (!reader->isStartElement())
217 continue;
218
219 if (reader->name() == QLatin1String("comment")) {
220 if (!readCommentElement(reader))
221 return false;
222 } else if (reader->name() == QLatin1String("general")) {
223 attribs = reader->attributes();
224
225 str = attribs.value(QStringLiteral("topicName")).toString();
226 if (str.isEmpty())
227 reader->raiseWarning(attributeWarning.arg(QStringLiteral("'topicName'")));
228 else {
229 m_topicName = str;
230 setName(str);
231 }
232
233 str = attribs.value(QStringLiteral("filterPrepared")).toString();
234 if (str.isEmpty())
235 reader->raiseWarning(attributeWarning.arg(QStringLiteral("'filterPrepared'")));
236 else {
237 isFilterPrepared = str.toInt();
238 }
239
240 str = attribs.value(QStringLiteral("filterSeparator")).toString();
241 if (str.isEmpty())
242 reader->raiseWarning(attributeWarning.arg(QStringLiteral("'filterSeparator'")));
243 else {
244 separator = str;
245 }
246
247 int pufferSize = 0;
248 str = attribs.value(QStringLiteral("messagePufferSize")).toString();
249 if (str.isEmpty())
250 reader->raiseWarning(attributeWarning.arg(QStringLiteral("'messagePufferSize'")));
251 else
252 pufferSize = str.toInt();
253 for (int i = 0; i < pufferSize; ++i) {
254 str = attribs.value(QStringLiteral("message") + QString::number(i)).toString();
255 if (str.isEmpty())
256 reader->raiseWarning(attributeWarning.arg(QStringLiteral("'message") + QString::number(i) + QLatin1Char('\'')));

Callers

nothing calls this directly

Calls 15

columnCountFunction · 0.85
columnFunction · 0.85
rowCountFunction · 0.85
atEndMethod · 0.80
raiseWarningMethod · 0.80
argMethod · 0.80
skipToEndElementMethod · 0.80
defaultPropertiesMethod · 0.80
QStringClass · 0.70
nameMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected