[libcalamares] Additional convenience for doubles
This commit is contained in:
parent
26dfd56f6d
commit
778feb50e8
@ -366,6 +366,22 @@ getInteger( const QVariantMap& map, const QString& key, int d )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
getDouble( const QVariantMap& map, const QString& key, double d )
|
||||||
|
{
|
||||||
|
double result = d;
|
||||||
|
if ( map.contains( key ) )
|
||||||
|
{
|
||||||
|
auto v = map.value( key );
|
||||||
|
if ( v.type() == QVariant::Int )
|
||||||
|
result = v.toInt();
|
||||||
|
else if ( v.type() == QVariant::Double )
|
||||||
|
result = v.toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap
|
QVariantMap
|
||||||
getSubMap( const QVariantMap& map, const QString& key, bool& success )
|
getSubMap( const QVariantMap& map, const QString& key, bool& success )
|
||||||
{
|
{
|
||||||
|
@ -110,10 +110,15 @@ namespace CalamaresUtils
|
|||||||
DLLEXPORT QString getString( const QVariantMap& map, const QString& key );
|
DLLEXPORT QString getString( const QVariantMap& map, const QString& key );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an integer value from a mapping; returns @p default if no value.
|
* Get an integer value from a mapping; returns @p d if no value.
|
||||||
*/
|
*/
|
||||||
DLLEXPORT int getInteger( const QVariantMap& map, const QString& key, int d );
|
DLLEXPORT int getInteger( const QVariantMap& map, const QString& key, int d );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a double value from a mapping (integers are converted); returns @p d if no value.
|
||||||
|
*/
|
||||||
|
DLLEXPORT double getDouble( const QVariantMap& map, const QString& key, double d );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a sub-map (i.e. a nested map) from the given mapping with the
|
* Returns a sub-map (i.e. a nested map) from the given mapping with the
|
||||||
* given key. @p success is set to true if the @p key exists
|
* given key. @p success is set to true if the @p key exists
|
||||||
|
Loading…
Reference in New Issue
Block a user