QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgis_server.h"
20#include "qgis_sip.h"
21#include "qgsserverapicontext.h"
22
23#include <QObject>
24#include <QString>
25#include <QVariant>
26
27#ifndef SIP_RUN
28#include <nlohmann/json.hpp>
29using namespace nlohmann;
30#endif
31
32
34
35
47{
48 Q_GADGET
49
50#ifndef SIP_RUN
51 typedef std::function<bool( const QgsServerApiContext &, QVariant & )> customValidator;
52#endif
53 public:
57 enum class Type
58 {
59 String = QMetaType::Type::QString,
60 Integer = QMetaType::Type::LongLong,
61 Double = QMetaType::Type::Double,
62 Boolean = QMetaType::Type::Bool,
63 List = QMetaType::Type::QStringList,
64 };
65 Q_ENUM( Type )
66
67
68
77 QgsServerQueryStringParameter( const QString name, bool required = false, Type type = QgsServerQueryStringParameter::Type::String, const QString &description = QString(), const QVariant &defaultValue = QVariant() );
78
80
96 virtual QVariant value( const QgsServerApiContext &context ) const;
97
98#ifndef SIP_RUN
99
107 void setCustomValidator( const customValidator &customValidator );
108
112 json data() const;
113
114#endif
115
119 QString description() const;
120
124 static QString typeName( const Type type );
125
129 QString name() const;
130
134 void setDescription( const QString &description );
135
144 bool hidden() const;
145
151 void setHidden( bool hidden );
152
153 private:
154 QString mName;
155 bool mRequired = false;
156 Type mType = Type::String;
157 customValidator mCustomValidator = nullptr;
158 QString mDescription;
159 QVariant mDefaultValue;
160 bool mHidden = false;
161
163};
164
165#endif // QGSSERVERQUERYSTRINGPARAMETER_H
Bad request error API exception.
Encapsulates the resources for a particular client request.
Holds the information regarding a query string input parameter and its validation.
QgsServerQueryStringParameter(const QString name, bool required=false, Type type=QgsServerQueryStringParameter::Type::String, const QString &description=QString(), const QVariant &defaultValue=QVariant())
Constructs a QgsServerQueryStringParameter object.
Type
The Type enum represents the parameter type.