[libcalamares] Additional convenience function extracting int
This commit is contained in:
parent
b828580464
commit
26dfd56f6d
@ -352,6 +352,20 @@ getString(const QVariantMap& map, const QString& key)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
getInteger( const QVariantMap& map, const QString& key, int d )
|
||||||
|
{
|
||||||
|
int result = d;
|
||||||
|
if ( map.contains( key ) )
|
||||||
|
{
|
||||||
|
auto v = map.value( key );
|
||||||
|
if ( v.type() == QVariant::Int )
|
||||||
|
result = v.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap
|
QVariantMap
|
||||||
getSubMap( const QVariantMap& map, const QString& key, bool& success )
|
getSubMap( const QVariantMap& map, const QString& key, bool& success )
|
||||||
{
|
{
|
||||||
|
@ -109,6 +109,11 @@ 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.
|
||||||
|
*/
|
||||||
|
DLLEXPORT int getInteger( const QVariantMap& map, const QString& key, int 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