QPIConfig multiline support

This commit is contained in:
2020-05-23 21:42:00 +03:00
parent 8dd574fef1
commit 0418638fc9
3 changed files with 40 additions and 17 deletions

2
pip

Submodule pip updated: a5809d5f39...21f8a035d8

View File

@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(qad)
set(_QAD_MAJOR 1)
set(_QAD_MINOR 2)
set(_QAD_REVISION 0)
set(_QAD_REVISION 1)
set(_QAD_SUFFIX beta)
set(_QAD_COMPANY SHS)
set(_QAD_DOMAIN org.SHS)

View File

@@ -243,6 +243,7 @@ QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode, QPIConfig::
type = type_;
if (!path.isEmpty()) {
open(mode);
incdirs << QFileInfo(path).absoluteDir().path();
parse();
}
}
@@ -253,6 +254,7 @@ QPIConfig::QPIConfig(const QString & path, QIODevice::OpenMode mode): QFile(path
type = Config;
if (!path.isEmpty()) {
open(mode);
incdirs << QFileInfo(path).absoluteDir().path();
parse();
}
}
@@ -263,6 +265,7 @@ QPIConfig::QPIConfig(const QString & path, QPIConfig::FileType type_): QFile(pat
type = type_;
if (!path.isEmpty()) {
open(QIODevice::ReadWrite);
incdirs << QFileInfo(path).absoluteDir().path();
parse();
}
}
@@ -748,9 +751,9 @@ void QPIConfig::parse(QString content) {
root.clear();
QString src, str, tab, comm, all, name, type, prefix, tprefix;
QStringList tree;
Entry * entry, * te, * ce;
Entry * entry = 0, * te = 0, * ce = 0;
int ind, sind;
bool isNew, isPrefix;
bool isNew = false, isPrefix = false, wasMultiline = false, isMultiline = false;
foreach (QPIConfig * c, inc_devs)
delete c;
inc_devs.clear();
@@ -781,22 +784,42 @@ void QPIConfig::parse(QString content) {
tab = str.left(str.indexOf(str.trimmed().left(1)));
str = str.trimmed();
all = str;
sind = str.indexOf('#');
if (sind > 0) {
comm = str.mid(sind + 1).trimmed();
if (comm.length() > 0) {
type = comm[0];
comm = comm.mid(1).trimmed();
} else type = "s";
str = str.left(sind).trimmed();
} else {
type = "s";
comm = "";
}
if (str.endsWith("\\")) {
isMultiline = true;
str.chop(1);
str = str.trimmed();
} else
isMultiline = false;
if (wasMultiline) {
wasMultiline = false;
if (ce) {
ce->_value += str;
ce->_all += "\\\n" + all;
}
str.clear();
}
wasMultiline = isMultiline;
ind = str.indexOf('=');
if ((ind > 0) && !(str[0] == '#')) {
sind = str.indexOf('#');
if (sind > 0) {
comm = str.right(str.length() - sind - 1).trimmed();
if (comm.length() > 0) type = comm[0];
else type = "s";
comm = comm.right(comm.length() - 1).trimmed();
str = str.left(sind);
} else {
type = "s";
comm = "";
}
tree = (prefix + str.left(ind).trimmed()).split(delim);
if (tree.front() == "include") {
name = str.right(str.length() - ind - 1).trimmed();
name = str.mid(ind + 1).trimmed();
QPIConfig * iconf = new QPIConfig(name, incdirs);
if (!iconf->dev) {
delete iconf;
@@ -832,7 +855,7 @@ void QPIConfig::parse(QString content) {
ce->delim = delim;
ce->_tab = tab;
ce->_name = name;
ce->_value = str.right(str.length() - ind - 1).trimmed();
ce->_value = str.mid(ind + 1).trimmed();
ce->_type = type;
ce->_comment = comm;
ce->_line = lines;