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 endMap();
79}
80
81
82void
83CborStreamWriter::writeArray(const std::vector<std::size_t> &int_list)
84{
85 startArray(int_list.size());
86 for(auto num : int_list)
87 {
88 append((quint64)num);
89 }
90 endArray();
91}
92
93void
94CborStreamWriter::writeArray(const std::vector<double> &double_list)
95{
96 startArray(double_list.size());
97 for(auto num : double_list)
98 {
99 append(num);
100 }
101 endArray();
102}
103
104void
105CborStreamWriter::writeArray(const std::vector<int> &positions)
106{
107
108 startArray(positions.size());
109 for(auto num : positions)
110 {
111 append(num);
112 }
113 endArray();
114}
115
116void
117CborStreamWriter::writeArray(QStringList &str_list)
118{
119 startArray(str_list.size());
120 for(auto str_item : str_list)
121 {
122 append(str_item);
123 }
124 endArray();
125}
126
127
128void
129CborStreamWriter::writeCborMap(const QCborMap &cbor_map)
130{
131 QCborValue(cbor_map).toCbor(*this);
132}
133
134void
135CborStreamWriter::writeCborArray(const QCborArray &cbor_array)
136{
137 QCborValue(cbor_array).toCbor(*this);
138}
139
140} // namespace cbor
141} // 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