pappso::XmlStreamReaderInterface Class Referenceabstract

convenient xml reader helper More...

`#include <xmlstreamreaderinterface.h>`

Inheritance diagram for pappso::XmlStreamReaderInterface:

## Public Member Functions

| XmlStreamReaderInterface ()
virtual | ~XmlStreamReaderInterface ()
virtual bool | readFile (const QString &fileName)
bool | read (QIODevice *device)
bool | read (const QString &xml_content)
QString | errorString () const

## Protected Member Functions

virtual void | readStream ()=0
void | cloneStartElement (QXmlStreamWriter &output) const
void | cloneElement (QXmlStreamWriter &output)
void | cloneNode (QXmlStreamWriter &output)

## Protected Attributes

QXmlStreamReader | m_qxmlStreamReader

## Detailed Description

convenient xml reader helper

Definition at line 40 of file xmlstreamreaderinterface.h.

## Constructor & Destructor Documentation

## XmlStreamReaderInterface()

XmlStreamReaderInterface::XmlStreamReaderInterface | ( |  | ) |

Default constructor

Definition at line 37 of file xmlstreamreaderinterface.cpp.

{
}

## ~XmlStreamReaderInterface()

XmlStreamReaderInterface::~XmlStreamReaderInterface | ( |  | ) |

virtual

Destructor

Definition at line 41 of file xmlstreamreaderinterface.cpp.

{
}

## Member Function Documentation

## cloneElement()

void pappso::XmlStreamReaderInterface::cloneElement | ( | QXmlStreamWriter & | output | ) |

protected

Definition at line 124 of file xmlstreamreaderinterface.cpp.

{
qDebug() << " name=" << m_qxmlStreamReader.name();
output.writeStartElement(m_qxmlStreamReader.namespaceUri().toString(),
m_qxmlStreamReader.name().toString());
output.writeAttributes(m_qxmlStreamReader.attributes());
qDebug() << m_qxmlStreamReader.name();
while(m_qxmlStreamReader.readNext() && !m_qxmlStreamReader.isEndElement())
{
cloneNode(output);
if(output.hasError())
{
qDebug();
m_qxmlStreamReader.raiseError(QObject::tr("Error in ouptut stream"));
}
}
qDebug();
output.writeEndElement();
}
pappso::XmlStreamReaderInterface::m_qxmlStreamReader
QXmlStreamReader m_qxmlStreamReader
Definition: xmlstreamreaderinterface.h:71
pappso::XmlStreamReaderInterface::cloneNode
void cloneNode(QXmlStreamWriter &output)
Definition: xmlstreamreaderinterface.cpp:146

Referenced by pappso::WrapTandemResults::process_group_note(), and pappso::WrapTandemResults::readStream().

## cloneNode()

void pappso::XmlStreamReaderInterface::cloneNode | ( | QXmlStreamWriter & | output | ) |

protected

Definition at line 146 of file xmlstreamreaderinterface.cpp.

{
qDebug();
if(m_qxmlStreamReader.isCharacters())
{
qDebug() << "isCharacters " << m_qxmlStreamReader.text();
if((m_qxmlStreamReader.text() == "\n") ||
(m_qxmlStreamReader.text() == "\n\t"))
{
// xml cleaner
}
else
{
output.writeCharacters(
m_qxmlStreamReader.text().toString().trimmed());
}
}
else if(m_qxmlStreamReader.isEndElement())
{
qDebug() << "isEndElement";
output.writeEndElement();
}
else if(m_qxmlStreamReader.isStartElement())
{
qDebug() << "isStartElement";
cloneElement(output);
}
else
{
}
qDebug();
}
pappso::XmlStreamReaderInterface::cloneElement
void cloneElement(QXmlStreamWriter &output)
Definition: xmlstreamreaderinterface.cpp:124

## cloneStartElement()

void pappso::XmlStreamReaderInterface::cloneStartElement | ( | QXmlStreamWriter & | output | ) | const

protected

Definition at line 110 of file xmlstreamreaderinterface.cpp.

