libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
cborstreamwriter.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/cborstreamwriter.cpp
3 * \date 05/07/2025
4 * \author Olivier Langella
5 * \brief PAPPSO CBOR stream writer
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
10 *
11 * This file is part of PAPPSOms-tools.
12 *
13 * PAPPSOms-tools is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms-tools is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
28#include "cborstreamwriter.h"
29#include <QDateTime>
30#include <QThreadPool>
32#include <QCborValue>
33
34namespace pappso
35{
36namespace cbor
37{
38CborStreamWriter::CborStreamWriter(QByteArray *data) : QCborStreamWriter(data)
39{
40}
41
42CborStreamWriter::CborStreamWriter(QIODevice *device) : QCborStreamWriter(device)
43{
44}
45
46
50
51
52void
53CborStreamWriter::writeInformations(const QString &software_name,
54 const QString &software_version,
55 const QString &type,
56 const QString &operation)
57{
58 append("informations");
59 startMap();
60 append(QLatin1String("software"));
61 append(software_name);
62 append(QLatin1String("version"));
63 append(software_version);
64 append(QLatin1String("type"));
65 append(type);
66 append(QLatin1String("operation"));
67 append(operation);
68 append(QLatin1String("cpu_used"));
69 append(QThreadPool::globalInstance()->maxThreadCount());
70 append(QLatin1String("pappsomspp_version"));
72 append(QLatin1String("sysinfo_machine_hostname"));
73 append(QSysInfo::machineHostName());
74 append(QLatin1String("sysinfo_product_name"));
75 append(QSysInfo::prettyProductName());
76 append(QLatin1String("timestamp"));
77 append(QDateTime::currentDateTime().toString(Qt::ISODate));
78
79 append(QLatin1String("uuid"));
80 append(QUuid::createUuid().toString());
81 endMap();
82}
83
84
85void
86CborStreamWriter::writeArray(const std::vector<std::size_t> &int_list)
87{
88 startArray(int_list.size());
89 for(auto num : int_list)
90 {
91 append((quint64)num);
92 }
93 endArray();
94}
95
96void
97CborStreamWriter::writeArray(const std::vector<double> &double_list)
98{
99 startArray(double_list.size());
100 for(auto num : double_list)
101 {
102 append(num);
103 }
104 endArray();
105}
106
107void
108CborStreamWriter::writeArray(const std::vector<int> &positions)
109{
110
111 startArray(positions.size());
112 for(auto num : positions)
113 {
114 append(num);
115 }
116 endArray();
117}
118
119void
120CborStreamWriter::writeArray(QStringList &str_list)
121{
122 startArray(str_list.size());
123 for(auto str_item : str_list)
124 {
125 append(str_item);
126 }
127 endArray();
128}
129
130
131void
132CborStreamWriter::writeCborMap(const QCborMap &cbor_map)
133{
134 QCborValue(cbor_map).toCbor(*this);
135}
136
137void
138CborStreamWriter::writeCborArray(const QCborArray &cbor_array)
139{
140 QCborValue(cbor_array).toCbor(*this);
141}
142
143} // namespace cbor
144} // namespace pappso
static QString getVersion()
Definition utils.cpp:623
void writeInformations(const QString &software_name, const QString &software_version, const QString &type, const QString &operation)
void writeArray(const std::vector< std::size_t > &int_list)
void writeCborMap(const QCborMap &cbor_map)
void writeCborArray(const QCborArray &cbor_array)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39