40 reader.enterContainer();
42 while(reader.hasNext() && (!reader.isInvalid()))
49 if(txt_value ==
"bits")
52 bits = reader.toUnsignedInteger();
55 else if(txt_value ==
"isInt")
58 isInt = reader.toBool();
61 else if(txt_value ==
"unit")
67 else if(txt_value ==
"compress")
73 else if(txt_value ==
"data")
78 auto r = reader.readByteArray();
79 while(r.status == QCborStreamReader::Ok)
82 r = reader.readByteArray();
85 if(r.status == QCborStreamReader::Error)
107 reader.leaveContainer();
115 for(
auto it_binarr = cbor_map.cbegin(); it_binarr != cbor_map.cend(); it_binarr++)
120 txt_value = it_binarr.key().toString();
122 if(txt_value ==
"bits")
125 bits = it_binarr.value().toInteger();
127 else if(txt_value ==
"isInt")
130 isInt = it_binarr.value().toBool();
132 else if(txt_value ==
"unit")
135 unit = it_binarr.value().toString();
137 else if(txt_value ==
"compress")
140 compress = it_binarr.value().toString();
142 else if(txt_value ==
"data")
147 byteArray = it_binarr.value().toByteArray();
178 std::size_t encodedLength = reader.attributes().value(
"encodedLength").toULongLong();
179 qDebug() <<
"encodedLength=" << encodedLength;
180 while(reader.readNext() && !reader.isEndElement())
182 if(reader.isStartElement())
184 if(reader.name().toString() ==
"cvParam")
186 QString accession = reader.attributes().value(
"accession").toString();
188 qDebug() <<
"accession=" << accession;
190 if(accession ==
"MS:1000523")
195 else if(accession ==
"MS:1000519")
208 else if(accession ==
"MS:1000521")
220 else if(accession ==
"MS:1000522")
234 else if(accession ==
"MS:1000574")
238 else if(accession ==
"MS:1000576")
250 else if(accession ==
"MS:1000515")
254 else if(accession ==
"MS:1000514")
261 else if(accession ==
"MS:1000595")
268 else if(accession ==
"MS:1000786")
279 QObject::tr(
"cvParam accession %1 is not known in binaryDataArray")
282 QObject::tr(
"cvParam accession %1 is not known in binaryDataArray")
285 reader.skipCurrentElement();
287 else if(reader.name().toString() ==
"binary")
290 while(reader.readNext() && !reader.isEndElement())
292 if(reader.isCharacters())
295 QStringView content = reader.text().trimmed();
296 if((reader.text().toString() ==
"\n") || (reader.text().toString() ==
"\n\t"))
302 if(!content.isEmpty())
306 if((std::size_t)reader.text().size() != encodedLength)
308 qWarning() <<
"reader.text().size() != encodedLength"
309 << reader.text().size() <<
" " << encodedLength;
314 byteArray = byteArray.fromBase64(reader.text().trimmed().toLatin1());
322 reader.skipCurrentElement();
501 std::vector<double> &double_list)
const
504 int size_in_byte = 8;
513 if(compress ==
"zlib")
516 if(estimated_length == 0)
518 double_list.resize(0);
522 std::vector<unsigned char> data_heap;
523 uLongf decompressedSize = estimated_length * size_in_byte;
524 data_heap.resize(decompressedSize);
527 int result_zlib = uncompress(
528 data_heap.data(), &decompressedSize, (Bytef *)byteArray.constData(), byteArray.size());
530 if(result_zlib != Z_OK)
533 QObject::tr(
"Decompression failed: %1 decompressedSize=%2 estimated_length=%3")
535 .arg(decompressedSize)
536 .arg(estimated_length));
540 data_heap.resize(decompressedSize);
541 double_list.resize(decompressedSize / size_in_byte);
546 for(std::size_t i = 0; i < data_heap.size(); i += size_in_byte)
552 double_list[j] = *(std::int32_t *)&data_heap[i];
556 double_list[j] = *(std::float_t *)&data_heap[i];
563 double_list[j] = *(std::int64_t *)&data_heap[i];
567 double_list[j] = *(
double *)&data_heap[i];
575 else if(compress ==
"none")
578 qDebug() << size_in_byte <<
" " << byteArray.size();
580 double_list.resize(byteArray.size() / size_in_byte);
583 for(std::size_t i = 0; i < (std::size_t)byteArray.size(); i += size_in_byte)
585 qDebug() <<
" i=" << i;
590 double_list[j] = *(std::int32_t *)&byteArray.constData()[i];
594 double_list[j] = *(std::float_t *)&byteArray.constData()[i];
601 double_list[j] = *(std::int64_t *)&byteArray.constData()[i];
606 double_list[j] = *(
double *)&byteArray.constData()[i];