Remove the comments from qss

This commit is contained in:
Klaus Basan
2019-04-11 01:17:18 +02:00
committed by Mat Sutcliffe
parent dd37c7b876
commit d875df6fc7
3 changed files with 17 additions and 1 deletions

View File

@@ -151,7 +151,7 @@ namespace BlackGui
{
if (needsWatcher) { m_fileWatcher.addPath(absolutePath); }
QTextStream in(&file);
const QString c = in.readAll();
const QString c = removeComments(in.readAll(), true, true);
const QString f = fileInfo.fileName().toLower();
// keep even empty files as placeholders

View File

@@ -433,6 +433,19 @@ namespace BlackMisc
return in;
}
QString removeComments(const QString &in, bool removeSlashStar, bool removeDoubleSlash)
{
QString copy(in);
thread_local const QRegularExpression re1("\\/\\*(.|\\n)*?\\*\\/");
if (removeSlashStar) { copy.remove(re1); }
thread_local const QRegularExpression re2("\\/\\/.*");
if (removeDoubleSlash) { copy.remove(re2); }
return copy;
}
} // ns
//! \endcond

View File

@@ -289,6 +289,9 @@ namespace BlackMisc
//! Convert string to bool
BLACKMISC_EXPORT QString joinStringSet(const QSet<QString> &set, const QString &separator);
//! Remove comments such as /** **/ or //
BLACKMISC_EXPORT QString removeComments(const QString &in, bool removeSlash, bool removeDoubleSlash);
namespace Mixin
{
/*!