Loading...
Searching...
No Matches
pappso::cbor::mzcbor::CvParam Struct Reference

`#include <cvparam.h>`

## Public Member Functions

void | fromCbor (CborStreamReader &reader)
void | toCbor (CborStreamWriter &writer)
void | fromMzml (QXmlStreamReader &reader)
| reads the XML attributes of the cvParam element Inside the cvParam XML element, reads the attributes and go to next XML element
void | toMzml (QXmlStreamWriter &writer)
QJsonObject | toJsonObject () const
| write the structure to a JSON object
void | xmlValueToCbor (CborStreamWriter &writer, const QStringView &value_str)
void | setValue (const QString &value_str)
std::uint8_t | getExpectedUint8 () const
double | getExpectedDouble () const
qint64 | getExpectedQint64 () const

## Public Attributes

QString | cvRef
QString | accession
double | valueDouble = nan("")
qint64 | valueInt = std::numeric_limits<qint64>::max()
QString | valueStr
QString | name
QString | unitAccession
QString | unitName
QString | unitCvRef
QCborStreamReader::Type | cborType = QCborStreamReader::Type::Invalid

## Detailed Description

Todo
  write docs

Definition at line 46 of file cvparam.h.

## Member Function Documentation

## fromCbor()

void pappso::cbor::mzcbor::CvParam::fromCbor | ( | CborStreamReader & | reader | ) |

Definition at line 36 of file cvparam.cpp.

{
qDebug();
if(!reader.isMap())
{
throw pappso::PappsoException(QObject::tr("this is not a cvParam : no map"));
}
reader.enterContainer();
QString attribute_cvparam;
while(reader.hasNext())
{
reader.decodeString(attribute_cvparam);
qDebug() << attribute_cvparam;
if(attribute_cvparam == "cvRef")
{
reader.decodeString(cvRef);
}
else if(attribute_cvparam == "accession")
{
reader.decodeString(accession);
}
else if(attribute_cvparam == "name")
{
reader.decodeString(name);
}
else if(attribute_cvparam == "value")
{
cborType = reader.type();
if(reader.isDouble())
{
valueDouble = reader.toDouble();
reader.next();
}
else if(reader.isUnsignedInteger())
{
valueInt = reader.toUnsignedInteger();
reader.next();
}
else if(reader.isInteger())
{
valueInt = reader.toInteger();
reader.next();
}
else if(reader.type() == QCborStreamReader::Type::String)
{
if(reader.decodeString(attribute_cvparam))
{
valueStr = attribute_cvparam;
}
else
{
throw pappso::PappsoException(
QObject::tr("cvParam value string failed for accession %1").arg(accession));
}
}
else
{
throw pappso::PappsoException(
QObject::tr("cvParam value type not known for accession %1").arg(accession));
}
}
else if(attribute_cvparam == "unitAccession")
{
reader.decodeString(unitAccession);
}
else if(attribute_cvparam == "unitCvRef")
{
reader.decodeString(unitCvRef);
}
else if(attribute_cvparam == "unitName")
{
reader.decodeString(unitName);
}
else
{
reader.next();
}
}
reader.leaveContainer();
qDebug();
}
pappso::cbor::mzcbor::CvParam::valueStr
QString valueStr
Definition cvparam.h:77
pappso::cbor::mzcbor::CvParam::cvRef
QString cvRef
Definition cvparam.h:73
pappso::cbor::mzcbor::CvParam::valueDouble
double valueDouble
Definition cvparam.h:75
pappso::cbor::mzcbor::CvParam::accession
QString accession
Definition cvparam.h:74
pappso::cbor::mzcbor::CvParam::unitName
QString unitName
Definition cvparam.h:80
pappso::cbor::mzcbor::CvParam::cborType
QCborStreamReader::Type cborType
Definition cvparam.h:83
pappso::cbor::mzcbor::CvParam::valueInt
qint64 valueInt
Definition cvparam.h:76
pappso::cbor::mzcbor::CvParam::unitCvRef
QString unitCvRef
Definition cvparam.h:81
pappso::cbor::mzcbor::CvParam::unitAccession
QString unitAccession
Definition cvparam.h:79
pappso::cbor::mzcbor::CvParam::name
QString name
Definition cvparam.h:78

