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

@@ -2,6 +2,7 @@
#include <QDebug>
#include "widget.h"
#include "protocol.h"
#include "protocol_commands.h"
Widget::Widget()
: QMainWindow(), currentCommand(0)
@@ -24,6 +25,8 @@ Widget::Widget()
QWidget *central = new QWidget;
central->setLayout(vbox);
setCentralWidget(central);
Command::initializeHash();
}
void Widget::startClicked()
@@ -31,6 +34,7 @@ void Widget::startClicked()
currentCommand = 0;
xmlWriter.writeStartDocument();
xmlWriter.writeStartElement("cockatrice_communication");
xmlWriter.writeAttribute("version", "4");
Command *test = new Command_Ping;
test->write(xmlWriter);
@@ -63,13 +67,8 @@ void Widget::parseXml()
if (xmlReader.isStartElement()) {
QString cmdStr = xmlReader.name().toString();
qDebug() << "parseXml: startElement: " << cmdStr;
if (cmdStr == "ping")
currentCommand = new Command_Ping;
else if (cmdStr == "chat_leave_channel")
currentCommand = new Command_ChatLeaveChannel;
else if (cmdStr == "chat_say")
currentCommand = new Command_ChatSay;
else
currentCommand = Command::getNewCommand(cmdStr);
if (!currentCommand)
qDebug() << "unrecognized command";
readCurrentCommand();
}