QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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
30using namespace nlohmann;
31#endif
32
33
35
36
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 = QMetaType::Type::QString,
63 Integer = QMetaType::Type::LongLong,
64 Double = QMetaType::Type::Double,
65 Boolean = QMetaType::Type::Bool,
66 List = QMetaType::Type::QStringList,
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
151 bool hidden() const;
152
158 void setHidden( bool hidden );
159
160 private:
161
162 QString mName;
163 bool mRequired = false;
164 Type mType = Type::String;
165 customValidator mCustomValidator = nullptr;
166 QString mDescription;
167 QVariant mDefaultValue;
168 bool mHidden = false;
169
170 friend class TestQgsServerQueryStringParameter;
171
172};
173
174#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.
@ String
Parameter is a string.
const QString & typeName