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