QGIS API Documentation  3.6.0-Noosa (5873452)
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 
64  QString toString() const;
65 
71  QStringList toStringList( char delimiter = ',' ) const;
72 
79  QList<int> toIntList( bool &ok, char delimiter = ',' ) const;
80 
87  QList<double> toDoubleList( bool &ok, char delimiter = ',' ) const;
88 
95  QList<QColor> toColorList( bool &ok, char delimiter = ',' ) const;
96 
103  QList<QgsGeometry> toGeomList( bool &ok, char delimiter = ',' ) const;
104 
110  QgsRectangle toRectangle( bool &ok ) const;
111 
117  int toInt( bool &ok ) const;
118 
124  double toDouble( bool &ok ) const;
125 
130  bool toBool() const;
131 
137  QColor toColor( bool &ok ) const;
138 
145  QUrl toUrl( bool &ok ) const;
146 
153  QString loadUrl( bool &ok ) const;
154 
160  static void raiseError( const QString &msg );
161 
162  QVariant::Type mType;
163  QVariant mValue;
164  QVariant mDefaultValue;
165 };
166 
174 {
175  Q_GADGET
176 
177  public:
179  enum Name
180  {
183  VERSION_SERVICE, // conflict with #define VERSION
186  FILE_NAME
187  };
188  Q_ENUM( Name )
189 
190 
197  const QVariant::Type type = QVariant::String,
198  const QVariant defaultValue = QVariant( "" ) );
199 
204  void raiseError() const;
205 
209  static QString name( const QgsServerParameter::Name name );
210 
215  static QgsServerParameter::Name name( const QString &name );
216 
218 };
219 
226 class SERVER_EXPORT QgsServerParameters
227 {
228  Q_GADGET
229 
230  public:
231 
236 
240  QgsServerParameters( const QUrlQuery &query );
241 
242  virtual ~QgsServerParameters() = default;
243 
248  void load( const QUrlQuery &query );
249 
253  void clear();
254 
260  void add( const QString &key, const QString &value );
261 
266  void remove( const QString &key );
267 
273  void remove( QgsServerParameter::Name name );
274 
279  QString value( const QString &key ) const;
280 
284  QUrlQuery urlQuery() const;
285 
289  QMap<QString, QString> toMap() const;
290 
296  QString service() const;
297 
303  QString request() const;
304 
310  QString map() const;
311 
317  QString fileName() const;
318 
324  QString version() const;
325 
326  protected:
327 
332  virtual bool loadParameter( const QString &name, const QString &value );
333 
334  QMap<QString, QString> mUnmanagedParameters;
335 
336  private:
337  void save( const QgsServerParameter &parameter );
338  QVariant value( QgsServerParameter::Name name ) const;
339 
340  QMap<QgsServerParameter::Name, QgsServerParameter> mParameters;
341  QUrlQuery mUrlQuery;
342 };
343 
344 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Name
Parameter&#39;s name common to all services.
QMap< QString, QString > mUnmanagedParameters
static void raiseError(const QString &msg)
Raises an exception in case of an invalid parameters.
const QString & typeName
Parameter common to all services (WMS, WFS, ...)
QgsServerParameter::Name mName
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
Definition of a parameter with basic conversion methods.