api.cpp
author insilmaril
Mon, 06 Jun 2005 20:27:42 +0000
changeset 105 67a91e28b30f
child 106 4083860dd82e
permissions -rw-r--r--
1.6.8 started API to speedup undos
     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 (false);
    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 }