36 reader.enterContainer();
37 QString attribute_cvparam;
38 while(reader.hasNext())
42 if(attribute_cvparam ==
"cvRef")
46 else if(attribute_cvparam ==
"accession")
50 else if(attribute_cvparam ==
"name")
54 else if(attribute_cvparam ==
"value")
62 else if(reader.isUnsignedInteger())
64 valueInt = reader.toUnsignedInteger();
67 else if(reader.isInteger())
72 else if(reader.type() == QCborStreamReader::Type::String)
81 QObject::tr(
"cvParam value string failed for accession %1").arg(
accession));
87 QObject::tr(
"cvParam value type not known for accession %1").arg(
accession));
90 else if(attribute_cvparam ==
"unitAccession")
95 else if(attribute_cvparam ==
"unitCvRef")
99 else if(attribute_cvparam ==
"unitName")
109 reader.leaveContainer();
116 for(
auto &the_attribute : reader.attributes())
118 if(the_attribute.name() ==
"cvRef")
120 cvRef = the_attribute.value().toString();
122 else if(the_attribute.name() ==
"accession")
124 accession = the_attribute.value().toString();
126 else if(the_attribute.name() ==
"name")
128 name = the_attribute.value().toString();
130 else if(the_attribute.name() ==
"value")
132 valueStr = the_attribute.value().toString();
134 else if(the_attribute.name() ==
"unitCvRef")
136 unitCvRef = the_attribute.value().toString();
138 else if(the_attribute.name() ==
"unitAccession")
142 else if(the_attribute.name() ==
"unitName")
144 unitName = the_attribute.value().toString();
148 reader.readNextStartElement();
157 writer.append(
"cvRef");
158 writer.append(
cvRef);
160 writer.append(
"accession");
162 writer.append(
"name");
165 writer.append(
"value");
170 writer.append(
"unitCvRef");
172 writer.append(
"unitAccession");
174 writer.append(
"unitName");
181std::map<QString, pappso::cbor::mzcbor::CvParam>
185 std::map<QString, CvParam> accession_values;
186 reader.enterContainer();
188 while(reader.hasNext())
193 accession_values.insert({cv_param.
accession, cv_param});
196 reader.leaveContainer();
197 return accession_values;
212 writer.writeStartElement(
"cvParam");
214 writer.writeAttribute(
"cvRef",
cvRef);
215 writer.writeAttribute(
"accession",
accession);
218 if(
cborType == QCborStreamReader::Type::Double)
222 else if(
cborType == QCborStreamReader::Type::UnsignedInteger)
226 else if(
cborType == QCborStreamReader::Type::NegativeInteger)
230 else if(
cborType == QCborStreamReader::Type::String)
233 writer.writeAttribute(
"value",
valueStr);
235 writer.writeAttribute(
"name",
name);
240 writer.writeAttribute(
"unitName",
unitName);
241 writer.writeAttribute(
"unitCvRef",
unitCvRef);
244 writer.writeEndElement();
254 return (std::uint8_t)i;
259 QObject::tr(
"cvParam value string is not an integer %1 %2").arg(
accession).arg(
valueStr));
267 qint64 i =
valueStr.toLongLong(&ok);
275 QObject::tr(
"cvParam value string is not an integer %1 %2").arg(
accession).arg(
valueStr));
291 QObject::tr(
"cvParam value string is not a double %1 %2").arg(
accession).arg(
valueStr));
298 const QStringView &value_str)
301 double d = value_str.toDouble(&ok);
304 if(value_str.contains(
'.'))
306 cborType = QCborStreamReader::Type::Double;
311 qint64 bigint = value_str.toLongLong(&ok);
314 cborType = QCborStreamReader::Type::NegativeInteger;
315 writer.append(bigint);
321 cborType = QCborStreamReader::Type::String;
322 writer.append(value_str);
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...
PSI cvParam object for mzML/mzCBOR.
void fromCbor(CborStreamReader &reader)
QCborStreamReader::Type cborType
void setValue(const QString &value_str)
static std::map< QString, pappso::cbor::mzcbor::CvParam > getCvParamsMapFromCbor(CborStreamReader &reader)
void xmlValueToCbor(CborStreamWriter &writer, const QStringView &value_str)
void fromMzml(QXmlStreamReader &reader)
void toCbor(CborStreamWriter &writer)
qint64 getExpectedQint64() const
void toMzml(QXmlStreamWriter &writer)
std::uint8_t getExpectedUint8() const
double getExpectedDouble() const