33#include <qjsonarray.h>
34#include <qjsonobject.h>
53 if(reader.isInvalid())
56 QObject::tr(
"ERROR in Spectrum::fromCbor :\ncbor is not valid"));
58 if(reader.enterContainer())
60 while(reader.hasNext() && (!reader.isInvalid()))
65 qDebug() << txt_value;
69 qDebug() << txt_value;
72 else if(txt_value ==
"index")
74 index = reader.toUnsignedInteger();
77 else if(txt_value ==
"defaultArrayLength")
82 else if(txt_value ==
"cvParam")
86 else if(txt_value ==
"scanList")
89 reader.enterContainer();
91 while(reader.hasNext() && (!reader.isInvalid()))
97 qDebug() << txt_value;
98 if(txt_value ==
"cvParam")
102 else if(txt_value ==
"scan")
105 reader.enterContainer();
107 while(reader.hasNext() && (!reader.isInvalid()))
114 reader.leaveContainer();
127 reader.leaveContainer();
129 else if(txt_value ==
"precursorList")
132 reader.enterContainer();
134 while(reader.hasNext() && (!reader.isInvalid()))
136 if(reader.isString())
140 qDebug() << txt_value;
142 if(txt_value ==
"cvParam")
146 else if(txt_value ==
"precursor")
152 while(reader.hasNext() && (!reader.isInvalid()))
179 reader.leaveContainer();
181 else if(txt_value ==
"binaryDataArray")
186 reader.enterContainer();
188 while(reader.hasNext())
196 reader.leaveContainer();
211 reader.leaveContainer();
219 if(reader.lastError() != QCborError::NoError)
222 QObject::tr(
"ERROR in Spectrum::fromCbor :\n%1").arg(reader.lastError()));
230 QJsonObject spectrum_json;
231 spectrum_json.insert(
"id",
id);
232 spectrum_json.insert(
"index", (qint64)
index);
234 spectrum_json.insert(
"cvParam",
cvParamMap.toJsonArray());
236 QJsonObject scan_list;
239 QJsonArray scan_array;
242 scan_array.append(scan.toJsonObject());
244 scan_list.insert(
"scan", scan_array);
245 spectrum_json.insert(
"scanList", scan_list);
249 QJsonObject precursor_list;
252 QJsonArray precursor_array;
255 precursor_array.append(precursor.toJsonObject());
257 precursor_list.insert(
"precursor", precursor_array);
258 spectrum_json.insert(
"precursorList", precursor_list);
271 return spectrum_json;
274std::map<QString, pappso::cbor::mzcbor::CvParam>
278 reader.enterContainer();
281 while(reader.hasNext() && (!reader.isInvalid()))
283 if(reader.isString())
287 qDebug() << txt_value;
288 if(txt_value ==
"cvParam")
304 reader.leaveContainer();
319 qDebug() << it->first <<
" " << it->second.valueInt;
320 return it->second.valueInt;
334 qDebug() << it->first <<
" " << it->second.valueInt;
335 return it->second.valueInt;
349 return scanList.front().getRtInSeconds();
355 std::vector<pappso_double> xVector;
356 std::vector<pappso_double> yVector;
359 if(binary_array.isIntensity())
363 else if(binary_array.isMz())
371 "error in pappso::cbor::mzcbor::Spectrum::decodeTrace: binary vector type not found"));
A simple container of DataPoint instances.
QJsonObject toJsonObject(const QString &x_label="x", const QString &y_label="y") const
serialize a PAPPSO trace object to JSON
size_t initialize(const std::vector< pappso_double > &xVector, const std::vector< pappso_double > &yVector)
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...
PSI scan object for mzML/mzCBOR.
PSI spectrum object for mzML/mzCBOR.
void fromCbor(CborStreamReader &reader)
void fromCbor(CborStreamReader &reader)
fill the structure reading data from a CBOR stream
void fromCbor(CborStreamReader &reader)
void fromCbor(CborStreamReader &reader)
static std::map< QString, pappso::cbor::mzcbor::CvParam > readScanCvParams(CborStreamReader &reader)
std::vector< Precursor > precursorList
std::vector< Scan > scanList
CvParamMap precursorListCvParamMap
QJsonObject toJsonObject() const
write the structure to a JSON object This is a simplified representation for easy JSON data handling ...
void fromCbor(CborStreamReader &reader, bool want_binary_data)
fill the structure reading data from a CBOR stream
double getRtInSeconds() const
CvParamMap scanListCvParamMap
void decodeTrace(pappso::Trace &trace) const
qint64 getTotalIonCount() const
std::vector< BinaryDataArray > binaryDataArrayList
std::size_t defaultArrayLength