libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
jsonstreamwriter.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/jsonstreamwriter.h
3 * \date 19/07/2025
4 * \author Olivier Langella
5 * \brief PAPPSO JSON 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#pragma once
28
29#include <QTextStream>
30#include <QCborMap>
31#include <QCborArray>
32#include <QIODevice>
33
34
36
37namespace pappso::cbor
38{
39/**
40 * @todo write docs
41 */
42 class PMSPP_LIB_DECL JsonStreamWriter : public QTextStream
43{
44 public:
45 /**
46 * Default constructor
47 */
48 JsonStreamWriter(QIODevice *device);
49
50 /**
51 * Destructor
52 */
53 virtual ~JsonStreamWriter();
54
55 void startArray();
56 void endArray();
57 void startMap();
58 void endMap();
59
60
61 void writeCborMap(const QCborMap &cbor_map);
62 void writeCborArray(const QCborArray &cbor_array);
63 void appendKey(const QString &key);
64 void appendValue(const QString &value);
65 void appendValue(std::size_t integer_size_value);
66 void writeArray(QStringList &str_list);
67
68 protected:
69 void comma();
70
71 private:
72 bool m_isStart = true;
73 bool m_nextIsValue = false;
74};
75} // namespace pappso::cbor
void appendValue(const QString &value)
void writeCborArray(const QCborArray &cbor_array)
void writeArray(QStringList &str_list)
void appendKey(const QString &key)
void writeCborMap(const QCborMap &cbor_map)
#define PMSPP_LIB_DECL