Skip to content
Permalink
Browse files

Returns only defined parameters in toMap()

  • Loading branch information
pblottiere committed Jun 28, 2018
1 parent bbf7a78 commit c1c92a657ad50167fabb5e6bf4e303cadda2f343
Showing with 18 additions and 9 deletions.
  1. +17 −9 src/server/qgsserverparameters.cpp
  2. +1 −0 src/server/qgsserverparameters.h
@@ -23,35 +23,40 @@ QgsServerParameters::QgsServerParameters()
const Parameter pService = { ParameterName::SERVICE,
QVariant::String,
QVariant( "" ),
QVariant()
QVariant(),
false
};
save( pService );

const Parameter pRequest = { ParameterName::REQUEST,
QVariant::String,
QVariant( "" ),
QVariant()
QVariant(),
false
};
save( pRequest );

const Parameter pVersion = { ParameterName::VERSION_SERVICE,
QVariant::String,
QVariant( "" ),
QVariant()
QVariant(),
false
};
save( pService );
save( pVersion );

const Parameter pMap = { ParameterName::MAP,
QVariant::String,
QVariant( "" ),
QVariant()
QVariant(),
false
};
save( pMap );

const Parameter pFile = { ParameterName::FILE_NAME,
QVariant::String,
QVariant( "" ),
QVariant()
QVariant(),
false
};
save( pFile );
}
@@ -142,8 +147,11 @@ QMap<QString, QString> QgsServerParameters::toMap() const

for ( auto parameter : mParameters.toStdMap() )
{
const QString name = metaEnum.valueToKey( parameter.first );
params[name] = parameter.second.mValue.toString();
if ( ! parameter.second.mDefined )
continue;

const QString paramName = name( parameter.first );
params[paramName] = parameter.second.mValue.toString();
}

return params;
@@ -180,7 +188,7 @@ void QgsServerParameters::load( const QUrlQuery &query )
{
const QVariant value( item.second );
mParameters[paramName].mValue = value;

mParameters[paramName].mDefined = true;
if ( !value.canConvert( mParameters[paramName].mType ) )
{
raiseError( paramName );
@@ -50,6 +50,7 @@ class SERVER_EXPORT QgsServerParameters
QVariant::Type mType;
QVariant mDefaultValue;
QVariant mValue;
bool mDefined;
};

/**

0 comments on commit c1c92a6

Please sign in to comment.
You can’t perform that action at this time.