39 for(
auto it_binarr = cbor_map.cbegin(); it_binarr != cbor_map.cend(); it_binarr++)
41 txt_value = it_binarr.key().toString();
42 qDebug() << txt_value;
44 if(txt_value ==
"cvRef")
46 cvRef = it_binarr.value().toString();
48 else if(txt_value ==
"accession")
52 else if(txt_value ==
"name")
54 name = it_binarr.value().toString();
56 else if(txt_value ==
"value")
58 if(it_binarr.value().isDouble())
62 else if(it_binarr.value().isInteger())
64 valueInt = it_binarr.value().toInteger();
66 else if(it_binarr.value().isString())
68 valueStr = it_binarr.value().toString();
73 QObject::tr(
"cvParam value type not known for accession %1").arg(
accession));
76 else if(txt_value ==
"unitAccession")
81 else if(txt_value ==
"unitCvRef")
85 else if(txt_value ==
"unitName")
87 unitName = it_binarr.value().toString();
99 reader.enterContainer();
100 QString attribute_cvparam;
101 while(reader.hasNext())
104 qDebug() << attribute_cvparam;
105 if(attribute_cvparam ==
"cvRef")
109 else if(attribute_cvparam ==
"accession")
113 else if(attribute_cvparam ==
"name")
117 else if(attribute_cvparam ==
"value")
120 if(reader.isDouble())
125 else if(reader.isUnsignedInteger())
127 valueInt = reader.toUnsignedInteger();
130 else if(reader.isInteger())
135 else if(reader.type() == QCborStreamReader::Type::String)
144 QObject::tr(
"cvParam value string failed for accession %1").arg(
accession));
150 QObject::tr(
"cvParam value type not known for accession %1").arg(
accession));
153 else if(attribute_cvparam ==
"unitAccession")
158 else if(attribute_cvparam ==
"unitCvRef")
162 else if(attribute_cvparam ==
"unitName")
172 reader.leaveContainer();
180 for(
auto &the_attribute : reader.attributes())
182 if(the_attribute.name() ==
"cvRef")
184 cvRef = the_attribute.value().toString();
186 else if(the_attribute.name() ==
"accession")
188 accession = the_attribute.value().toString();
190 else if(the_attribute.name() ==
"name")
192 name = the_attribute.value().toString();
194 else if(the_attribute.name() ==
"value")
196 valueStr = the_attribute.value().toString();
198 else if(the_attribute.name() ==
"unitCvRef")
200 unitCvRef = the_attribute.value().toString();
202 else if(the_attribute.name() ==
"unitAccession")
206 else if(the_attribute.name() ==
"unitName")
208 unitName = the_attribute.value().toString();
212 reader.readNextStartElement();
221 writer.append(
"cvRef");
222 writer.append(
cvRef);
224 writer.append(
"accession");
226 writer.append(
"name");
229 writer.append(
"value");
234 writer.append(
"unitCvRef");
236 writer.append(
"unitAccession");
238 writer.append(
"unitName");
248 QJsonObject cv_param;
249 cv_param.insert(
"cvRef",
cvRef);
251 cv_param.insert(
"name",
name);
256 if(
valueInt == std::numeric_limits<qint64>::max())
274 cv_param.insert(
"unitName",
unitName);
291 writer.writeStartElement(
"cvParam");
293 writer.writeAttribute(
"cvRef",
cvRef);
294 writer.writeAttribute(
"accession",
accession);
297 if(
cborType == QCborStreamReader::Type::Double)
301 else if(
cborType == QCborStreamReader::Type::UnsignedInteger)
305 else if(
cborType == QCborStreamReader::Type::NegativeInteger)
309 else if(
cborType == QCborStreamReader::Type::String)
312 writer.writeAttribute(
"value",
valueStr);
314 writer.writeAttribute(
"name",
name);
319 writer.writeAttribute(
"unitName",
unitName);
320 writer.writeAttribute(
"unitCvRef",
unitCvRef);
323 writer.writeEndElement();
333 return (std::uint8_t)i;
338 QObject::tr(
"cvParam value string is not an integer %1 %2").arg(
accession).arg(
valueStr));
346 qint64 i =
valueStr.toLongLong(&ok);
354 QObject::tr(
"cvParam value string is not an integer %1 %2").arg(
accession).arg(
valueStr));
370 QObject::tr(
"cvParam value string is not a double %1 %2").arg(
accession).arg(
valueStr));
377 const QStringView &value_str)
380 double d = value_str.toDouble(&ok);
383 if(value_str.contains(
'.'))
385 cborType = QCborStreamReader::Type::Double;
390 qint64 bigint = value_str.toLongLong(&ok);
393 cborType = QCborStreamReader::Type::NegativeInteger;
394 writer.append(bigint);
400 cborType = QCborStreamReader::Type::String;
401 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 fromQCborMap(const QCborMap &reader)
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