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>
33namespace pappso::cbor
34{
35/**
36 * @todo write docs
37 */
38class JsonStreamWriter : public QTextStream
39{
40 public:
41 /**
42 * Default constructor
43 */
44 JsonStreamWriter(QIODevice *device);
45
46 /**
47 * Destructor
48 */
49 virtual ~JsonStreamWriter();
50
51 void startArray();
52 void endArray();
53 void startMap();
54 void endMap();
55
56
57 void writeCborMap(const QCborMap &cbor_map);
58 void writeCborArray(const QCborArray &cbor_array);
59 void appendKey(const QString &key);
60 void appendValue(const QString &value);
61 void writeArray(QStringList &str_list);
62
63 protected:
64 void comma();
65
66 private:
67 bool m_isStart = true;
68 bool m_nextIsValue = false;
69};
70} // 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)