00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CMDINTERPRETER_H__
00019 #define __CMDINTERPRETER_H__
00020
00021 #include <qobject.h>
00022 #include <qstringlist.h>
00023 #include <qlist.h>
00024 #include <qprocess.h>
00025
00027 typedef bool (*cmd_func)(QString &args);
00028
00036 class CmdInterpreter : public QObject
00037 {
00038 Q_OBJECT
00039 public:
00041 CmdInterpreter(QObject *parent);
00043 bool exec(const QString &cmd);
00046 void registerFunc(QString name, cmd_func func);
00048 void registerCmd(QString startToken, cmd_func func);
00050 QStringList &commands();
00052 QString readLineStdout();
00054 QString readLineStderr();
00056 bool canReadLineStdout();
00058 bool canReadLineStderr();
00059 public slots:
00060 void kill();
00061 signals:
00062 void readyReadStdout();
00063 void readyReadStderr();
00064 void processExited();
00065 private:
00067 QStringList __commands;
00069 static QProcess proc;
00070 };
00071
00072 #endif