22 #include <QLatin1Char> 32 :m_command(
_(
"")), m_param(), m_current(0), m_commands()
34 QString line = init.trimmed();
35 unsigned int level = 0;
43 pos = line.indexOf(QLatin1Char(
'('));
47 line.remove(0, pos+1);
54 while (line.length()) {
59 if (!escaped && (c.toLatin1() ==
'\\')) {
72 switch (c.toLatin1()) {
101 line = line.trimmed();
103 qWarning(
"Parser: trailing garbage after command: '%s'",
DBG(line));
116 unsigned int level = 0;
118 QStringList commands;
119 bool escaped =
false;
121 while (line.length()) {
126 if (!escaped && (c.toLatin1() ==
'\\')) {
139 switch (c.toLatin1()) {
143 commands.append(cmd.trimmed());
161 commands.append(cmd.trimmed());
177 static const QString empty =
_(
"");
203 if (p.toLower() ==
_(
"true"))
return true;
204 if (p.toLower() ==
_(
"false"))
return false;
208 int value = p.toInt(&ok);
209 if (ok)
return (value != 0);
211 qWarning(
"Parser: invalid bool format: '%s'",
DBG(p));
220 int value = p.toInt(&ok);
223 qWarning(
"Parser: unable to parse int from '%s'",
DBG(p));
235 unsigned int value = p.toUInt(&ok);
238 qWarning(
"Parser: unable to parse unsigned int from '%s'",
DBG(p));
253 qWarning(
"Parser: unable to parse unsigned int from '%s'",
DBG(p));
266 double value = p.toDouble(&ok);
269 qWarning(
"Parser: unable to parse double from '%s'",
DBG(p));
279 static const QString special =
_(
":;<=>?[\\]^`");
282 for (QString::ConstIterator it = text.begin(); it != text.end(); ++it) {
285 if ((c.toLatin1() <
'.') || (c.toLatin1() >
'z') || special.contains(c))
297 QString result = text;
301 QRegExp rx(
_(
"[\\s\\\t\\\r\\\n]+"));
302 result.replace(rx, QChar(0x0020));
308 result.replace(QChar(0x002F), QChar(0x2044));
319 for (QString::ConstIterator it = text.begin(); it != text.end(); ++it) {
322 if (!esc && (c.toLatin1() ==
'\\')) {
344 url.setPath(QString::fromLatin1(QUrl::toPercentEncoding(parser.
command())));
349 for (
unsigned int i = 0; i <
count; ++i) {
351 if (params.length()) params +=
',';
352 params += QUrl::toPercentEncoding(param);
354 url.setQuery(QString::fromLatin1(params));
365 QString
command = QUrl::fromPercentEncoding(url.path().toLatin1());
369 QStringList
params = url.query().split(
_(
","));
370 if (!params.isEmpty()) {
372 foreach (
const QString ¶m, params) {
373 if (!first) command +=
_(
",");
374 command += QUrl::fromPercentEncoding(param.toLatin1());
sample_index_t toSampleIndex()
static QString fromUrl(const QUrl &url)
Parser(const QString &init)
static QString unescape(const QString &text)
static QString escapeForFileName(const QString &text)
QStringList splitCommands(QString &line)
static QUrl toUrl(const QString &command)
const QString & firstParam()
const QStringList & params()
QString Q_DECL_EXPORT urlScheme()
QStringList remainingParams()
unsigned int count() const
static QString escape(const QString &text)
const QString & nextParam()