forked from qt-creator/qt-creator
CMake: Small improvements to the CMakeConfigItem
* Add a method to more easily get values from list of ConfigItems * Cleanup message signature Change-Id: I728b7c8f5c382fe4a9bf2e3b8636d63db3d07881 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -42,7 +42,7 @@ CMakeConfigItem::CMakeConfigItem(const CMakeConfigItem &other) :
|
||||
value(other.value), documentation(other.documentation)
|
||||
{ }
|
||||
|
||||
CMakeConfigItem::CMakeConfigItem(const QByteArray &k, CMakeConfigItem::Type &t,
|
||||
CMakeConfigItem::CMakeConfigItem(const QByteArray &k, Type t,
|
||||
const QByteArray &d, const QByteArray &v) :
|
||||
key(k), type(t), value(v), documentation(d)
|
||||
{ }
|
||||
@@ -51,6 +51,15 @@ CMakeConfigItem::CMakeConfigItem(const QByteArray &k, const QByteArray &v) :
|
||||
key(k), value(v)
|
||||
{ }
|
||||
|
||||
QByteArray CMakeConfigItem::valueOf(const QByteArray &key, const QList<CMakeConfigItem> &input)
|
||||
{
|
||||
for (auto it = input.constBegin(); it != input.constEnd(); ++it) {
|
||||
if (it->key == key)
|
||||
return it->value;
|
||||
}
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
std::function<bool (const CMakeConfigItem &a, const CMakeConfigItem &b)> CMakeConfigItem::sortOperator()
|
||||
{
|
||||
return [](const CMakeConfigItem &a, const CMakeConfigItem &b) { return a.key < b.key; };
|
||||
|
||||
@@ -37,9 +37,11 @@ public:
|
||||
enum Type { FILEPATH, PATH, BOOL, STRING, INTERNAL };
|
||||
CMakeConfigItem();
|
||||
CMakeConfigItem(const CMakeConfigItem &other);
|
||||
CMakeConfigItem(const QByteArray &k, Type &t, const QByteArray &d, const QByteArray &v);
|
||||
CMakeConfigItem(const QByteArray &k, Type t, const QByteArray &d, const QByteArray &v);
|
||||
CMakeConfigItem(const QByteArray &k, const QByteArray &v);
|
||||
|
||||
static QByteArray valueOf(const QByteArray &key, const QList<CMakeConfigItem> &input);
|
||||
|
||||
bool isNull() const { return key.isEmpty(); }
|
||||
|
||||
static std::function<bool(const CMakeConfigItem &a, const CMakeConfigItem &b)> sortOperator();
|
||||
|
||||
Reference in New Issue
Block a user