43 reader.enterContainer();
44 QString attribute_cvparam;
45 while(reader.hasNext())
48 qDebug() << attribute_cvparam;
49 if(attribute_cvparam ==
"cvRef")
53 else if(attribute_cvparam ==
"accession")
57 else if(attribute_cvparam ==
"name")
61 else if(attribute_cvparam ==
"value")
69 else if(reader.isUnsignedInteger())
71 valueInt = reader.toUnsignedInteger();
74 else if(reader.isInteger())
79 else if(reader.type() == QCborStreamReader::Type::String)
88 QObject::tr(
"cvParam value string failed for accession %1").arg(
accession));
94 QObject::tr(
"cvParam value type not known for accession %1").arg(
accession));
97 else if(attribute_cvparam ==
"unitAccession")
102 else if(attribute_cvparam ==
"unitCvRef")
106 else if(attribute_cvparam ==
"unitName")
116 reader.leaveContainer();
124 for(
auto &the_attribute : reader.attributes())
126 if(the_attribute.name() ==
"cvRef")
128 cvRef = the_attribute.value().toString();
130 else if(the_attribute.name() ==
"accession")
132 accession = the_attribute.value().toString();
134 else if(the_attribute.name() ==
"name")
136 name = the_attribute.value().toString();
138 else if(the_attribute.name() ==
"value")
140 valueStr = the_attribute.value().toString();
142 else if(the_attribute.name() ==
"unitCvRef")
144 unitCvRef = the_attribute.value().toString();
146 else if(the_attribute.name() ==
"unitAccession")
150 else if(the_attribute.name() ==
"unitName")
152 unitName = the_attribute.value().toString();
156 reader.readNextStartElement();
165 writer.append(
"cvRef");
166 writer.append(
cvRef);
168 writer.append(
"accession");
170 writer.append(
"name");
173 writer.append(
"value");
178 writer.append(
"unitCvRef");
180 writer.append(
"unitAccession");
182 writer.append(
"unitName");
192 QJsonObject cv_param;
193 cv_param.insert(
"cvRef",
cvRef);
195 cv_param.insert(
"name",
name);
200 if(
valueInt == std::numeric_limits<qint64>::max())
218 cv_param.insert(
"unitName",
unitName);
235 writer.writeStartElement(
"cvParam");
237 writer.writeAttribute(
"cvRef",
cvRef);
238 writer.writeAttribute(
"accession",
accession);
241 if(
cborType == QCborStreamReader::Type::Double)
245 else if(
cborType == QCborStreamReader::Type::UnsignedInteger)
249 else if(
cborType == QCborStreamReader::Type::NegativeInteger)
253 else if(
cborType == QCborStreamReader::Type::String)
256 writer.writeAttribute(
"value",
valueStr);
258 writer.writeAttribute(
"name",
name);
263 writer.writeAttribute(
"unitName",
unitName);
264 writer.writeAttribute(
"unitCvRef",
unitCvRef);
267 writer.writeEndElement();
277 return (std::uint8_t)i;
282 QObject::tr(
"cvParam value string is not an integer %1 %2").arg(
accession).arg(
valueStr));
290 qint64 i =
valueStr.toLongLong(&ok);
298 QObject::tr(
"cvParam value string is not an integer %1 %2").arg(
accession).arg(
valueStr));
314 QObject::tr(
"cvParam value string is not a double %1 %2").arg(
accession).arg(
valueStr));
321 const QStringView &value_str)
324 double d = value_str.toDouble(&ok);
327 if(value_str.contains(
'.'))
329 cborType = QCborStreamReader::Type::Double;
334 qint64 bigint = value_str.toLongLong(&ok);
337 cborType = QCborStreamReader::Type::NegativeInteger;
338 writer.append(bigint);
344 cborType = QCborStreamReader::Type::String;
345 writer.append(value_str);
simple override of the raw QCborStreamReader This adds convenient functions to put CBOR data into C++...
bool decodeString(QString &the_str)
decode the current cbor value as a string the point to the next value the current value is decoded as...
overrides QCborStreamWriter base class to provide convenient functions
PSI cvParam object for mzML/mzCBOR.
void fromCbor(CborStreamReader &reader)
QJsonObject toJsonObject() const
write the structure to a JSON object
QCborStreamReader::Type cborType
void setValue(const QString &value_str)
void xmlValueToCbor(CborStreamWriter &writer, const QStringView &value_str)
void fromMzml(QXmlStreamReader &reader)
reads the XML attributes of the cvParam element Inside the cvParam XML element, reads the attributes ...
void toCbor(CborStreamWriter &writer)
qint64 getExpectedQint64() const
void toMzml(QXmlStreamWriter &writer)
std::uint8_t getExpectedUint8() const
double getExpectedDouble() const