References accession, cborType, cvRef, pappso::cbor::CborStreamReader::decodeString(), name, unitAccession, unitCvRef, unitName, valueDouble, valueInt, and valueStr.

Referenced by pappso::cbor::mzcbor::CvParamMap::fromCbor(), and pappso::cbor::mzcbor::MzcborReaderBase::getCvParamsMap().

## fromMzml()

void pappso::cbor::mzcbor::CvParam::fromMzml | ( | QXmlStreamReader & | reader | ) |

reads the XML attributes of the cvParam element Inside the cvParam XML element, reads the attributes and go to next XML element

Parameters

  reader | XML stream reader

Definition at line 121 of file cvparam.cpp.

{
// qDebug();
for(auto &the_attribute : reader.attributes())
{
if(the_attribute.name() == "cvRef")
{
cvRef = the_attribute.value().toString();
}
else if(the_attribute.name() == "accession")
{
accession = the_attribute.value().toString();
}
else if(the_attribute.name() == "name")
{
name = the_attribute.value().toString();
}
else if(the_attribute.name() == "value")
{
valueStr = the_attribute.value().toString();
}
else if(the_attribute.name() == "unitCvRef")
{
unitCvRef = the_attribute.value().toString();
}
else if(the_attribute.name() == "unitAccession")
{
unitAccession = the_attribute.value().toString();
}
else if(the_attribute.name() == "unitName")
{
unitName = the_attribute.value().toString();
}
}
reader.readNextStartElement();
// qDebug();
}

References accession, cvRef, name, unitAccession, unitCvRef, unitName, and valueStr.

Referenced by pappso::cbor::mzcbor::MzmlConvert::insideElement().

## getExpectedDouble()

double pappso::cbor::mzcbor::CvParam::getExpectedDouble | ( |  | ) | const

Definition at line 303 of file cvparam.cpp.

{
bool ok(false);
double i = valueStr.toDouble(&ok);
if(ok)
{
return i;
}
else
{
throw pappso::PappsoException(
QObject::tr("cvParam value string is not a double %1 %2").arg(accession).arg(valueStr));
}
}

References accession, and valueStr.

Referenced by pappso::cbor::mzcbor::MzmlConvert::insideElement().

## getExpectedQint64()

qint64 pappso::cbor::mzcbor::CvParam::getExpectedQint64 | ( |  | ) | const

Definition at line 287 of file cvparam.cpp.

{
bool ok(false);
qint64 i = valueStr.toLongLong(&ok);
if(ok)
{
return i;
}
else
{
throw pappso::PappsoException(
QObject::tr("cvParam value string is not an integer %1 %2").arg(accession).arg(valueStr));
}
}

References accession, and valueStr.

## getExpectedUint8()

std::uint8_t pappso::cbor::mzcbor::CvParam::getExpectedUint8 | ( |  | ) | const

Definition at line 271 of file cvparam.cpp.

{
bool ok(false);
int i = valueStr.toInt(&ok);
if(ok)
{
return (std::uint8_t)i;
}
else
{
throw pappso::PappsoException(
QObject::tr("cvParam value string is not an integer %1 %2").arg(accession).arg(valueStr));
}
}

References accession, and valueStr.

Referenced by pappso::cbor::mzcbor::MzmlConvert::insideElement().

## setValue()

void pappso::cbor::mzcbor::CvParam::setValue | ( | const QString & | value_str | ) |

Definition at line 224 of file cvparam.cpp.

{
valueInt = 0;
valueDouble = 0;
valueStr = value_str;
}

References valueDouble, valueInt, and valueStr.

Referenced by pappso::cbor::mzcbor::BinaryDataArray::toMzml().

