Loading...
Searching...
No Matches
pappso::cbor::CborStreamReader Class Reference

simple override of the raw QCborStreamReader This adds convenient functions to put CBOR data into C++ structures More...

`#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)
| transfer the entire current CBOR map to a QCborMap object
bool | readCborArray (QCborArray &cbor_array)
| transfer the entire current CBOR array to a QCborMap object
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 (std::vector< std::uint8_t > &small_int_list)
bool | readArray (QStringList &str_list)
bool | readArray (std::vector< QString > &str_list)

## Detailed Description

simple override of the raw QCborStreamReader This adds convenient functions to put CBOR data into C++ structures

Definition at line 45 of file cborstreamreader.h.

## Constructor & Destructor Documentation

## CborStreamReader() [1/2]

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

Default constructor

Definition at line 36 of file cborstreamreader.cpp.

: QCborStreamReader()
{
}

## CborStreamReader() [2/2]

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

Definition at line 40 of file cborstreamreader.cpp.

: QCborStreamReader(device)
{
}

## ~CborStreamReader()

pappso::cbor::CborStreamReader::~CborStreamReader | ( |  | ) |

virtual

Destructor

Definition at line 43 of file cborstreamreader.cpp.

{
}

## 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

Parameters

  the_str | reference to the string

Returns
  true if OK

Definition at line 48 of file cborstreamreader.cpp.

{
the_str.clear();
auto r = readString();
while(r.status == QCborStreamReader::Ok)
{
the_str += r.data;
r = readString();
}
if(r.status == QCborStreamReader::Error)
{
// handle error condition
the_str.clear();
return false;
}
return true;
}

Referenced by pappso::cbor::mzcbor::BinaryDataArray::fromCbor(), pappso::cbor::mzcbor::CvParam::fromCbor(), pappso::cbor::mzcbor::IsolationWindow::fromCbor(), pappso::cbor::mzcbor::Precursor::fromCbor(), pappso::cbor::mzcbor::Scan::fromCbor(), pappso::cbor::mzcbor::SelectedIon::fromCbor(), pappso::cbor::mzcbor::Spectrum::fromCbor(), readArray(), readArray(), pappso::cbor::psm::PsmProteinMap::readMap(), and pappso::cbor::mzcbor::Spectrum::readScanCvParams().

## readArray() [1/7]

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

Definition at line 176 of file cborstreamreader.cpp.

{
enterContainer();
QString the_str;
while(!lastError() && hasNext())
{
if(decodeString(the_str))
{
str_list << the_str;
}
else
{
return false;
}
}
leaveContainer();
return true;
}
pappso::cbor::CborStreamReader::decodeString
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...
Definition cborstreamreader.cpp:48

References decodeString().

## readArray() [2/7]

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

Definition at line 69 of file cborstreamreader.cpp.

{
enterContainer();
while(!lastError() && hasNext())
{
if(isDouble())
{
double_list.push_back(toDouble());
}
else
{
return false;
}
next();
//}
}
leaveContainer();
return true;
}

## readArray() [3/7]

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

Definition at line 112 of file cborstreamreader.cpp.

{
enterContainer();
while(!lastError() && hasNext())
{
if(isInteger())
{
positions.push_back(toInteger());
}
else
{
return false;
}
next();
//}
}
leaveContainer();
return true;
}

## readArray() [4/7]

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

Definition at line 154 of file cborstreamreader.cpp.

{
enterContainer();
while(!lastError() && hasNext())
{
if(isUnsignedInteger())
{
int_list.push_back(toUnsignedInteger());
}
else
{
return false;
}
next();
//}
}
leaveContainer();
return true;
}

## readArray() [5/7]

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

Definition at line 195 of file cborstreamreader.cpp.

{
str_list.clear();
str_list.reserve(length());
enterContainer();
QString the_str;
while(!lastError() && hasNext())
{
if(decodeString(the_str))
{
str_list.push_back(the_str);
}
else
{
return false;
}
}
leaveContainer();
return true;
}

References decodeString().

## readArray() [6/7]

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

Definition at line 133 of file cborstreamreader.cpp.

{
enterContainer();
while(!lastError() && hasNext())
{
if(isUnsignedInteger())
{
int_list.push_back(toUnsignedInteger());
}
else
{
return false;
}
next();
//}
}
leaveContainer();
return true;
}

## readArray() [7/7]

bool pappso::cbor::CborStreamReader::readArray | ( | std::vector< std::uint8_t > & | small_int_list | ) |

Definition at line 90 of file cborstreamreader.cpp.

{
enterContainer();
while(!lastError() && hasNext())
{
if(isInteger())
{
small_int_list.push_back(toInteger());
}
else
{
return false;
}
next();
//}
}
leaveContainer();
return true;
}

## readCborArray()

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

transfer the entire current CBOR array to a QCborMap object

Parameters

  cbor_map | QCborMap reference to use

Returns
  true if OK

Definition at line 233 of file cborstreamreader.cpp.

{
cbor_array = QCborValue::fromCbor(*this).toArray();
if(!lastError())
{
return true;
}
else
{
qDebug() << lastError().toString();
}
return false;
}

## readCborMap()

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

transfer the entire current CBOR map to a QCborMap object

Parameters

  cbor_map | QCborMap reference to use

Returns
  true if OK

Definition at line 217 of file cborstreamreader.cpp.

{
cbor_map = QCborValue::fromCbor(*this).toMap();
if(!lastError())
{
return true;
}
else
{
qDebug() << lastError().toString();
}
return false;
}

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

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

- pappsomspp/core/processing/cbor/cborstreamreader.h
- pappsomspp/core/processing/cbor/cborstreamreader.cpp