QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsserverquerystringparameter.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsserverquerystringparameter.h - QgsServerQueryStringParameter
3 
4  ---------------------
5  begin : 10.7.2019
6  copyright : (C) 2019 by Alessandro Pasotti
7  email : elpaso at itopen dot it
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSSERVERQUERYSTRINGPARAMETER_H
17 #define QGSSERVERQUERYSTRINGPARAMETER_H
18 
19 #include "qgsserverapicontext.h"
20 #include "qgis_server.h"
21 #include "qgis_sip.h"
22 #include <QString>
23 #include <QVariant>
24 #include <QObject>
25 
26 
27 #include "nlohmann/json_fwd.hpp"
28 
29 #ifndef SIP_RUN
30 using namespace nlohmann;
31 #endif
32 
33 
35 
36 
47 class SERVER_EXPORT QgsServerQueryStringParameter
48 {
49 
50  Q_GADGET
51 
52 #ifndef SIP_RUN
53  typedef std::function< bool ( const QgsServerApiContext &, QVariant & ) > customValidator;
54 #endif
55  public:
56 
60  enum class Type
61  {
62  String = QVariant::String,
63  Integer = QVariant::LongLong,
64  Double = QVariant::Double,
65  Boolean = QVariant::Bool,
66  List = QVariant::StringList,
67  };
68  Q_ENUM( Type )
69 
70 
71 
80  QgsServerQueryStringParameter( const QString name,
81  bool required = false,
83  const QString &description = QString(),
84  const QVariant &defaultValue = QVariant() );
85 
87 
102  virtual QVariant value( const QgsServerApiContext &context ) const;
103 
104 #ifndef SIP_RUN
105 
113  void setCustomValidator( const customValidator &customValidator );
114 
118  json data( ) const;
119 
120 #endif
121 
125  QString description() const;
126 
130  static QString typeName( const Type type );
131 
135  QString name() const;
136 
140  void setDescription( const QString &description );
141 
142  private:
143 
144  QString mName;
145  bool mRequired = false;
146  Type mType = Type::String;
147  customValidator mCustomValidator = nullptr;
148  QString mDescription;
149  QVariant mDefaultValue;
150 
151  friend class TestQgsServerQueryStringParameter;
152 
153 };
154 
155 #endif // QGSSERVERQUERYSTRINGPARAMETER_H
The QgsServerQueryStringParameter class holds the information regarding a query string input paramete...
const QString & typeName
The QgsServerApiContext class encapsulates the resources for a particular client request: the request...
Bad request error API exception.
Type
The Type enum represents the parameter type.