## toCbor()

void pappso::cbor::mzcbor::CvParam::toCbor | ( | CborStreamWriter & | writer | ) |

Definition at line 161 of file cvparam.cpp.

{
writer.startMap();
writer.append("cvRef");
writer.append(cvRef);
writer.append("accession");
writer.append(accession);
writer.append("name");
writer.append(name);
writer.append("value");
xmlValueToCbor(writer, valueStr);
if(!unitAccession.isEmpty())
{
writer.append("unitCvRef");
writer.append(unitCvRef);
writer.append("unitAccession");
writer.append(unitAccession);
writer.append("unitName");
writer.append(unitName);
}
writer.endMap();
}
pappso::cbor::mzcbor::CvParam::xmlValueToCbor
void xmlValueToCbor(CborStreamWriter &writer, const QStringView &value_str)
Definition cvparam.cpp:320

References accession, cvRef, name, unitAccession, unitCvRef, unitName, valueStr, and xmlValueToCbor().

Referenced by pappso::cbor::mzcbor::MzmlConvert::insideElement().

## toJsonObject()

QJsonObject pappso::cbor::mzcbor::CvParam::toJsonObject | ( |  | ) | const

write the structure to a JSON object

Returns
  QJsonObject

Definition at line 190 of file cvparam.cpp.

{
QJsonObject cv_param;
cv_param.insert("cvRef", cvRef);
cv_param.insert("accession", accession);
cv_param.insert("name", name);
if(std::isnan(valueDouble))
{
if(valueInt == std::numeric_limits<qint64>::max())
{
cv_param.insert("value", valueStr);
}
else
{
cv_param.insert("value", valueInt);
}
}
else
{
cv_param.insert("value", valueDouble);
}
if(!unitAccession.isEmpty())
{
cv_param.insert("unitCvRef", unitCvRef);
cv_param.insert("unitAccession", unitAccession);
cv_param.insert("unitName", unitName);
}
return cv_param;
}

References accession, cvRef, name, unitAccession, unitCvRef, unitName, valueDouble, valueInt, and valueStr.

## toMzml()

void pappso::cbor::mzcbor::CvParam::toMzml | ( | QXmlStreamWriter & | writer | ) |

Definition at line 232 of file cvparam.cpp.

{
// <cvParam cvRef="MS" accession="MS:1000514" value="" name="m/z array"
writer.writeStartElement("cvParam");
writer.writeAttribute("cvRef", cvRef);
writer.writeAttribute("accession", accession);
if(cborType == QCborStreamReader::Type::Double)
{
valueStr = QString::number(valueDouble, 'g', 15);
}
else if(cborType == QCborStreamReader::Type::UnsignedInteger)
{
valueStr = QString("%1").arg(valueInt);
}
else if(cborType == QCborStreamReader::Type::NegativeInteger)
{
valueStr = QString("%1").arg(valueInt);
}
else if(cborType == QCborStreamReader::Type::String)
{
}
writer.writeAttribute("value", valueStr);
writer.writeAttribute("name", name);
// unitAccession="MS:1000040" unitName="m/z" unitCvRef="MS" />
if(!unitAccession.isEmpty())
{
writer.writeAttribute("unitAccession", unitAccession);
writer.writeAttribute("unitName", unitName);
writer.writeAttribute("unitCvRef", unitCvRef);
}
writer.writeEndElement(); // cvParam
}

References accession, cborType, cvRef, name, unitAccession, unitCvRef, unitName, valueDouble, valueInt, and valueStr.

Referenced by pappso::cbor::mzcbor::BinaryDataArray::toMzml().

## xmlValueToCbor()

void pappso::cbor::mzcbor::CvParam::xmlValueToCbor | ( | CborStreamWriter & | writer,
|  | const QStringView & | value_str )

Definition at line 320 of file cvparam.cpp.

