QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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 = QMetaType::Type::QString , Integer = QMetaType::Type::LongLong , Double = QMetaType::Type::Double , Boolean = QMetaType::Type::Bool ,
  List = QMetaType::Type::QStringList
}
 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.
 
virtual ~QgsServerQueryStringParameter ()
 
json data () const
 Returns the handler information as a JSON object.
 
QString description () const
 Returns parameter description.
 
bool hidden () const
 Returns true if the parameter is hidden from the schema.
 
QString name () const
 Returns the name of the parameter.
 
void setCustomValidator (const customValidator &customValidator)
 Sets the custom validation function to customValidator.
 
void setDescription (const QString &description)
 Sets validator description.
 
void setHidden (bool hidden)
 Set the parameter's hidden status, parameters are not hidden by default.
 
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.
 

Static Public Member Functions

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

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 

Parameter is a string.

Integer 

Parameter is an integer.

Double 

Parameter is a double.

Boolean 

Parameter is a boolean.

List 

Parameter is a (comma separated) list of strings, the handler will perform any further required conversion of the list values.

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 23 of file qgsserverquerystringparameter.cpp.

◆ ~QgsServerQueryStringParameter()

QgsServerQueryStringParameter::~QgsServerQueryStringParameter ( )
virtual

Definition at line 36 of file qgsserverquerystringparameter.cpp.

Member Function Documentation

◆ data()

json QgsServerQueryStringParameter::data ( ) const

Returns the handler information as a JSON object.

Definition at line 117 of file qgsserverquerystringparameter.cpp.

◆ description()

QString QgsServerQueryStringParameter::description ( ) const

Returns parameter description.

Definition at line 143 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 164 of file qgsserverquerystringparameter.cpp.

◆ name()

QString QgsServerQueryStringParameter::name ( ) const

Returns the name of the parameter.

Definition at line 154 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 112 of file qgsserverquerystringparameter.cpp.

◆ setDescription()

void QgsServerQueryStringParameter::setDescription ( const QString &  description)

Sets validator description.

Definition at line 159 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 169 of file qgsserverquerystringparameter.cpp.

◆ typeName()

QString QgsServerQueryStringParameter::typeName ( const Type  type)
static

Returns the name of the type.

Definition at line 148 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 41 of file qgsserverquerystringparameter.cpp.

Friends And Related Symbol 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: