libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::cbor::CborStreamReader Class Reference

#include <cborstreamreader.h>

Inheritance diagram for pappso::cbor::CborStreamReader:

Public Member Functions

 CborStreamReader ()
 
 CborStreamReader (QIODevice *device)
 
virtual ~CborStreamReader ()
 
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 a string, beware that using this function, the cbor stream will point to the next cbor value
 
bool readCborMap (QCborMap &cbor_map)
 
bool readCborArray (QCborArray &cbor_array)
 
bool readArray (std::vector< std::size_t > &int_list)
 
bool readArray (std::vector< qint64 > &int_list)
 
bool readArray (std::vector< double > &double_list)
 
bool readArray (std::vector< int > &positions)
 
bool readArray (QStringList &str_list)
 
bool readArray (std::vector< QString > &str_list)
 

Detailed Description

Todo:
write docs

Definition at line 44 of file cborstreamreader.h.

Constructor & Destructor Documentation

◆ CborStreamReader() [1/2]

pappso::cbor::CborStreamReader::CborStreamReader ( )

Default constructor

Definition at line 36 of file cborstreamreader.cpp.

36 : QCborStreamReader()
37{
38}

◆ CborStreamReader() [2/2]

pappso::cbor::CborStreamReader::CborStreamReader ( QIODevice *  device)

Definition at line 40 of file cborstreamreader.cpp.

40 : QCborStreamReader(device)
41{
42}

◆ ~CborStreamReader()

pappso::cbor::CborStreamReader::~CborStreamReader ( )
virtual

Destructor

Definition at line 43 of file cborstreamreader.cpp.

44{
45}

Member Function Documentation

◆ decodeString()

bool pappso::cbor::CborStreamReader::decodeString ( QString &  the_str)

decode the current cbor value as a string the point to the next value the current value is decoded as a string, beware that using this function, the cbor stream will point to the next cbor value

Returns
true if OK

Definition at line 48 of file cborstreamreader.cpp.

49{
50 the_str.clear();
51 auto r = readString();
52 while(r.status == QCborStreamReader::Ok)
53 {
54 the_str += r.data;
55 r = readString();
56 }
57
58 if(r.status == QCborStreamReader::Error)
59 {
60 // handle error condition
61 the_str.clear();
62 return false;
63 }
64 return true;
65}

Referenced by pappso::cbor::mzcbor::BinaryDataArray::fromCbor(), pappso::cbor::mzcbor::CvParam::fromCbor(), pappso::cbor::mzcbor::SelectedIon::fromCbor(), pappso::cbor::mzcbor::Precursor::fromCbor(), pappso::cbor::mzcbor::Spectrum::fromCbor(), readArray(), readArray(), pappso::cbor::psm::PsmProteinMap::readMap(), pappso::cbor::psm::PsmFileReaderBase::readPsm(), pappso::cbor::psm::PsmFileReaderBase::readPsmFile(), pappso::cbor::psm::PsmFileReaderBase::readPsmProteinRef(), pappso::cbor::psm::PsmFileReaderBase::readSample(), and pappso::cbor::mzcbor::Spectrum::readScanCvParams().

◆ readArray() [1/6]

bool pappso::cbor::CborStreamReader::readArray ( QStringList &  str_list)

Definition at line 154 of file cborstreamreader.cpp.

155{
156 enterContainer();
157 QString the_str;
158 while(!lastError() && hasNext())
159 {
160 if(decodeString(the_str))
161 {
162 str_list << the_str;
163 }
164 else
165 {
166 return false;
167 }
168 }
169 leaveContainer();
170 return true;
171}
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...

References decodeString().

◆ readArray() [2/6]

bool pappso::cbor::CborStreamReader::readArray ( std::vector< double > &  double_list)

Definition at line 69 of file cborstreamreader.cpp.

