Skip to content
Snippets Groups Projects
Commit 859b2180 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

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: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 05ade413
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment