color collection, now only CSS colors
PIVariantTypes::Color from/to string (with CSS names)
This commit is contained in:
@@ -26,34 +26,20 @@
|
||||
const char _attribute_[] = "_attribute_";
|
||||
|
||||
PIString unmask(const PIString & str) {
|
||||
PIString ret;
|
||||
for (int i = 0; i < str.size_s(); ++i) {
|
||||
if (str[i] == '\\') {
|
||||
if (i < str.size_s() - 1) {
|
||||
++i;
|
||||
ret += str[i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ret += str[i];
|
||||
}
|
||||
PIString ret(str);
|
||||
ret.unmask("#\\");
|
||||
if (ret.isNotEmpty())
|
||||
if (ret[0] == '\\')
|
||||
ret.remove(0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PIString mask(const PIString & str) {
|
||||
PIString ret = str;
|
||||
if (ret.isEmpty()) return ret;
|
||||
int start = 0;
|
||||
if (ret[0].isSpace()) {
|
||||
ret.mask("#\\");
|
||||
if (ret[0].isSpace())
|
||||
ret.insert(0, '\\');
|
||||
start = 1;
|
||||
}
|
||||
for (int i = start; i < ret.size_s(); ++i) {
|
||||
if (ret[i] == '\\') {
|
||||
ret.insert(i, '\\');
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -158,7 +144,7 @@ PIValueTree PIValueTreeConversions::fromText(PIIODevice * device) {
|
||||
continue;
|
||||
}
|
||||
line += l;
|
||||
//piCout << line.replacedAll("\n", "\\n");
|
||||
//piCout << "L" << line.replacedAll("\n", "\\n");
|
||||
if (line.size() < 2) {
|
||||
line.clear();
|
||||
continue;
|
||||
@@ -168,11 +154,22 @@ PIValueTree PIValueTreeConversions::fromText(PIIODevice * device) {
|
||||
line.clear();
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith('#')) {
|
||||
line.clear();
|
||||
continue;
|
||||
}
|
||||
type = PIVariant::typeName<PIString>();
|
||||
comm.clear();
|
||||
int ind = line.find('#');
|
||||
if (ind >= 0) {
|
||||
comm = line.takeMid(ind + 1);
|
||||
int ind = -1, cind = -1;
|
||||
for (;;) {
|
||||
ind = line.find('#', ind + 1);
|
||||
if (ind < 0) break;
|
||||
if (ind > 0)
|
||||
if (line[ind - 1] == '\\') continue;
|
||||
cind = ind;
|
||||
}
|
||||
if (cind >= 0) {
|
||||
comm = line.takeMid(cind + 1);
|
||||
bool typed = false;
|
||||
if (comm.isNotEmpty()) {
|
||||
if (comm.size() == 1) typed = true;
|
||||
@@ -196,7 +193,7 @@ PIValueTree PIValueTreeConversions::fromText(PIIODevice * device) {
|
||||
line.cutRight(1).trim();
|
||||
}
|
||||
ind = line.find('=');
|
||||
if ((ind > 0) && (line[0] != '#')) {
|
||||
if (ind > 0) {
|
||||
path = prefix;
|
||||
path << line.takeLeft(ind).split('.').trim();
|
||||
line.cutLeft(1).trim();
|
||||
@@ -213,6 +210,9 @@ PIValueTree PIValueTreeConversions::fromText(PIIODevice * device) {
|
||||
}
|
||||
other.back() = src;*/
|
||||
}
|
||||
} else {
|
||||
line.clear();
|
||||
continue;
|
||||
}
|
||||
//piCout << path << line << comm;
|
||||
PIValueTree & leaf(ret[path]);
|
||||
|
||||
Reference in New Issue
Block a user