libpappsomspp
Library for mass spectrometry
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 More...
 
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 41 of file cborstreamreader.h.

Constructor & Destructor Documentation

◆ CborStreamReader() [1/2]

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

Default constructor

Definition at line 32 of file cborstreamreader.cpp.

32 : QCborStreamReader()
33{
34}

◆ CborStreamReader() [2/2]

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

Definition at line 36 of file cborstreamreader.cpp.

36 : QCborStreamReader(device)
37{
38}

◆ ~CborStreamReader()

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

Destructor

Definition at line 39 of file cborstreamreader.cpp.

40{
41}

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 44 of file cborstreamreader.cpp.

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

Referenced by pappso::cbor::psm::PsmProteinMap::readMap().

◆ readArray() [1/4]

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

Definition at line 129 of file cborstreamreader.cpp.

130{
131 enterContainer();
132 QString the_str;
133 while(!lastError() && hasNext())
134 {
135 if(decodeString(the_str))
136 {
137 str_list << the_str;
138 }
139 else
140 {
141 return false;
142 }
143 }
144 leaveContainer();
145 return true;
146}
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...

◆ readArray() [2/4]

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

Definition at line 65 of file cborstreamreader.cpp.

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

◆ readArray() [3/4]

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

Definition at line 86 of file cborstreamreader.cpp.

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

◆ readArray() [4/4]

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

Definition at line 107 of file cborstreamreader.cpp.

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

◆ readCborArray()

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

Definition at line 165 of file cborstreamreader.cpp.

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

◆ readCborMap()

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

Definition at line 149 of file cborstreamreader.cpp.

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

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


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