QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
QgsServerQueryStringParameter Class Reference

The QgsServerQueryStringParameter class holds the information regarding a query string input parameter and its validation. More...

#include <qgsserverquerystringparameter.h>

Public Types

enum class  Type {
  String = QVariant::String , Integer = QVariant::LongLong , Double = QVariant::Double , Boolean = QVariant::Bool ,
  List = QVariant::StringList
}
 The Type enum represents the parameter type. More...
 

Public Member Functions

 QgsServerQueryStringParameter (const QString name, bool required=false, Type type=QgsServerQueryStringParameter::Type::String, const QString &description=QString(), const QVariant &defaultValue=QVariant())
 Constructs a QgsServerQueryStringParameter object. More...
 
virtual ~QgsServerQueryStringParameter ()
 
json data () const
 Returns the handler information as a JSON object. More...
 
QString description () const
 Returns parameter description. More...
 
bool hidden () const
 Returns true if the parameter is hidden from the schema. More...
 
QString name () const
 Returns the name of the parameter. More...
 
void setCustomValidator (const customValidator &customValidator)
 Sets the custom validation function to customValidator. More...
 
void setDescription (const QString &description)
 Sets validator description. More...
 
void setHidden (bool hidden)
 Set the parameter's hidden status, parameters are not hidden by default. More...
 
virtual QVariant value (const QgsServerApiContext &context) const
 Extracts the value from the request context by validating the parameter value and converting it to its proper Type. More...
 

Static Public Member Functions

static QString typeName (const Type type)
 Returns the name of the type. More...
 

Friends

class TestQgsServerQueryStringParameter
 

Detailed Description

The QgsServerQueryStringParameter class holds the information regarding a query string input parameter and its validation.

The class is extendable through custom validators (C++ only) and/or by subclassing and overriding the value() method.

Since
QGIS 3.10

Definition at line 47 of file qgsserverquerystringparameter.h.

Member Enumeration Documentation

◆ Type

The Type enum represents the parameter type.

Enumerator
String 
Integer 

parameter is a string

Double 

parameter is an integer

Boolean 

parameter is a double

List 

parameter is a boolean

Definition at line 60 of file qgsserverquerystringparameter.h.

Constructor & Destructor Documentation

◆ QgsServerQueryStringParameter()

QgsServerQueryStringParameter::QgsServerQueryStringParameter ( const QString  name,
bool  required = false,
QgsServerQueryStringParameter::Type  type = QgsServerQueryStringParameter::Type::String,
const QString &  description = QString(),
const QVariant &  defaultValue = QVariant() 
)

Constructs a QgsServerQueryStringParameter object.

Parameters
nameparameter name
required
typethe parameter type
descriptionparameter description
defaultValuedefault value, it is ignored if the parameter is required

Definition at line 22 of file qgsserverquerystringparameter.cpp.

◆ ~QgsServerQueryStringParameter()

QgsServerQueryStringParameter::~QgsServerQueryStringParameter ( )
virtual

Definition at line 35 of file qgsserverquerystringparameter.cpp.

Member Function Documentation

◆ data()

json QgsServerQueryStringParameter::data ( ) const

Returns the handler information as a JSON object.

Definition at line 116 of file qgsserverquerystringparameter.cpp.

◆ description()

QString QgsServerQueryStringParameter::description ( ) const

Returns parameter description.

Definition at line 142 of file qgsserverquerystringparameter.cpp.

◆ hidden()

bool QgsServerQueryStringParameter::hidden ( ) const

Returns true if the parameter is hidden from the schema.

Hidden params can be useful to implement legacy parameters or parameters that can be accepted without being advertised.

Since
QGIS 3.28

Definition at line 163 of file qgsserverquerystringparameter.cpp.

◆ name()

QString QgsServerQueryStringParameter::name ( ) const

Returns the name of the parameter.

Definition at line 153 of file qgsserverquerystringparameter.cpp.

◆ setCustomValidator()

void QgsServerQueryStringParameter::setCustomValidator ( const customValidator &  customValidator)

Sets the custom validation function to customValidator.

Validator function signature is: bool ( const QgsServerApiContext &context, QVariant &value )

Note
a validator can change the value if needed and must return true if the validation passed
not available in Python bindings

Definition at line 111 of file qgsserverquerystringparameter.cpp.

◆ setDescription()

void QgsServerQueryStringParameter::setDescription ( const QString &  description)

Sets validator description.

Definition at line 158 of file qgsserverquerystringparameter.cpp.

◆ setHidden()

void QgsServerQueryStringParameter::setHidden ( bool  hidden)

Set the parameter's hidden status, parameters are not hidden by default.

Since
QGIS 3.28

Definition at line 168 of file qgsserverquerystringparameter.cpp.

◆ typeName()

QString QgsServerQueryStringParameter::typeName ( const Type  type)
static

Returns the name of the type.

Definition at line 147 of file qgsserverquerystringparameter.cpp.

◆ value()

QVariant QgsServerQueryStringParameter::value ( const QgsServerApiContext context) const
virtual

Extracts the value from the request context by validating the parameter value and converting it to its proper Type.

If the value is not set and a default was not provided an invalid QVariant is returned.

Validation steps:

  • required
  • can convert to proper Type
  • custom validator (if set - not available in Python bindings)
See also
setCustomValidator() (not available in Python bindings)
Returns
the parameter value or an invalid QVariant if not found (and not required)
Exceptions
QgsServerApiBadRequestErrorif validation fails

Definition at line 40 of file qgsserverquerystringparameter.cpp.

Friends And Related Function Documentation

◆ TestQgsServerQueryStringParameter

friend class TestQgsServerQueryStringParameter
friend

Definition at line 170 of file qgsserverquerystringparameter.h.


The documentation for this class was generated from the following files: