2011-10-14 15:22:24 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
class QIODevice;
|
2012-03-21 23:30:43 +00:00
|
|
|
class CommandFactory;
|
|
|
|
class Command;
|
2011-10-14 15:22:24 +00:00
|
|
|
|
|
|
|
class CommandParser : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-03-21 23:30:43 +00:00
|
|
|
CommandParser(QIODevice *device, CommandFactory *commandFactory, QObject *parent = 0);
|
2011-10-14 15:22:24 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void checkNext();
|
|
|
|
|
|
|
|
signals:
|
2012-03-21 23:30:43 +00:00
|
|
|
void commandReady(Command *command);
|
2011-10-14 15:22:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void readLine();
|
|
|
|
void readDataBlock();
|
|
|
|
void processNext(const char *line);
|
|
|
|
void processArgument(const char *data);
|
2012-03-21 23:30:43 +00:00
|
|
|
void reset();
|
2011-10-14 15:22:24 +00:00
|
|
|
QIODevice *m_device;
|
|
|
|
QString m_commandName;
|
|
|
|
QStringList m_arguments;
|
|
|
|
int m_argumentsExpected;
|
|
|
|
int m_expectingDataSize;
|
2012-03-21 23:30:43 +00:00
|
|
|
CommandFactory *m_commandFactory;
|
2011-10-14 15:22:24 +00:00
|
|
|
};
|
|
|
|
|