{
output.writeStartElement(m_qxmlStreamReader.name().toString());
for(auto declaration : m_qxmlStreamReader.namespaceDeclarations())
{
output.writeNamespace(declaration.namespaceUri().toString(),
declaration.prefix().toString());
}
output.writeAttributes(m_qxmlStreamReader.attributes());
}

Referenced by pappso::WrapTandemResults::process_group_note(), pappso::WrapTandemInput::readStream(), and pappso::WrapTandemResults::readStream().

## errorString()

QString pappso::XmlStreamReaderInterface::errorString | ( |  | ) | const

Definition at line 46 of file xmlstreamreaderinterface.cpp.

{
if(m_qxmlStreamReader.errorString().isEmpty())
return "";
else
{
QString error = QObject::tr("ERROR at line %1 column %2\n%3")
.arg(m_qxmlStreamReader.lineNumber())
.arg(m_qxmlStreamReader.columnNumber())
.arg(m_qxmlStreamReader.errorString());
return error;
}
}

Referenced by pappso::TandemWrapperRun::readTandemPresetFile(), pappso::TandemWrapperRun::wrapTandemInputFile(), and pappso::TandemWrapperRun::writeFinalTandemOutput().

## read() [1/2]

bool pappso::XmlStreamReaderInterface::read | ( | const QString & | xml_content | ) |

Definition at line 100 of file xmlstreamreaderinterface.cpp.

{
m_qxmlStreamReader.clear();
m_qxmlStreamReader.addData(xml_content);
m_qxmlStreamReader.setNamespaceProcessing(true);
readStream();
return !m_qxmlStreamReader.error();
}
pappso::XmlStreamReaderInterface::readStream
virtual void readStream()=0

## read() [2/2]

bool pappso::XmlStreamReaderInterface::read | ( | QIODevice * | device | ) |

Definition at line 89 of file xmlstreamreaderinterface.cpp.

{
m_qxmlStreamReader.setDevice(device);
m_qxmlStreamReader.setNamespaceProcessing(true);
readStream();
return !m_qxmlStreamReader.error();
}

## readFile()

bool pappso::XmlStreamReaderInterface::readFile | ( | const QString & | fileName | ) |

virtual

Definition at line 61 of file xmlstreamreaderinterface.cpp.

{
QFile file(fileName);
if(!file.open(QFile::ReadOnly | QFile::Text))
{
m_qxmlStreamReader.raiseError(
QObject::tr("Cannot read file %1 : %2")
.arg(QFileInfo(fileName).absoluteFilePath())
.arg(m_qxmlStreamReader.errorString()));
return false;
}
if(read(&file))
{
file.close();
return true;
}
else
{
file.close();
m_qxmlStreamReader.raiseError(
QObject::tr("Error reading file %1 : %2")
.arg(QFileInfo(fileName).absoluteFilePath())
.arg(m_qxmlStreamReader.errorString()));
return false;
}
}
pappso::XmlStreamReaderInterface::read
bool read(QIODevice *device)
Definition: xmlstreamreaderinterface.cpp:89

Referenced by pappso::TandemWrapperRun::readTandemPresetFile(), pappso::TandemWrapperRun::wrapTandemInputFile(), and pappso::TandemWrapperRun::writeFinalTandemOutput().

## readStream()

virtual void pappso::XmlStreamReaderInterface::readStream | ( |  | ) |

protected pure virtual

Implemented in pappso::XtandemPresetReader, pappso::WrapTandemResults, and pappso::WrapTandemInput.

## Member Data Documentation

## m_qxmlStreamReader

QXmlStreamReader pappso::XmlStreamReaderInterface::m_qxmlStreamReader

protected

Definition at line 71 of file xmlstreamreaderinterface.h.

Referenced by pappso::WrapTandemResults::process_group_note(), pappso::XtandemPresetReader::read_note(), pappso::WrapTandemInput::readStream(), pappso::WrapTandemResults::readStream(), and pappso::XtandemPresetReader::readStream().

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

- pappsomspp/processing/xml/xmlstreamreaderinterface.h
- pappsomspp/processing/xml/xmlstreamreaderinterface.cpp