QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsserverparameters.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsserverparameters.h
3 ------------------
4 begin : Jun 27, 2018
5 copyright : (C) 2018 by Paul Blottiere
6 email : paul dot blottiere at oslandia dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSSERVERPARAMETERS_H
19#define QGSSERVERPARAMETERS_H
20
21#include "qgis_server.h"
22#include "qgsgeometry.h"
23
24#include <QColor>
25#include <QMap>
26#include <QMetaEnum>
27#include <QUrlQuery>
28
36{
37 public:
38
44 QgsServerParameterDefinition( const QMetaType::Type type = QMetaType::Type::QString, const QVariant defaultValue = QVariant( "" ) );
45
46
53 Q_DECL_DEPRECATED QgsServerParameterDefinition( const QVariant::Type type, const QVariant defaultValue = QVariant( "" ) ) SIP_DEPRECATED;
54
55 virtual ~QgsServerParameterDefinition() = default;
56
60 QString typeName() const;
61
65 virtual bool isValid() const;
66
71 QString toString( bool defaultValue = false ) const;
72
79 QStringList toStringList( char delimiter = ',', bool skipEmptyParts = true ) const;
80
88 QList<int> toIntList( bool &ok, char delimiter = ',', bool skipEmptyParts = true ) const;
89
97 QList<double> toDoubleList( bool &ok, char delimiter = ',', bool skipEmptyParts = true ) const;
98
106 QList<QColor> toColorList( bool &ok, char delimiter = ',', bool skipEmptyParts = true ) const;
107
115 QList<QgsGeometry> toGeomList( bool &ok, char delimiter = ',', bool skipEmptyParts = true ) const;
116
122 QStringList toOgcFilterList() const;
123
129 QStringList toExpressionList() const;
130
136 QgsRectangle toRectangle( bool &ok ) const;
137
143 int toInt( bool &ok ) const;
144
150 double toDouble( bool &ok ) const;
151
156 bool toBool() const;
157
163 QColor toColor( bool &ok ) const;
164
171 QUrl toUrl( bool &ok ) const;
172
179 QString loadUrl( bool &ok ) const;
180
186 static void raiseError( const QString &msg );
187
188 QMetaType::Type mType;
189 QVariant mValue;
191};
192
200{
201 Q_GADGET
202
203 public:
205 enum Name
206 {
209 VERSION_SERVICE, // conflict with #define VERSION
213 };
214 Q_ENUM( Name )
215
216
222 QgsServerParameter( const QgsServerParameter::Name name = QgsServerParameter::UNKNOWN, const QMetaType::Type type = QMetaType::Type::QString, const QVariant defaultValue = QVariant( "" ) );
223
231 Q_DECL_DEPRECATED QgsServerParameter( const QgsServerParameter::Name name, const QVariant::Type type, const QVariant defaultValue = QVariant( "" ) ) SIP_DEPRECATED;
232
237 void raiseError() const;
238
242 static QString name( const QgsServerParameter::Name name );
243
248 static QgsServerParameter::Name name( const QString &name );
249
251};
252
259class SERVER_EXPORT QgsServerParameters
260{
261 Q_GADGET
262
263 public:
264
269
273 QgsServerParameters( const QUrlQuery &query );
274
275 virtual ~QgsServerParameters() = default;
276
281 void load( const QUrlQuery &query );
282
286 void clear();
287
293 void add( const QString &key, const QString &value );
294
299 void remove( const QString &key );
300
306 void remove( QgsServerParameter::Name name );
307
312 QString value( const QString &key ) const;
313
317 QUrlQuery urlQuery() const;
318
322 QMap<QString, QString> toMap() const;
323
329 QString service() const;
330
336 virtual QString request() const;
337
343 QString map() const;
344
350 QString fileName() const;
351
357 virtual QString version() const;
358
359 protected:
360
365 virtual bool loadParameter( const QString &name, const QString &value );
366
367 QMap<QString, QString> mUnmanagedParameters;
368
369 private:
370 void save( const QgsServerParameter &parameter );
371 QVariant value( QgsServerParameter::Name name ) const;
372
373 QMap<QgsServerParameter::Name, QgsServerParameter> mParameters;
374 QUrlQuery mUrlQuery;
375};
376
377#endif
A rectangle specified with double values.
QList< QColor > toColorList(bool &ok, char delimiter=',', bool skipEmptyParts=true) const
Converts the parameter into a list of colors.
QString loadUrl(bool &ok) const
Loads the data associated to the parameter converted into an url.
QUrl toUrl(bool &ok) const
Converts the parameter into an url.
virtual ~QgsServerParameterDefinition()=default
QList< int > toIntList(bool &ok, char delimiter=',', bool skipEmptyParts=true) const
Converts the parameter into a list of integers.
QString toString(bool defaultValue=false) const
Converts the parameter into a string.
bool toBool() const
Converts the parameter into a boolean.
QgsServerParameterDefinition(const QMetaType::Type type=QMetaType::Type::QString, const QVariant defaultValue=QVariant(""))
Constructor for QgsServerParameterDefinition.
QStringList toStringList(char delimiter=',', bool skipEmptyParts=true) const
Converts the parameter into a list of strings.
virtual bool isValid() const
Returns true if the parameter is valid, false otherwise.
QString typeName() const
Returns the type of the parameter as a string.
static void raiseError(const QString &msg)
Raises an exception in case of an invalid parameters.
QStringList toExpressionList() const
Converts the parameter into a list of QGIS expressions.
int toInt(bool &ok) const
Converts the parameter into an integer.
QList< QgsGeometry > toGeomList(bool &ok, char delimiter=',', bool skipEmptyParts=true) const
Converts the parameter into a list of geometries.
QColor toColor(bool &ok) const
Converts the parameter into a color.
double toDouble(bool &ok) const
Converts the parameter into a double.
QList< double > toDoubleList(bool &ok, char delimiter=',', bool skipEmptyParts=true) const
Converts the parameter into a list of doubles.
QgsRectangle toRectangle(bool &ok) const
Converts the parameter into a rectangle.
QStringList toOgcFilterList() const
Converts the parameter into a list of OGC filters.
Parameter common to all services (WMS, WFS, ...).
QgsServerParameter::Name mName
QgsServerParameter(const QgsServerParameter::Name name=QgsServerParameter::UNKNOWN, const QMetaType::Type type=QMetaType::Type::QString, const QVariant defaultValue=QVariant(""))
Constructor for QgsServerParameter.
Name
Parameter's name common to all services.
QMap< QString, QString > toMap() const
Returns all parameters in a map.
virtual ~QgsServerParameters()=default
QString map() const
Returns MAP parameter as a string or an empty string if not defined.
void add(const QString &key, const QString &value)
Adds a parameter.
QString service() const
Returns SERVICE parameter as a string or an empty string if not defined.
virtual QString request() const
Returns REQUEST parameter as a string or an empty string if not defined.
void clear()
Removes all parameters.
QString fileName() const
Returns FILE_NAME parameter as a string or an empty string if not defined.
virtual bool loadParameter(const QString &name, const QString &value)
Loads a parameter with a specific value.
QUrlQuery urlQuery() const
Returns a url query with underlying parameters.
QMap< QString, QString > mUnmanagedParameters
void load(const QUrlQuery &query)
Loads new parameters.
void remove(const QString &key)
Removes a parameter.
virtual QString version() const
Returns VERSION parameter as a string or an empty string if not defined.
QString value(const QString &key) const
Returns the value of a parameter.
#define SIP_DEPRECATED
Definition qgis_sip.h:114