move some functions into ProStringList for saner OO design
Change-Id: I60f00f38f459fc9f8eebee9187158e4198fc9546 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
parent
f76d14673f
commit
ab74cf09a8
@ -386,6 +386,20 @@ void ProStringList::removeAll(const char *str)
|
||||
remove(i);
|
||||
}
|
||||
|
||||
void ProStringList::removeEach(const ProStringList &value)
|
||||
{
|
||||
foreach (const ProString &str, value)
|
||||
if (!str.isEmpty())
|
||||
removeAll(str);
|
||||
}
|
||||
|
||||
void ProStringList::removeEmpty()
|
||||
{
|
||||
for (int i = size(); --i >= 0;)
|
||||
if (at(i).isEmpty())
|
||||
remove(i);
|
||||
}
|
||||
|
||||
void ProStringList::removeDuplicates()
|
||||
{
|
||||
int n = size();
|
||||
@ -405,6 +419,13 @@ void ProStringList::removeDuplicates()
|
||||
erase(begin() + j, end());
|
||||
}
|
||||
|
||||
void ProStringList::insertUnique(const ProStringList &value)
|
||||
{
|
||||
foreach (const ProString &str, value)
|
||||
if (!str.isEmpty() && !contains(str))
|
||||
append(str);
|
||||
}
|
||||
|
||||
ProStringList::ProStringList(const QStringList &list)
|
||||
{
|
||||
reserve(list.size());
|
||||
|
@ -239,9 +239,13 @@ public:
|
||||
QString join(const QString &sep) const;
|
||||
QString join(QChar sep) const;
|
||||
|
||||
void insertUnique(const ProStringList &value);
|
||||
|
||||
void removeAll(const ProString &str);
|
||||
void removeAll(const char *str);
|
||||
void removeEach(const ProStringList &value);
|
||||
void removeAt(int idx) { remove(idx); }
|
||||
void removeEmpty();
|
||||
void removeDuplicates();
|
||||
|
||||
bool contains(const ProString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
|
@ -1687,7 +1687,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
||||
if (mode == CacheAdd)
|
||||
newval += diffval;
|
||||
else
|
||||
removeEach(&newval, diffval);
|
||||
newval.removeEach(diffval);
|
||||
}
|
||||
if (oldval != newval) {
|
||||
if (target != TargetStash || !m_stashfile.isEmpty()) {
|
||||
|
@ -350,34 +350,6 @@ ProStringList QMakeEvaluator::split_value_list(const QString &vals, const ProFil
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void zipEmpty(ProStringList *value)
|
||||
{
|
||||
for (int i = value->size(); --i >= 0;)
|
||||
if (value->at(i).isEmpty())
|
||||
value->remove(i);
|
||||
}
|
||||
|
||||
static void insertUnique(ProStringList *varlist, const ProStringList &value)
|
||||
{
|
||||
foreach (const ProString &str, value)
|
||||
if (!str.isEmpty() && !varlist->contains(str))
|
||||
varlist->append(str);
|
||||
}
|
||||
|
||||
static void removeAll(ProStringList *varlist, const ProString &value)
|
||||
{
|
||||
for (int i = varlist->size(); --i >= 0; )
|
||||
if (varlist->at(i) == value)
|
||||
varlist->remove(i);
|
||||
}
|
||||
|
||||
void QMakeEvaluator::removeEach(ProStringList *varlist, const ProStringList &value)
|
||||
{
|
||||
foreach (const ProString &str, value)
|
||||
if (!str.isEmpty())
|
||||
removeAll(varlist, str);
|
||||
}
|
||||
|
||||
static void replaceInList(ProStringList *varlist,
|
||||
const QRegExp ®exp, const QString &replace, bool global, QString &tmp)
|
||||
{
|
||||
@ -916,24 +888,24 @@ void QMakeEvaluator::visitProVariable(
|
||||
switch (tok) {
|
||||
default: // whatever - cannot happen
|
||||
case TokAssign: // =
|
||||
zipEmpty(&varVal);
|
||||
varVal.removeEmpty();
|
||||
// FIXME: add check+warning about accidental value removal.
|
||||
// This may be a bit too noisy, though.
|
||||
m_valuemapStack.top()[varName] = varVal;
|
||||
debugMsg(2, "assigning");
|
||||
break;
|
||||
case TokAppendUnique: // *=
|
||||
insertUnique(&valuesRef(varName), varVal);
|
||||
valuesRef(varName).insertUnique(varVal);
|
||||
debugMsg(2, "appending unique");
|
||||
break;
|
||||
case TokAppend: // +=
|
||||
zipEmpty(&varVal);
|
||||
varVal.removeEmpty();
|
||||
valuesRef(varName) += varVal;
|
||||
debugMsg(2, "appending");
|
||||
break;
|
||||
case TokRemove: // -=
|
||||
if (!m_cumulative) {
|
||||
removeEach(&valuesRef(varName), varVal);
|
||||
valuesRef(varName).removeEach(varVal);
|
||||
} else {
|
||||
// We are stingy with our values.
|
||||
}
|
||||
|
@ -243,8 +243,6 @@ public:
|
||||
#endif
|
||||
QByteArray getCommandOutput(const QString &args) const;
|
||||
|
||||
static void removeEach(ProStringList *varlist, const ProStringList &value);
|
||||
|
||||
QMakeEvaluator *m_caller;
|
||||
#ifdef PROEVALUATOR_CUMULATIVE
|
||||
bool m_cumulative;
|
||||
|
Loading…
x
Reference in New Issue
Block a user