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
52const QString &
54{
55 return m_uuid;
56}
57
58void
59CborStreamWriter::writeInformations(const QString &software_name,
60 const QString &software_version,
61 const QString &type,
62 const QString &operation)
63{
64 append("informations");
65 startMap();
66 append(QLatin1String("software"));
67 append(software_name);
68 append(QLatin1String("version"));
69 append(software_version);
70 append(QLatin1String("type"));
71 append(type);
72 append(QLatin1String("operation"));
73 append(operation);
74 append(QLatin1String("cpu_used"));
75 append(QThreadPool::globalInstance()->maxThreadCount());
76 append(QLatin1String("pappsomspp_version"));
78 append(QLatin1String("sysinfo_machine_hostname"));
79 append(QSysInfo::machineHostName());
80 append(QLatin1String("sysinfo_product_name"));
81 append(QSysInfo::prettyProductName());
82 append(QLatin1String("timestamp"));
83 append(QDateTime::currentDateTime().toString(Qt::ISODate));
84
85 append(QLatin1String("uuid"));
86 m_uuid = QUuid::createUuid().toString();
87 append(m_uuid);
88 endMap();
89}
90
91
92void
93CborStreamWriter::writeArray(const std::vector<std::size_t> &int_list)
94{
95 startArray(int_list.size());
96 for(auto num : int_list)
97 {
98 append((quint64)num);
99 }
100 endArray();
101}
102
103void
104CborStreamWriter::writeArray(const std::vector<double> &double_list)
105{
106 startArray(double_list.size());
107 for(auto num : double_list)
108 {
109 append(num);
110 }
111 endArray();
112}
113
114void
115CborStreamWriter::writeArray(const std::vector<int> &positions)
116{
117
118 startArray(positions.size());
119 for(auto num : positions)
120 {
121 append(num);
122 }
123 endArray();
124}
125
126
127void
128CborStreamWriter::writeArray(const std::vector<qint64> &int_list)
129{
130
131 startArray(int_list.size());
132 for(auto num : int_list)
133 {
134 append(num);
135 }
136 endArray();
137}
138
139void
140CborStreamWriter::writeArray(const QStringList &str_list)
141{
142 startArray(str_list.size());
143 for(auto str_item : str_list)
144 {
145 append(str_item);
146 }
147 endArray();
148}
149
150void
151CborStreamWriter::writeArray(const std::vector<QString> &str_list)
152{
153 startArray(str_list.size());
154 for(auto str_item : str_list)
155 {
156 append(str_item);
157 }
158 endArray();
159}
160
161void
162CborStreamWriter::writeCborMap(const QCborMap &cbor_map)
163{
164 QCborValue(cbor_map).toCbor(*this);
165}
166
167void
168CborStreamWriter::writeCborArray(const QCborArray &cbor_array)
169{
170 QCborValue(cbor_array).toCbor(*this);
171}
172
173} // namespace cbor
174} // 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)
const QString & getUuid() const
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