QGIS API Documentation  3.27.0-Master (bef583a8ef)
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 <QMap>
22 #include <QMetaEnum>
23 #include <QUrlQuery>
24 #include <QColor>
25 #include "qgsgeometry.h"
26 #include "qgis_server.h"
27 
34 class SERVER_EXPORT QgsServerParameterDefinition
35 {
36  public:
37 
43  QgsServerParameterDefinition( const QVariant::Type type = QVariant::String,
44  const QVariant defaultValue = QVariant( "" ) );
45 
49  virtual ~QgsServerParameterDefinition() = default;
50 
54  QString typeName() const;
55 
59  virtual bool isValid() const;
60 
65  QString toString( bool defaultValue = false ) const;
66 
73  QStringList toStringList( char delimiter = ',', bool skipEmptyParts = true ) const;
74 
81  QList<int> toIntList( bool &ok, char delimiter = ',' ) const;
82 
89  QList<double> toDoubleList( bool &ok, char delimiter = ',' ) const;
90 
97  QList<QColor> toColorList( bool &ok, char delimiter = ',' ) const;
98 
105  QList<QgsGeometry> toGeomList( bool &ok, char delimiter = ',' ) const;
106 
112  QStringList toOgcFilterList() const;
113 
119  QStringList toExpressionList() const;
120 
126  QgsRectangle toRectangle( bool &ok ) const;
127 
133  int toInt( bool &ok ) const;
134 
140  double toDouble( bool &ok ) const;
141 
146  bool toBool() const;
147 
153  QColor toColor( bool &ok ) const;
154 
161  QUrl toUrl( bool &ok ) const;
162 
169  QString loadUrl( bool &ok ) const;
170 
176  static void raiseError( const QString &msg );
177 
178  QVariant::Type mType;
179  QVariant mValue;
180  QVariant mDefaultValue;
181 };
182 
190 {
191  Q_GADGET
192 
193  public:
195  enum Name
196  {
199  VERSION_SERVICE, // conflict with #define VERSION
202  FILE_NAME
203  };
204  Q_ENUM( Name )
205 
206 
213  const QVariant::Type type = QVariant::String,
214  const QVariant defaultValue = QVariant( "" ) );
215 
220  void raiseError() const;
221 
225  static QString name( const QgsServerParameter::Name name );
226 
231  static QgsServerParameter::Name name( const QString &name );
232 
234 };
235 
242 class SERVER_EXPORT QgsServerParameters
243 {
244  Q_GADGET
245 
246  public:
247 
252 
256  QgsServerParameters( const QUrlQuery &query );
257 
258  virtual ~QgsServerParameters() = default;
259 
264  void load( const QUrlQuery &query );
265 
269  void clear();
270 
276  void add( const QString &key, const QString &value );
277 
282  void remove( const QString &key );
283 
289  void remove( QgsServerParameter::Name name );
290 
295  QString value( const QString &key ) const;
296 
300  QUrlQuery urlQuery() const;
301 
305  QMap<QString, QString> toMap() const;
306 
312  QString service() const;
313 
319  virtual QString request() const;
320 
326  QString map() const;
327 
333  QString fileName() const;
334 
340  virtual QString version() const;
341 
342  protected:
343 
348  virtual bool loadParameter( const QString &name, const QString &value );
349 
350  QMap<QString, QString> mUnmanagedParameters;
351 
352  private:
353  void save( const QgsServerParameter &parameter );
354  QVariant value( QgsServerParameter::Name name ) const;
355 
356  QMap<QgsServerParameter::Name, QgsServerParameter> mParameters;
357  QUrlQuery mUrlQuery;
358 };
359 
360 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Definition of a parameter with basic conversion methods.
virtual ~QgsServerParameterDefinition()=default
Default destructor for QgsServerParameterDefinition.
Parameter common to all services (WMS, WFS, ...)
QgsServerParameter::Name mName
Name
Parameter's name common to all services.
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
virtual ~QgsServerParameters()=default
QMap< QString, QString > mUnmanagedParameters
const QString & typeName