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
35
#include "
pappsomspp/export-import-config.h
"
36
37
namespace
pappso::cbor
38
{
39
/**
40
* @brief helper class to write json text using CBOR data structures
41
*/
42
class
PMSPP_LIB_DECL
JsonStreamWriter
:
public
QTextStream
43
{
44
public
:
45
/** @brief build a QTextStream for JSON writer
46
*/
47
JsonStreamWriter
(QIODevice *device);
48
49
/**
50
* Destructor
51
*/
52
virtual
~JsonStreamWriter
();
53
54
55
/** @brief starts an array in JSON output
56
* simply print "["
57
*/
58
void
startArray();
59
60
61
/** @brief ends an array in JSON output
62
* simply print "]"
63
*/
64
void
endArray();
65
66
67
/** @brief start an object in JSON output
68
* simply print "{"
69
*/
70
void
startMap();
71
72
73
/** @brief ends an object in JSON output
74
* simply print "}"
75
*/
76
void
endMap();
77
78
79
/** @brief converts a CBOR map (object) into JSON text in output
80
* @param cbor_map the map to convert
81
*/
82
void
writeCborMap(
const
QCborMap &cbor_map);
83
84
85
/** @brief converts a CBOR array (list) into JSON text in output
86
* @param cbor_array the map to convert
87
*/
88
void
writeCborArray(
const
QCborArray &cbor_array);
89
90
/** @brief writes a key (dictionary entry) to JSON text
91
*/
92
void
appendKey(
const
QString &key);
93
94
95
/** @brief writes String value to JSON text
96
* @warning this function does not escapes text correctly, use with caution
97
*/
98
void
appendValue(
const
QString &value);
99
100
101
/** @brief writes an integer value to JSON text
102
*/
103
void
appendValue(std::size_t integer_size_value);
104
105
/** @brief convert a string list to a JSON array
106
* @warning text is not escaped correctly, use with caution
107
*/
108
void
writeArray(QStringList &str_list);
109
110
protected
:
111
void
comma();
112
113
private
:
114
bool
m_isStart =
true
;
115
bool
m_nextIsValue =
false
;
116
};
117
}
// namespace pappso::cbor
pappso::cbor::JsonStreamWriter
helper class to write json text using CBOR data structures
Definition
jsonstreamwriter.h:43
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition
export-import-config.h:14
pappso::cbor
Definition
cborstreamreader.cpp:35
pappsomspp
core
processing
cbor
jsonstreamwriter.h
Generated on Tue May 19 2026 12:52:14 for libpappsomspp by
1.9.8