libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
cborstreamreaderinterface.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/processing/cbor/cborstreamreaderinterface.h
3
* \date 11/02/2025
4
* \author Olivier Langella
5
* \brief common interface to read CBOR streams with convenient framework
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 "
cborstreamreaderinterface.h
"
29
30
pappso::cbor::CborStreamReaderInterface::CborStreamReaderInterface
()
31
{
32
}
33
34
pappso::cbor::CborStreamReaderInterface::~CborStreamReaderInterface
()
35
{
36
}
37
38
39
bool
40
pappso::cbor::CborStreamReaderInterface::getExpectedString
()
41
{
42
bool
is_ok =
false
;
43
m_expectedString
=
""
;
44
if
(
mpa_cborReader
->type() == QCborStreamReader::String)
45
{
46
is_ok =
mpa_cborReader
->decodeString(
m_expectedString
);
47
}
48
49
return
is_ok;
50
}
51
52
53
void
54
pappso::cbor::CborStreamReaderInterface::initCborReader
(QFile *pcborfile)
55
{
56
57
if
(
mpa_cborReader
!=
nullptr
)
delete
mpa_cborReader
;
58
mpa_cborReader
=
nullptr
;
59
mpa_cborReader
=
new
CborStreamReader
();
60
// try to mmap the file, this is faster
61
char
*ptr =
62
reinterpret_cast<
char
*
>
(pcborfile->map(0, pcborfile->size(), QFile::MapPrivateOption));
63
if
(ptr)
64
{
65
// worked
66
m_data
= QByteArray::fromRawData(ptr, pcborfile->size());
67
mpa_cborReader
->addData(
m_data
);
68
}
69
else
if
(pcborfile->isSequential())
70
{
71
// details requires full contents, so allocate memory
72
m_data
= pcborfile->readAll();
73
mpa_cborReader
->addData(
m_data
);
74
}
75
else
76
{
77
// just use the QIODevice
78
mpa_cborReader
->setDevice(pcborfile);
79
}
80
}
81
cborstreamreaderinterface.h
pappso::cbor::CborStreamReaderInterface::CborStreamReaderInterface
CborStreamReaderInterface()
Definition
cborstreamreaderinterface.cpp:30
pappso::cbor::CborStreamReaderInterface::m_expectedString
QString m_expectedString
Definition
cborstreamreaderinterface.h:59
pappso::cbor::CborStreamReaderInterface::initCborReader
void initCborReader(QFile *pcborfile)
Definition
cborstreamreaderinterface.cpp:54
pappso::cbor::CborStreamReaderInterface::~CborStreamReaderInterface
virtual ~CborStreamReaderInterface()
Definition
cborstreamreaderinterface.cpp:34
pappso::cbor::CborStreamReaderInterface::getExpectedString
bool getExpectedString()
Definition
cborstreamreaderinterface.cpp:40
pappso::cbor::CborStreamReaderInterface::mpa_cborReader
CborStreamReader * mpa_cborReader
Definition
cborstreamreaderinterface.h:58
pappso::cbor::CborStreamReaderInterface::m_data
QByteArray m_data
Definition
cborstreamreaderinterface.h:60
pappso::cbor::CborStreamReader
Definition
cborstreamreader.h:45
pappsomspp
core
processing
cbor
cborstreamreaderinterface.cpp
Generated on Tue Sep 23 2025 09:36:35 for libpappsomspp by
1.13.2