QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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:
43 QgsServerParameterDefinition( const QMetaType::Type type = QMetaType::Type::QString, const QVariant defaultValue = QVariant( "" ) );
44
45
52 Q_DECL_DEPRECATED QgsServerParameterDefinition( const QVariant::Type type, const QVariant defaultValue = QVariant( "" ) ) SIP_DEPRECATED;
53
54 virtual ~QgsServerParameterDefinition() = default;
55
59 QString typeName() const;
60
64 virtual bool isValid() const;
65
70 QString toString( bool defaultValue = false ) const;
71
78 QStringList toStringList( char delimiter = ',', bool skipEmptyParts = true ) const;
79
87 QList<int> toIntList( bool &ok, char delimiter = ',', bool skipEmptyParts = true ) const;
88
96 QList<double> toDoubleList( bool &ok, char delimiter = ',', bool skipEmptyParts = true ) const;
97
105 QList<QColor> toColorList( bool &ok, char delimiter = ',', bool skipEmptyParts = true ) const;
106
114 QList<QgsGeometry> toGeomList( bool &ok, char delimiter = ',', bool skipEmptyParts = true ) const;
115
121 QStringList toOgcFilterList() const;
122
128 QStringList toExpressionList() const;
129
135 QgsRectangle toRectangle( bool &ok ) const;
136
142 int toInt( bool &ok ) const;
143
149 double toDouble( bool &ok ) const;
150
155 bool toBool() const;
156
162 QColor toColor( bool &ok ) const;
163
170 QUrl toUrl( bool &ok ) const;
171
178 QString loadUrl( bool &ok ) const;
179
185 static void raiseError( const QString &msg );
186
187 QMetaType::Type mType;
188 QVariant mValue;
190};
191
199{
200 Q_GADGET
201
202 public:
204 enum Name
205 {
208 VERSION_SERVICE, // conflict with #define VERSION
212 };
213 Q_ENUM( Name )
214
215
221 QgsServerParameter( const QgsServerParameter::Name name = QgsServerParameter::UNKNOWN, const QMetaType::Type type = QMetaType::Type::QString, const QVariant defaultValue = QVariant( "" ) );
222
230 Q_DECL_DEPRECATED QgsServerParameter( const QgsServerParameter::Name name, const QVariant::Type type, const QVariant defaultValue = QVariant( "" ) ) SIP_DEPRECATED;
231
236 void raiseError() const;
237
241 static QString name( const QgsServerParameter::Name name );
242
247 static QgsServerParameter::Name name( const QString &name );
248
250};
251
258class SERVER_EXPORT QgsServerParameters
259{
260 Q_GADGET
261
262 public:
267
271 QgsServerParameters( const QUrlQuery &query );
272
273 virtual ~QgsServerParameters() = default;
274
279 void load( const QUrlQuery &query );
280
284 void clear();
285
291 void add( const QString &key, const QString &value );
292
297 void remove( const QString &key );
298
304 void remove( QgsServerParameter::Name name );
305
310 QString value( const QString &key ) const;
311
315 QUrlQuery urlQuery() const;
316
320 QMap<QString, QString> toMap() const;
321
327 QString service() const;
328
334 virtual QString request() const;
335
341 QString map() const;
342
348 QString fileName() const;
349
355 virtual QString version() const;
356
357 protected:
362 virtual bool loadParameter( const QString &name, const QString &value );
363
364 QMap<QString, QString> mUnmanagedParameters;
365
366 private:
367 void save( const QgsServerParameter &parameter );
368 QVariant value( QgsServerParameter::Name name ) const;
369
370 QMap<QgsServerParameter::Name, QgsServerParameter> mParameters;
371 QUrlQuery mUrlQuery;
372};
373
374#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