13 void Parser::initCommand()
20 void Parser::parseAtom (const QString &s)
28 re.setPattern ("\\b(.*)(\\s|\\()");
36 re.setPattern ("\\((.*)\\)");
38 //cout << " s="<<s.ascii()<<endl;
39 //cout << "com="<<com.ascii()<<" pos="<<pos<<endl<<endl;
48 while (pos<s.length())
58 if (s.at(pos)==',' && !inquote)
62 s=s.right(s.length()-pos-1);
73 QString Parser::command()
78 QStringList Parser::parameters()
83 int Parser::paramCount()
85 return paramList.count();
89 QString Parser::errorMessage()
94 case NoError: l="No Error";
95 case Warning: l="Warning";
96 case Aborted: l="Aborted";
98 return QString ("Error Level: %1\n Command: %2\nDescription: %3")
99 .arg(l).arg(com).arg(errDescription);
102 QString Parser::errorDescription()
104 return errDescription;
107 ErrorLevel Parser::errorLevel()
112 void Parser::setError(ErrorLevel level, const QString &description)
114 errDescription=description;
118 void Parser::resetError ()
126 bool Parser::checkParamCount (QList <int> plist)
130 for (int i=0; i<plist.count();i++)
132 if (checkParamCount (plist[i]))
137 expList.append(QString().setNum(plist[i]));
139 expected=expList.join(",");
140 errDescription=QString("Wrong number of parameters: Expected %1, but found %2").arg(expected).arg(paramList.count());
144 bool Parser::checkParamCount (const int &expected)
146 if (paramList.count()!=expected)
149 errDescription=QString("Wrong number of parameters: Expected %1, but found %2").arg(expected).arg(paramList.count());
155 bool Parser::checkParamIsInt(const int &index)
158 if (index > paramList.count())
161 errDescription=QString("Parameter index %1 is outside of parameter list").arg(index);
165 paramList[index].toInt (&ok, 10);
169 errDescription=QString("Parameter %1 is not an integer").arg(index);
176 int Parser::parInt (bool &ok,const uint &index)
178 if (checkParamIsInt (index))
179 return paramList[index].toInt (&ok, 10);
184 QString Parser::parString (bool &ok,const int &index)
186 // return the string at index, this could be also stored in
189 QRegExp re("\"(.*)\"");
190 int pos=re.search (paramList[index]);
199 bool Parser::parBool (bool &ok,const int &index)
201 // return the bool at index, this could be also stored in
205 QString p=paramList[index];
206 if (p=="true" || p=="1")
208 else if (p=="false" || p=="0")
214 QColor Parser::parColor(bool &ok,const int &index)
216 // return the QColor at index
218 return QColor (paramList[index]);
221 void Parser::setScript(const QString &s)
226 QString Parser::getScript()
231 void Parser::startScript()