libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
cborstreamreader.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/cborstreamwriter.h
3 * \date 08/07/2025
4 * \author Olivier Langella
5 * \brief PAPPSO CBOR stream reader
6 *
7 * QCborStreamReader overloaded with convenient functions
8 */
9
10/*******************************************************************************
11 * Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
12 *
13 * This file is part of PAPPSOms-tools.
14 *
15 * PAPPSOms-tools is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * PAPPSOms-tools is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
27 *
28 ******************************************************************************/
29#pragma once
30
31#include <QCborStreamReader>
32#include <QStringList>
33#include <QCborMap>
34#include <QCborArray>
35#include <qcborvalue.h>
37
38namespace pappso
39{
40namespace cbor
41{
42/**
43 * @brief simple override of the raw QCborStreamReader
44 * This adds convenient functions to put CBOR data into C++ structures
45 */
46class PMSPP_LIB_DECL CborStreamReader : public QCborStreamReader
47{
48 public:
49 /**
50 * Default constructor
51 */
53 CborStreamReader(QIODevice *device);
54
55 /**
56 * Destructor
57 */
58 virtual ~CborStreamReader();
59
60 /** @brief decode the current cbor value as a string the point to the next value
61 * the current value is decoded as a string, beware that using this function, the cbor stream will
62 * point to the next cbor value
63 * @param the_str reference to the string
64 * @return true if OK
65 */
66 bool decodeString(QString &the_str);
67
68 /** @brief transfer the entire current CBOR value to a QCborValue object
69 * @param cbor_value QCborValue reference to use
70 * @return true if OK
71 */
72 bool readCborValue(QCborValue &cbor_value);
73
74 /** @brief transfer the entire current CBOR map to a QCborMap object
75 * @param cbor_map QCborMap reference to use
76 * @return true if OK
77 */
78 bool readCborMap(QCborMap &cbor_map);
79
80
81 /** @brief transfer the entire current CBOR array to a QCborMap object
82 * @param cbor_map QCborMap reference to use
83 * @return true if OK
84 */
85 bool readCborArray(QCborArray &cbor_array);
86 bool readArray(std::vector<std::size_t> &int_list);
87 bool readArray(std::vector<qint64> &int_list);
88 bool readArray(std::vector<double> &double_list);
89 bool readArray(std::vector<int> &positions);
90 bool readArray(std::vector<std::uint8_t> &small_int_list);
91 bool readArray(QStringList &str_list);
92 bool readArray(std::vector<QString> &str_list);
93};
94} // namespace cbor
95} // namespace pappso
bool readCborMap(QCborMap &cbor_map)
transfer the entire current CBOR map to a QCborMap object
bool readCborArray(QCborArray &cbor_array)
transfer the entire current CBOR array to a QCborMap object
bool readArray(std::vector< std::size_t > &int_list)
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...
bool readCborValue(QCborValue &cbor_value)
transfer the entire current CBOR value to a QCborValue object
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39