70{
71 enterContainer();
72 while(!lastError() && hasNext())
73 {
74 if(isDouble())
75 {
76 double_list.push_back(toDouble());
77 }
78 else
79 {
80 return false;
81 }
82 next();
83 //}
84 }
85 leaveContainer();
86 return true;
87}

◆ readArray() [3/6]

bool pappso::cbor::CborStreamReader::readArray ( std::vector< int > &  positions)

Definition at line 90 of file cborstreamreader.cpp.

91{
92 enterContainer();
93 while(!lastError() && hasNext())
94 {
95 if(isInteger())
96 {
97 positions.push_back(toInteger());
98 }
99 else
100 {
101 return false;
102 }
103 next();
104 //}
105 }
106 leaveContainer();
107 return true;
108}

◆ readArray() [4/6]

bool pappso::cbor::CborStreamReader::readArray ( std::vector< qint64 > &  int_list)

Definition at line 132 of file cborstreamreader.cpp.

133{
134 enterContainer();
135 while(!lastError() && hasNext())
136 {
137 if(isUnsignedInteger())
138 {
139 int_list.push_back(toUnsignedInteger());
140 }
141 else
142 {
143 return false;
144 }
145 next();
146 //}
147 }
148 leaveContainer();
149 return true;
150}

◆ readArray() [5/6]

bool pappso::cbor::CborStreamReader::readArray ( std::vector< QString > &  str_list)

Definition at line 173 of file cborstreamreader.cpp.

174{
175 str_list.clear();
176 str_list.reserve(length());
177 enterContainer();
178 QString the_str;
179 while(!lastError() && hasNext())
180 {
181 if(decodeString(the_str))
182 {
183 str_list.push_back(the_str);
184 }
185 else
186 {
187 return false;
188 }
189 }
190 leaveContainer();
191 return true;
192}

References decodeString().

◆ readArray() [6/6]

bool pappso::cbor::CborStreamReader::readArray ( std::vector< std::size_t > &  int_list)

Definition at line 111 of file cborstreamreader.cpp.

112{
113 enterContainer();
114 while(!lastError() && hasNext())
115 {
116 if(isUnsignedInteger())
117 {
118 int_list.push_back(toUnsignedInteger());
119 }
120 else
121 {
122 return false;
123 }
124 next();
125 //}
126 }
127 leaveContainer();
128 return true;
129}

Referenced by pappso::cbor::psm::PsmFileReaderBase::readPsmProteinRef(), and pappso::cbor::psm::PsmFileReaderBase::readRoot().

◆ readCborArray()

bool pappso::cbor::CborStreamReader::readCborArray ( QCborArray &  cbor_array)

Definition at line 211 of file cborstreamreader.cpp.

212{
213 cbor_array = QCborValue::fromCbor(*this).toArray();
214 if(!lastError())
215 {
216 return true;
217 }
218 else
219 {
220 qDebug() << lastError().toString();
221 }
222
223 return false;
224}

Referenced by pappso::cbor::psm::PsmFileReaderBase::readLog().

◆ readCborMap()

bool pappso::cbor::CborStreamReader::readCborMap ( QCborMap &  cbor_map)

Definition at line 195 of file cborstreamreader.cpp.

196{
197 cbor_map = QCborValue::fromCbor(*this).toMap();
198 if(!lastError())
199 {
200 return true;
201 }
202 else
203 {
204 qDebug() << lastError().toString();
205 }
206
207 return false;
208}

Referenced by pappso::cbor::psm::PsmFileAppend::close(), pappso::cbor::psm::PsmFileReaderBase::readInformations(), pappso::cbor::psm::PsmProteinMap::readMap(), pappso::cbor::psm::PsmFileReaderBase::readParameterMap(), pappso::cbor::psm::PsmFileReaderBase::readPsm(), pappso::cbor::psm::PsmFileReaderBase::readScan(), and pappso::cbor::psm::PsmFileScanProcess::readScan().


The documentation for this class was generated from the following files: