Loading...
Searching...
No Matches
pappso::cbor::mzcbor::ConvertToMzml Class Reference

`#include <converttomzml.h>`

Inheritance diagram for pappso::cbor::mzcbor::ConvertToMzml:

## Public Member Functions

| ConvertToMzml (QXmlStreamWriter *p_writer)
virtual | ~ConvertToMzml ()
virtual void | readCbor (QFile *cborp, pappso::UiMonitorInterface &monitor)
virtual void | readCbor (QIODevice *cborp, pappso::UiMonitorInterface &monitor)
virtual void | close ()
| convenient function to clean pointer before leaving
Public Member Functions inherited from pappso::cbor::CborStreamReaderInterface
| CborStreamReaderInterface ()
virtual | ~CborStreamReaderInterface ()

## Protected Member Functions

void | readRoot (pappso::UiMonitorInterface &monitor)
void | writeElementInMzml (const QString &name, pappso::UiMonitorInterface &monitor)
Protected Member Functions inherited from pappso::cbor::CborStreamReaderInterface
bool | getExpectedString ()
void | initCborReader (QFile *pcborfile)
void | initCborReader (QIODevice *pcborfile)

## Private Attributes

QXmlStreamWriter * | mp_writer
bool | m_isMzcbor = false

## Additional Inherited Members

Protected Attributes inherited from pappso::cbor::CborStreamReaderInterface
CborStreamReader * | mpa_cborReader = nullptr
QString | m_expectedString
QByteArray | m_data

## Detailed Description

Todo
  write docs

Definition at line 47 of file converttomzml.h.

## Constructor & Destructor Documentation

## ConvertToMzml()

pappso::cbor::mzcbor::ConvertToMzml::ConvertToMzml | ( | QXmlStreamWriter * | p_writer | ) |

Default constructor

Definition at line 39 of file converttomzml.cpp.

: mp_writer(p_writer)
{
}
pappso::cbor::mzcbor::ConvertToMzml::mp_writer
QXmlStreamWriter * mp_writer
Definition converttomzml.h:72

References mp_writer.

## ~ConvertToMzml()

pappso::cbor::mzcbor::ConvertToMzml::~ConvertToMzml | ( |  | ) |

virtual

Destructor

Definition at line 43 of file converttomzml.cpp.

{
}

## Member Function Documentation

## close()

void pappso::cbor::mzcbor::ConvertToMzml::close | ( |  | ) |

virtual

convenient function to clean pointer before leaving

Reimplemented from pappso::cbor::CborStreamReaderInterface.

Definition at line 48 of file converttomzml.cpp.

{
}

## readCbor() [1/2]

void pappso::cbor::mzcbor::ConvertToMzml::readCbor | ( | QFile * | cborp,
|  | pappso::UiMonitorInterface & | monitor )

virtual

Definition at line 53 of file converttomzml.cpp.

{
qDebug();
initCborReader(cborp);
qDebug();
if(mpa_cborReader->isMap())
{
readRoot(monitor);
}
qDebug();
}
pappso::cbor::CborStreamReaderInterface::initCborReader
void initCborReader(QFile *pcborfile)
Definition cborstreamreaderinterface.cpp:80
pappso::cbor::CborStreamReaderInterface::mpa_cborReader
CborStreamReader * mpa_cborReader
Definition cborstreamreaderinterface.h:68
pappso::cbor::mzcbor::ConvertToMzml::readRoot
void readRoot(pappso::UiMonitorInterface &monitor)
Definition converttomzml.cpp:82

References pappso::cbor::CborStreamReaderInterface::initCborReader(), pappso::cbor::CborStreamReaderInterface::mpa_cborReader, and readRoot().

## readCbor() [2/2]

void pappso::cbor::mzcbor::ConvertToMzml::readCbor | ( | QIODevice * | cborp,
|  | pappso::UiMonitorInterface & | monitor )

virtual

Definition at line 67 of file converttomzml.cpp.

{
qDebug();
initCborReader(cborp);
qDebug();
if(mpa_cborReader->isMap())
{
readRoot(monitor);
}
qDebug();
}

References pappso::cbor::CborStreamReaderInterface::initCborReader(), pappso::cbor::CborStreamReaderInterface::mpa_cborReader, and readRoot().

## readRoot()

void pappso::cbor::mzcbor::ConvertToMzml::readRoot | ( | pappso::UiMonitorInterface & | monitor | ) |

protected

Definition at line 82 of file converttomzml.cpp.

{
qDebug();
mpa_cborReader->enterContainer();
while(getExpectedString())
{
if(m_expectedString == "mzCBOR")
{
m_isMzcbor = true;
mpa_cborReader->next();
}
else if(m_expectedString == "mzML")
{
QCborMap mzml_cbor;
mpa_cborReader->readCborMap(mzml_cbor);
//<mzML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
// xsi:schemaLocation="http://psi.hupo.org/ms/mzml
// http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd" version="1.1.0"
// id="20120906_balliau_extract_1_A01_urnb-1" xmlns="http://psi.hupo.org/ms/mzml">
mp_writer->setAutoFormatting(true);
mp_writer->writeStartDocument("1.0");
mp_writer->writeDefaultNamespace(mzml_cbor.value("xmlns").toString());
mp_writer->writeNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
mp_writer->writeStartElement("mzML");
mp_writer->writeAttribute("http://www.w3.org/2001/XMLSchema-instance",
"schemaLocation",
mzml_cbor.value("schemaLocation").toString());
for(auto &str_key : mzml_cbor.keys())
{
if((str_key != "xmlns") && (str_key != "schemaLocation"))
{
mp_writer->writeAttribute(str_key.toString(),
mzml_cbor.value(str_key).toString());
}
}
m_isMzcbor = true;
// getExpectedString();
// qDebug() << m_expectedString;
// mpa_cborReader->next();
while(getExpectedString())
{
qDebug() << m_expectedString;
writeElementInMzml(m_expectedString, monitor);
}
mp_writer->writeEndElement();
}
}
mpa_cborReader->leaveContainer();
mp_writer->writeEndDocument();
}
pappso::cbor::CborStreamReaderInterface::m_expectedString
QString m_expectedString
Definition cborstreamreaderinterface.h:69
pappso::cbor::CborStreamReaderInterface::getExpectedString
bool getExpectedString()
Definition cborstreamreaderinterface.cpp:54
pappso::cbor::mzcbor::ConvertToMzml::m_isMzcbor
bool m_isMzcbor
Definition converttomzml.h:73
pappso::cbor::mzcbor::ConvertToMzml::writeElementInMzml
void writeElementInMzml(const QString &name, pappso::UiMonitorInterface &monitor)
Definition converttomzml.cpp:147

References pappso::cbor::CborStreamReaderInterface::getExpectedString(), pappso::cbor::CborStreamReaderInterface::m_expectedString, m_isMzcbor, mp_writer, pappso::cbor::CborStreamReaderInterface::mpa_cborReader, and writeElementInMzml().

Referenced by readCbor(), and readCbor().

## writeElementInMzml()

void pappso::cbor::mzcbor::ConvertToMzml::writeElementInMzml | ( | const QString & | name,
|  | pappso::UiMonitorInterface & | monitor )

protected

Definition at line 147 of file converttomzml.cpp.

{
bool is_array = false;
if(name == "cvParam")
{ // this is an array
qDebug();
CvParamMap cvparam_map;
cvparam_map.fromCbor(*mpa_cborReader);
for(auto &cvparam_pair : cvparam_map)
{
cvparam_pair.second.toMzml(*mp_writer);
}
}
else if(name == "binaryDataArray")
{
mp_writer->writeStartElement("binaryDataArrayList");
mp_writer->writeAttribute("count", QString("%1").arg(mpa_cborReader->length()));
mpa_cborReader->enterContainer();
while(mpa_cborReader->hasNext())
{
BinaryDataArray binary_data_array;
binary_data_array.fromCbor(*mpa_cborReader);
binary_data_array.toMzml(*mp_writer);
}
mpa_cborReader->leaveContainer();
mp_writer->writeEndElement();
}
else
{
if(mpa_cborReader->isArray())
{
is_array = true;
}
else if(mpa_cborReader->isMap())
{
}
else
{
// error
qWarning() << "not a map, not an array";
}
if(is_array)
{
mpa_cborReader->enterContainer();
while(mpa_cborReader->hasNext())
{
writeElementInMzml(name, monitor);
}
mpa_cborReader->leaveContainer();
}
else
{
mp_writer->writeStartElement(name);
mpa_cborReader->enterContainer();
while(getExpectedString())
{
qDebug() << m_expectedString;
QString current_attribute = m_expectedString;
if(mpa_cborReader->isContainer())
{
qDebug() << current_attribute;
writeElementInMzml(current_attribute, monitor);
}
else if(mpa_cborReader->isInteger())
{
qDebug() << current_attribute;
mp_writer->writeAttribute(current_attribute,
QString("%1").arg(mpa_cborReader->toInteger()));
mpa_cborReader->next();
}
else if(mpa_cborReader->isUnsignedInteger())
{
qDebug() << current_attribute;
mp_writer->writeAttribute(current_attribute,
QString("%1").arg(mpa_cborReader->toUnsignedInteger()));
}
else if(mpa_cborReader->isString())
{
getExpectedString();
qDebug() << current_attribute;
mp_writer->writeAttribute(current_attribute, m_expectedString);
}
else
{
qDebug() << current_attribute;
mpa_cborReader->next();
}
}
mpa_cborReader->leaveContainer();
mp_writer->writeEndElement();
}
}
}

References pappso::cbor::mzcbor::BinaryDataArray::fromCbor(), pappso::cbor::mzcbor::CvParamMap::fromCbor(), pappso::cbor::CborStreamReaderInterface::getExpectedString(), pappso::cbor::CborStreamReaderInterface::m_expectedString, mp_writer, pappso::cbor::CborStreamReaderInterface::mpa_cborReader, pappso::cbor::mzcbor::BinaryDataArray::toMzml(), and writeElementInMzml().

Referenced by readRoot(), and writeElementInMzml().

## Member Data Documentation

## m_isMzcbor

bool pappso::cbor::mzcbor::ConvertToMzml::m_isMzcbor = false

private

Definition at line 73 of file converttomzml.h.

Referenced by readRoot().

## mp_writer

QXmlStreamWriter* pappso::cbor::mzcbor::ConvertToMzml::mp_writer

private

Definition at line 72 of file converttomzml.h.

Referenced by ConvertToMzml(), readRoot(), and writeElementInMzml().

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

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