QGIS API Documentation  3.23.0-Master (eb871beae0)
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  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 
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  virtual QString request() const;
306 
312  QString map() const;
313 
319  QString fileName() const;
320 
326  virtual 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  QUrlQuery mUrlQuery;
344 };
345 
346 #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