forked from qt-creator/qt-creator
Utils: Iterate environment via callback
Iterators expose the underlying datastructure and get in the way of moving towards "env as stack of changes" Task-number: QTCREATORBUG-28357 Change-Id: I69e3b53e62ed4c9ab394779e97afbc6fd1986838 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -24,6 +24,12 @@ NameValueItems Environment::diff(const Environment &other, bool checkAppendPrepe
|
|||||||
return m_dict.diff(other.m_dict, checkAppendPrepend);
|
return m_dict.diff(other.m_dict, checkAppendPrepend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Environment::forEachEntry(const std::function<void(const QString &, const QString &, bool)> &callBack) const
|
||||||
|
{
|
||||||
|
for (auto it = m_dict.m_values.constBegin(); it != m_dict.m_values.constEnd(); ++it)
|
||||||
|
callBack(it.key().name, it.value().first, it.value().second);
|
||||||
|
}
|
||||||
|
|
||||||
bool Environment::hasChanges() const
|
bool Environment::hasChanges() const
|
||||||
{
|
{
|
||||||
return m_dict.size() != 0;
|
return m_dict.size() != 0;
|
||||||
|
@@ -93,6 +93,8 @@ public:
|
|||||||
const_iterator constEnd() const { return m_dict.constEnd(); } // FIXME: avoid
|
const_iterator constEnd() const { return m_dict.constEnd(); } // FIXME: avoid
|
||||||
const_iterator constFind(const QString &name) const { return m_dict.constFind(name); } // FIXME: avoid
|
const_iterator constFind(const QString &name) const { return m_dict.constFind(name); } // FIXME: avoid
|
||||||
|
|
||||||
|
void forEachEntry(const std::function<void (const QString &, const QString &, bool)> &callBack) const;
|
||||||
|
|
||||||
friend bool operator!=(const Environment &first, const Environment &second)
|
friend bool operator!=(const Environment &first, const Environment &second)
|
||||||
{
|
{
|
||||||
return first.m_dict != second.m_dict;
|
return first.m_dict != second.m_dict;
|
||||||
|
Reference in New Issue
Block a user