{
bool ok(false);
double d = value_str.toDouble(&ok);
if(ok)
{
if(value_str.contains('.'))
{
cborType = QCborStreamReader::Type::Double;
writer.append(d);
}
else
{
qint64 bigint = value_str.toLongLong(&ok);
if(ok)
{
cborType = QCborStreamReader::Type::NegativeInteger;
writer.append(bigint);
}
}
}
else
{
cborType = QCborStreamReader::Type::String;
writer.append(value_str);
}
}
pappso::masschroq::PeakQualityCategory::d
@ d
Definition types.h:56

References cborType.

Referenced by toCbor().

## Member Data Documentation

## accession

QString pappso::cbor::mzcbor::CvParam::accession

Definition at line 74 of file cvparam.h.

Referenced by fromCbor(), pappso::cbor::mzcbor::CvParamMap::fromCbor(), fromMzml(), pappso::cbor::mzcbor::MzcborReaderBase::getCvParamsMap(), getExpectedDouble(), getExpectedQint64(), getExpectedUint8(), pappso::cbor::mzcbor::MzmlConvert::insideElement(), toCbor(), toJsonObject(), pappso::cbor::mzcbor::BinaryDataArray::toMzml(), and toMzml().

## cborType

QCborStreamReader::Type pappso::cbor::mzcbor::CvParam::cborType = QCborStreamReader::Type::Invalid

Definition at line 83 of file cvparam.h.

Referenced by fromCbor(), toMzml(), and xmlValueToCbor().

## cvRef

QString pappso::cbor::mzcbor::CvParam::cvRef

Definition at line 73 of file cvparam.h.

Referenced by fromCbor(), fromMzml(), toCbor(), toJsonObject(), pappso::cbor::mzcbor::BinaryDataArray::toMzml(), and toMzml().

## name

QString pappso::cbor::mzcbor::CvParam::name

Definition at line 78 of file cvparam.h.

Referenced by fromCbor(), fromMzml(), pappso::cbor::mzcbor::MzmlConvert::insideElement(), toCbor(), toJsonObject(), pappso::cbor::mzcbor::BinaryDataArray::toMzml(), and toMzml().

## unitAccession

QString pappso::cbor::mzcbor::CvParam::unitAccession

Definition at line 79 of file cvparam.h.

Referenced by fromCbor(), fromMzml(), pappso::cbor::mzcbor::MzmlConvert::insideElement(), toCbor(), toJsonObject(), pappso::cbor::mzcbor::BinaryDataArray::toMzml(), and toMzml().

## unitCvRef

QString pappso::cbor::mzcbor::CvParam::unitCvRef

Definition at line 81 of file cvparam.h.

Referenced by fromCbor(), fromMzml(), toCbor(), toJsonObject(), pappso::cbor::mzcbor::BinaryDataArray::toMzml(), and toMzml().

## unitName

QString pappso::cbor::mzcbor::CvParam::unitName

Definition at line 80 of file cvparam.h.

Referenced by fromCbor(), fromMzml(), toCbor(), toJsonObject(), pappso::cbor::mzcbor::BinaryDataArray::toMzml(), and toMzml().

## valueDouble

double pappso::cbor::mzcbor::CvParam::valueDouble = nan("")

Definition at line 75 of file cvparam.h.

Referenced by fromCbor(), setValue(), toJsonObject(), and toMzml().

## valueInt

qint64 pappso::cbor::mzcbor::CvParam::valueInt = std::numeric_limits<qint64>::max()

Definition at line 76 of file cvparam.h.

Referenced by fromCbor(), setValue(), toJsonObject(), and toMzml().

## valueStr

QString pappso::cbor::mzcbor::CvParam::valueStr

Definition at line 77 of file cvparam.h.

Referenced by fromCbor(), fromMzml(), getExpectedDouble(), getExpectedQint64(), getExpectedUint8(), setValue(), toCbor(), toJsonObject(), and toMzml().

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

- pappsomspp/core/processing/cbor/mzcbor/cvparam.h
- pappsomspp/core/processing/cbor/mzcbor/cvparam.cpp