1 |
// qsamplerUtilities.cpp |
// qsamplerUtilities.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2020, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
25 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
26 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
27 |
|
|
28 |
#include <QRegExp> |
#include <QRegularExpression> |
29 |
|
|
30 |
|
|
31 |
using namespace QSampler; |
using namespace QSampler; |
89 |
// replace POSIX path escape sequences (%HH) by LSCP escape sequences (\xHH) |
// replace POSIX path escape sequences (%HH) by LSCP escape sequences (\xHH) |
90 |
// TODO: missing code for other systems like Windows |
// TODO: missing code for other systems like Windows |
91 |
{ |
{ |
92 |
QRegExp regexp("%[0-9a-fA-F][0-9a-fA-F]"); |
QRegularExpression regexp("%[0-9a-fA-F][0-9a-fA-F]"); |
93 |
for (int i = path.indexOf(regexp); i >= 0; i = path.indexOf(regexp, i + 4)) |
for (int i = path.indexOf(regexp); i >= 0; i = path.indexOf(regexp, i + 4)) |
94 |
path.replace(i, 1, "\\x"); |
path.replace(i, 1, "\\x"); |
95 |
} |
} |
100 |
// replace all non-basic characters by LSCP escape sequences |
// replace all non-basic characters by LSCP escape sequences |
101 |
{ |
{ |
102 |
const char pathSeparator = '/'; |
const char pathSeparator = '/'; |
103 |
QRegExp regexp(QRegExp::escape("\\x") + "[0-9a-fA-F][0-9a-fA-F]"); |
QRegularExpression regexp(QRegularExpression::escape("\\x") + "[0-9a-fA-F][0-9a-fA-F]"); |
104 |
for (int i = 0; i < int(path.length()); i++) { |
for (int i = 0; i < int(path.length()); i++) { |
105 |
// first skip all previously added LSCP escape sequences |
// first skip all previously added LSCP escape sequences |
106 |
if (path.indexOf(regexp, i) == i) { |
if (path.indexOf(regexp, i) == i) { |
146 |
path.replace(i, 1, "%%"); |
path.replace(i, 1, "%%"); |
147 |
|
|
148 |
// resolve LSCP hex escape sequences (\xHH) |
// resolve LSCP hex escape sequences (\xHH) |
149 |
QRegExp regexp(QRegExp::escape("\\x") + "[0-9a-fA-F][0-9a-fA-F]"); |
QRegularExpression regexp(QRegularExpression::escape("\\x") + "[0-9a-fA-F][0-9a-fA-F]"); |
150 |
for (int i = path.indexOf(regexp); i >= 0; i = path.indexOf(regexp, i + 4)) { |
for (int i = path.indexOf(regexp); i >= 0; i = path.indexOf(regexp, i + 4)) { |
151 |
const QString sHex = path.mid(i + 2, 2).toLower(); |
const QString sHex = path.mid(i + 2, 2).toLower(); |
152 |
// the slash has to be escaped for POSIX as well |
// the slash has to be escaped for POSIX as well |
203 |
QString text(sText); |
QString text(sText); |
204 |
|
|
205 |
// resolve LSCP hex escape sequences (\xHH) |
// resolve LSCP hex escape sequences (\xHH) |
206 |
QRegExp regexp(QRegExp::escape("\\x") + "[0-9a-fA-F][0-9a-fA-F]"); |
QRegularExpression regexp(QRegularExpression::escape("\\x") + "[0-9a-fA-F][0-9a-fA-F]"); |
207 |
for (int i = text.indexOf(regexp); i >= 0; i = text.indexOf(regexp, i + 4)) { |
for (int i = text.indexOf(regexp); i >= 0; i = text.indexOf(regexp, i + 4)) { |
208 |
const QString sHex = text.mid(i + 2, 2).toLower(); |
const QString sHex = text.mid(i + 2, 2).toLower(); |
209 |
// decode into raw ASCII character |
// decode into raw ASCII character |