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< double > &double_list)
 
bool readArray (std::vector< int > &positions)
 
bool readArray (QStringList &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 readArray(), and pappso::cbor::psm::PsmProteinMap::readMap().

◆ readArray() [1/4]

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

Definition at line 133 of file cborstreamreader.cpp.

134{
135 enterContainer();
136 QString the_str;
137 while(!lastError() && hasNext())
138 {
139 if(decodeString(the_str))
140 {
141 str_list << the_str;
142 }
143 else
144 {
145 return false;
146 }
147 }
148 leaveContainer();
149 return true;
150}
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/4]

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/4]

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/4]

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}

◆ readCborArray()

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

Definition at line 169 of file cborstreamreader.cpp.

170{
171 cbor_array = QCborValue::fromCbor(*this).toArray();
172 if(!lastError())
173 {
174 return true;
175 }
176 else
177 {
178 qDebug() << lastError().toString();
179 }
180
181 return false;
182}

◆ readCborMap()

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

Definition at line 153 of file cborstreamreader.cpp.

154{
155 cbor_map = QCborValue::fromCbor(*this).toMap();
156 if(!lastError())
157 {
158 return true;
159 }
160 else
161 {
162 qDebug() << lastError().toString();
163 }
164
165 return false;
166}

Referenced by pappso::cbor::psm::PsmFileAppend::close(), and pappso::cbor::psm::PsmProteinMap::readMap().


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