QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 Q_GADGET
50
51#ifndef SIP_RUN
52 typedef std::function<bool( const QgsServerApiContext &, QVariant & )> customValidator;
53#endif
54 public:
58 enum class Type
59 {
60 String = QMetaType::Type::QString,
61 Integer = QMetaType::Type::LongLong,
62 Double = QMetaType::Type::Double,
63 Boolean = QMetaType::Type::Bool,
64 List = QMetaType::Type::QStringList,
65 };
66 Q_ENUM( Type )
67
68
69
78 QgsServerQueryStringParameter( const QString name, bool required = false, Type type = QgsServerQueryStringParameter::Type::String, const QString &description = QString(), const QVariant &defaultValue = QVariant() );
79
81
97 virtual QVariant value( const QgsServerApiContext &context ) const;
98
99#ifndef SIP_RUN
100
108 void setCustomValidator( const customValidator &customValidator );
109
113 json data() const;
114
115#endif
116
120 QString description() const;
121
125 static QString typeName( const Type type );
126
130 QString name() const;
131
135 void setDescription( const QString &description );
136
145 bool hidden() const;
146
152 void setHidden( bool hidden );
153
154 private:
155 QString mName;
156 bool mRequired = false;
157 Type mType = Type::String;
158 customValidator mCustomValidator = nullptr;
159 QString mDescription;
160 QVariant mDefaultValue;
161 bool mHidden = false;
162
163 friend class TestQgsServerQueryStringParameter;
164};
165
166#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