QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 <QObject>
23 #include <QMetaEnum>
24 #include <QUrlQuery>
25 #include <QColor>
26 #include "qgsgeometry.h"
27 #include "qgis_server.h"
28 
35 class SERVER_EXPORT QgsServerParameterDefinition
36 {
37  public:
38 
44  QgsServerParameterDefinition( const QVariant::Type type = QVariant::String,
45  const QVariant defaultValue = QVariant( "" ) );
46 
50  virtual ~QgsServerParameterDefinition() = default;
51 
55  QString typeName() const;
56 
60  virtual bool isValid() const;
61 
65  QString toString() 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  QgsRectangle toRectangle( bool &ok ) const;
113 
119  int toInt( bool &ok ) const;
120 
126  double toDouble( bool &ok ) const;
127 
132  bool toBool() const;
133 
139  QColor toColor( bool &ok ) const;
140 
147  QUrl toUrl( bool &ok ) const;
148 
155  QString loadUrl( bool &ok ) const;
156 
162  static void raiseError( const QString &msg );
163 
164  QVariant::Type mType;
165  QVariant mValue;
166  QVariant mDefaultValue;
167 };
168 
176 {
177  Q_GADGET
178 
179  public:
181  enum Name
182  {
185  VERSION_SERVICE, // conflict with #define VERSION
188  FILE_NAME
189  };
190  Q_ENUM( Name )
191 
192 
199  const QVariant::Type type = QVariant::String,
200  const QVariant defaultValue = QVariant( "" ) );
201 
206  void raiseError() const;
207 
211  static QString name( const QgsServerParameter::Name name );
212 
217  static QgsServerParameter::Name name( const QString &name );
218 
220 };
221 
228 class SERVER_EXPORT QgsServerParameters
229 {
230  Q_GADGET
231 
232  public:
233 
237  QgsServerParameters();
238 
242  QgsServerParameters( const QUrlQuery &query );
243 
244  virtual ~QgsServerParameters() = default;
245 
250  void load( const QUrlQuery &query );
251 
255  void clear();
256 
262  void add( const QString &key, const QString &value );
263 
268  void remove( const QString &key );
269 
275  void remove( QgsServerParameter::Name name );
276 
281  QString value( const QString &key ) const;
282 
286  QUrlQuery urlQuery() const;
287 
291  QMap<QString, QString> toMap() const;
292 
298  QString service() const;
299 
305  QString request() const;
306 
312  QString map() const;
313 
319  QString fileName() const;
320 
326  QString version() const;
327 
328  protected:
329 
334  virtual bool loadParameter( const QString &name, const QString &value );
335 
336  QMap<QString, QString> mUnmanagedParameters;
337 
338  private:
339  void save( const QgsServerParameter &parameter );
340  QVariant value( QgsServerParameter::Name name ) const;
341 
342  QMap<QgsServerParameter::Name, QgsServerParameter> mParameters;
343 };
344 
345 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:40
Name
Parameter&#39;s name common to all services.
QMap< QString, QString > mUnmanagedParameters
const QString & typeName
Parameter common to all services (WMS, WFS, ...)
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
Definition of a parameter with basic conversion methods.