very dirty metacompiler for protocol information code

This commit is contained in:
Max-Wilhelm Bruker
2009-10-26 15:09:17 +01:00
parent dbd3af8265
commit b0841dd6e8
7 changed files with 163 additions and 103 deletions

View File

@@ -1,16 +1,14 @@
#include "protocol.h"
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QDebug>
#include "protocol.h"
#include "protocol_commands.h"
QHash<QString, Command::NewCommandFunction> Command::commandHash;
Command::Command(const QString &_cmdName)
: cmdName(_cmdName)
{
}
void Command::validateParameters()
{
}
bool Command::read(QXmlStreamReader &xml)
@@ -22,7 +20,7 @@ bool Command::read(QXmlStreamReader &xml)
} else if (xml.isEndElement()) {
qDebug() << "endElement: " << xml.name().toString();
if (xml.name() == cmdName) {
validateParameters();
extractParameters();
qDebug() << "FERTIG";
deleteLater();
return true;
@@ -53,3 +51,10 @@ void Command::write(QXmlStreamWriter &xml)
xml.writeEndElement();
}
Command *Command::getNewCommand(const QString &name)
{
if (!commandHash.contains(name))
return 0;
return commandHash.value(name)();
}