Skip to content

Commit

Permalink
Add a remove method thanks to enum value
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Jul 23, 2018
1 parent 6e1f14b commit f55d9c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/server/qgsserverparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,28 @@ QgsServerParameter::QgsServerParameter( const QgsServerParameter::Name name,

QString QgsServerParameter::name( const QgsServerParameter::Name name )
{
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerParameter::Name>() );
return metaEnum.valueToKey( name );
if ( name == QgsServerParameter::VERSION_SERVICE )
{
return QStringLiteral( "VERSION" );
}
else
{
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerParameter::Name>() );
return metaEnum.valueToKey( name );
}
}

QgsServerParameter::Name QgsServerParameter::name( const QString &name )
{
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerParameter::Name>() );
return ( QgsServerParameter::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
if ( name.compare( QStringLiteral( "VERSION" ) ) == 0 )
{
return QgsServerParameter::VERSION_SERVICE;
}
else
{
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerParameter::Name>() );
return ( QgsServerParameter::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
}
}

void QgsServerParameter::raiseError() const
Expand Down Expand Up @@ -318,6 +332,11 @@ QUrlQuery QgsServerParameters::urlQuery() const
return query;
}

void QgsServerParameters::remove( QgsServerParameter::Name name )
{
remove( QgsServerParameter::name( name ) );
}

void QgsServerParameters::remove( const QString &key )
{
if ( mUnmanagedParameters.contains( key ) )
Expand Down
2 changes: 2 additions & 0 deletions src/server/qgsserverparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class SERVER_EXPORT QgsServerParameters
*/
void remove( const QString &key );

void remove( QgsServerParameter::Name name );

/**
* Returns the value of a parameter.
* \param key the name of the parameter
Expand Down

0 comments on commit f55d9c1

Please sign in to comment.