mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-1244 Added basic streaming xml write support to UAVObjects.
This commit is contained in:
parent
905e6a8eda
commit
b272948ff4
@ -519,6 +519,20 @@ QString UAVObject::toStringData()
|
||||
return sout;
|
||||
}
|
||||
|
||||
void UAVObject::toXML(QXmlStreamWriter *xmlWriter)
|
||||
{
|
||||
xmlWriter->writeStartElement("object");
|
||||
xmlWriter->writeAttribute("name", getName());
|
||||
xmlWriter->writeAttribute("objectid", QString::number(getObjID()));
|
||||
xmlWriter->writeAttribute("instanceid", QString::number(getInstID()));
|
||||
xmlWriter->writeStartElement("fields");
|
||||
foreach(UAVObjectField* field , fields) {
|
||||
field->toXML(xmlWriter);
|
||||
}
|
||||
xmlWriter->writeEndElement(); // fields
|
||||
xmlWriter->writeEndElement(); // object
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit the transactionCompleted event (used by the UAVTalk plugin)
|
||||
*/
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <QList>
|
||||
#include <QFile>
|
||||
#include <stdint.h>
|
||||
#include <QXmlStreamWriter>
|
||||
#include "uavobjectfield.h"
|
||||
|
||||
#define UAVOBJ_ACCESS_SHIFT 0
|
||||
@ -127,6 +128,7 @@ public:
|
||||
QString toString();
|
||||
QString toStringBrief();
|
||||
QString toStringData();
|
||||
void toXML(QXmlStreamWriter *xmlWriter);
|
||||
void emitTransactionCompleted(bool success);
|
||||
void emitNewInstance(UAVObject *);
|
||||
|
||||
|
@ -654,6 +654,16 @@ QString UAVObjectField::toString()
|
||||
return sout;
|
||||
}
|
||||
|
||||
void UAVObjectField::toXML(QXmlStreamWriter *xmlWriter)
|
||||
{
|
||||
xmlWriter->writeStartElement("field");
|
||||
xmlWriter->writeAttribute("name", getName());
|
||||
xmlWriter->writeAttribute("type", getTypeAsString());
|
||||
for (unsigned int n = 0; n < numElements; ++n) {
|
||||
xmlWriter->writeTextElement("value", getValue(n).toString());
|
||||
}
|
||||
xmlWriter->writeEndElement(); // field
|
||||
}
|
||||
|
||||
qint32 UAVObjectField::pack(quint8 *dataOut)
|
||||
{
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <QVariant>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
class UAVObject;
|
||||
|
||||
@ -72,6 +73,7 @@ public:
|
||||
bool isNumeric();
|
||||
bool isText();
|
||||
QString toString();
|
||||
void toXML(QXmlStreamWriter *xmlWriter);
|
||||
|
||||
bool isWithinLimits(QVariant var, quint32 index, int board = 0);
|
||||
QVariant getMaxLimit(quint32 index, int board = 0);
|
||||
|
Loading…
Reference in New Issue
Block a user