2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2020-06-17 15:02:01 +02:00
|
|
|
*
|
2020-05-30 16:15:03 +02:00
|
|
|
* SPDX-FileCopyrightText: 2013-2016 Teo Mrnjavac <teo@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2018 Adriaan de Groot <groot@kde.org>
|
2020-08-10 18:21:42 +02:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2019-04-29 11:36:04 +02:00
|
|
|
*
|
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2019-04-29 11:36:04 +02:00
|
|
|
*
|
2020-05-30 16:15:03 +02:00
|
|
|
*
|
2019-04-29 11:36:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UTILS_VARIANT_H
|
|
|
|
#define UTILS_VARIANT_H
|
|
|
|
|
|
|
|
#include "DllMacro.h"
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariantMap>
|
|
|
|
|
|
|
|
namespace CalamaresUtils
|
|
|
|
{
|
2019-08-04 21:22:54 +02:00
|
|
|
/**
|
2020-06-22 00:41:21 +02:00
|
|
|
* Get a bool value from a mapping with a given key; returns @p d if no value.
|
2019-08-04 21:22:54 +02:00
|
|
|
*/
|
2020-06-22 00:41:21 +02:00
|
|
|
DLLEXPORT bool getBool( const QVariantMap& map, const QString& key, bool d = false );
|
2019-08-04 21:22:54 +02:00
|
|
|
|
|
|
|
/**
|
2020-06-22 00:41:21 +02:00
|
|
|
* Get a string value from a mapping with a given key; returns @p d if no value.
|
2019-08-04 21:22:54 +02:00
|
|
|
*/
|
2020-06-22 00:41:21 +02:00
|
|
|
DLLEXPORT QString getString( const QVariantMap& map, const QString& key, const QString& d = QString() );
|
2019-08-04 21:22:54 +02:00
|
|
|
|
2020-06-17 15:02:01 +02:00
|
|
|
/**
|
2020-06-22 00:41:21 +02:00
|
|
|
* Get a string list from a mapping with a given key; returns @p d if no value.
|
2020-06-17 15:02:01 +02:00
|
|
|
*/
|
2020-06-22 00:41:21 +02:00
|
|
|
DLLEXPORT QStringList getStringList( const QVariantMap& map, const QString& key, const QStringList& d = QStringList() );
|
2020-06-17 15:02:01 +02:00
|
|
|
|
2019-08-04 21:22:54 +02:00
|
|
|
/**
|
2020-06-22 00:41:21 +02:00
|
|
|
* Get an integer value from a mapping with a given key; returns @p d if no value.
|
2019-08-04 21:22:54 +02:00
|
|
|
*/
|
2020-08-25 23:44:08 +02:00
|
|
|
DLLEXPORT qint64 getInteger( const QVariantMap& map, const QString& key, qint64 d = 0 );
|
2019-08-04 21:22:54 +02:00
|
|
|
|
2020-03-21 19:21:16 +01:00
|
|
|
/**
|
2020-06-22 00:41:21 +02:00
|
|
|
* Get an unsigned integer value from a mapping with a given key; returns @p d if no value.
|
2020-03-21 19:21:16 +01:00
|
|
|
*/
|
2020-06-22 00:41:21 +02:00
|
|
|
DLLEXPORT quint64 getUnsignedInteger( const QVariantMap& map, const QString& key, quint64 d = 0 );
|
2020-03-21 19:21:16 +01:00
|
|
|
|
2019-08-04 21:22:54 +02:00
|
|
|
/**
|
2020-06-22 00:41:21 +02:00
|
|
|
* Get a double value from a mapping with a given key (integers are converted); returns @p d if no value.
|
2019-08-04 21:22:54 +02:00
|
|
|
*/
|
2020-06-22 00:41:21 +02:00
|
|
|
DLLEXPORT double getDouble( const QVariantMap& map, const QString& key, double d = 0.0 );
|
2019-08-04 21:22:54 +02:00
|
|
|
|
|
|
|
/**
|
2020-08-10 18:21:42 +02:00
|
|
|
* Returns a sub-map (i.e. a nested map) from a given mapping with a
|
2019-08-04 21:22:54 +02:00
|
|
|
* given key. @p success is set to true if the @p key exists
|
|
|
|
* in @p map and converts to a map, false otherwise.
|
|
|
|
*
|
2020-06-22 00:41:21 +02:00
|
|
|
* Returns @p d if there is no such key or it is not a map-value.
|
2019-08-04 21:22:54 +02:00
|
|
|
* (e.g. if @p success is false).
|
|
|
|
*/
|
2020-08-25 23:44:08 +02:00
|
|
|
DLLEXPORT QVariantMap getSubMap( const QVariantMap& map,
|
|
|
|
const QString& key,
|
|
|
|
bool& success,
|
|
|
|
const QVariantMap& d = QVariantMap() );
|
2019-08-04 21:22:54 +02:00
|
|
|
} // namespace CalamaresUtils
|
2019-04-29 11:36:04 +02:00
|
|
|
|
|
|
|
#endif
|