author | insilmaril |
Fri, 08 Jul 2005 07:24:43 +0000 | |
changeset 118 | d18eb6939d17 |
parent 106 | 4083860dd82e |
child 132 | fd7f08a85971 |
permissions | -rw-r--r-- |
insilmaril@105 | 1 |
#include "api.h" |
insilmaril@105 | 2 |
|
insilmaril@105 | 3 |
#include <qregexp.h> |
insilmaril@105 | 4 |
|
insilmaril@105 | 5 |
void API::parseCommand (const QString &s,QString &command,QString |
insilmaril@105 | 6 |
¶m) |
insilmaril@105 | 7 |
{ |
insilmaril@105 | 8 |
param=""; |
insilmaril@105 | 9 |
command=""; |
insilmaril@105 | 10 |
QRegExp re; |
insilmaril@105 | 11 |
int pos; |
insilmaril@105 | 12 |
|
insilmaril@105 | 13 |
// Get command |
insilmaril@105 | 14 |
re.setPattern ("(.*)\\s"); |
insilmaril@106 | 15 |
re.setMinimal (true); |
insilmaril@105 | 16 |
pos=re.search (s); |
insilmaril@105 | 17 |
if (pos>=0) |
insilmaril@105 | 18 |
command=re.cap(1); |
insilmaril@105 | 19 |
|
insilmaril@105 | 20 |
// Get parameters |
insilmaril@105 | 21 |
re.setPattern ("\\((.*)\\)"); |
insilmaril@105 | 22 |
pos=re.search (s); |
insilmaril@105 | 23 |
if (pos>=0) |
insilmaril@105 | 24 |
param=re.cap (1); |
insilmaril@105 | 25 |
} |
insilmaril@105 | 26 |
|
insilmaril@105 | 27 |
void API::getString (const QString &s, QString &rs) |
insilmaril@105 | 28 |
{ |
insilmaril@105 | 29 |
// return the string in s, this could be also stored in |
insilmaril@105 | 30 |
// a variable later |
insilmaril@105 | 31 |
QRegExp re("\"(.*)\""); |
insilmaril@105 | 32 |
int pos=re.search (s); |
insilmaril@105 | 33 |
if (pos>=0) |
insilmaril@105 | 34 |
rs=re.cap (1); |
insilmaril@105 | 35 |
else |
insilmaril@105 | 36 |
rs=""; |
insilmaril@105 | 37 |
|
insilmaril@105 | 38 |
} |