QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
103  virtual QVariant value( const QgsServerApiContext &context ) const;
104 
105 #ifndef SIP_RUN
106 
114  void setCustomValidator( const customValidator &customValidator );
115 
119  json data( ) const;
120 
121 #endif
122 
126  QString description() const;
127 
131  static QString typeName( const Type type );
132 
136  QString name() const;
137 
141  void setDescription( const QString &description );
142 
143  private:
144 
145  QString mName;
146  bool mRequired = false;
147  Type mType = Type::String;
148  customValidator mCustomValidator = nullptr;
149  QString mDescription;
150  QVariant mDefaultValue;
151 
152  friend class TestQgsServerQueryStringParameter;
153 
154 };
155 
156 #endif // QGSSERVERQUERYSTRINGPARAMETER_H
Bad request error API exception.
The QgsServerApiContext class encapsulates the resources for a particular client request: the request...
The QgsServerQueryStringParameter class holds the information regarding a query string input paramete...
Type
The Type enum represents the parameter type.
const QString & typeName