QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsdatasourceuri.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdatasourceuri.h - Structure to contain the component parts
3 of a data source URI
4 -------------------
5 begin : Dec 5, 2004
6 copyright : (C) 2004 by Gary E.Sherman
7 email : sherman at mrcc.com
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19#ifndef QGSDATASOURCEURI_H
20#define QGSDATASOURCEURI_H
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
24#include "qgswkbtypes.h"
25#include "qgshttpheaders.h"
26
27#include <QMap>
28#include <QSet>
29
37class CORE_EXPORT QgsDataSourceUri
38{
39 Q_GADGET
40 public:
41
54 Q_ENUM( SslMode )
55
57
61 QgsDataSourceUri( const QString &uri );
62
67 QgsDataSourceUri( const QByteArray &uri ) SIP_SKIP;
68
72 QString connectionInfo( bool expandAuthConfig = true ) const;
73
77 QString uri( bool expandAuthConfig = true ) const;
78
82 QByteArray encodedUri() const;
83
89 void setEncodedUri( const QByteArray &uri ) SIP_SKIP;
90
94 void setEncodedUri( const QString &uri );
95
99 QString quotedTablename() const;
100
106 void setParam( const QString &key, const QString &value );
107
112 void setParam( const QString &key, const QStringList &value ) SIP_PYNAME( setParamList );
113
118 int removeParam( const QString &key );
119
123 QString param( const QString &key ) const;
124
128 QStringList params( const QString &key ) const;
129
133 bool hasParam( const QString &key ) const;
134
138 void setConnection( const QString &aHost,
139 const QString &aPort,
140 const QString &aDatabase,
141 const QString &aUsername,
142 const QString &aPassword,
143 SslMode sslmode = SslPrefer,
144 const QString &authConfigId = QString() );
145
149 void setConnection( const QString &aService,
150 const QString &aDatabase,
151 const QString &aUsername,
152 const QString &aPassword,
153 SslMode sslmode = SslPrefer,
154 const QString &authConfigId = QString() );
155
159 void setDatabase( const QString &database );
160
167 void setDataSource( const QString &aSchema,
168 const QString &aTable,
169 const QString &aGeometryColumn,
170 const QString &aSql = QString(),
171 const QString &aKeyColumn = QString() );
172
176 void setAuthConfigId( const QString &authcfg );
177
181 void setUsername( const QString &username );
182
186 void setPassword( const QString &password );
187
196 static QString removePassword( const QString &aUri, bool hide = false );
197
201 QString authConfigId() const;
202
204 QString username() const;
205
207 QString schema() const;
208
210 QString table() const;
211
220 QString sql() const;
221
223 QString geometryColumn() const;
224
226 void setUseEstimatedMetadata( bool flag );
227
229 bool useEstimatedMetadata() const;
230
232 void disableSelectAtId( bool flag );
233
235 bool selectAtIdDisabled() const;
236
238 void clearSchema();
239
244 void setSchema( const QString &schema );
245
254 void setSql( const QString &sql );
255
257 QString host() const;
259 QString database() const;
261 QString port() const;
262
267 QString driver() const;
268
273 void setDriver( const QString &driver );
274
276 QString password() const;
277
279 SslMode sslMode() const;
280
282 QString service() const;
283
285 QString keyColumn() const;
286
288 void setKeyColumn( const QString &column );
289
293 Qgis::WkbType wkbType() const;
294
296 void setWkbType( Qgis::WkbType type );
297
299 QString srid() const;
300
302 void setSrid( const QString &srid );
303
308 static SslMode decodeSslMode( const QString &sslMode );
309
314 static QString encodeSslMode( SslMode sslMode );
315
320 void setTable( const QString &table );
321
326 void setGeometryColumn( const QString &geometryColumn );
327
332 QSet<QString> parameterKeys() const;
333
334#ifndef SIP_RUN
336 QgsHttpHeaders httpHeaders() const { return mHttpHeaders; }
337#endif
338
343 QgsHttpHeaders &httpHeaders() { return mHttpHeaders; }
344
349 QString httpHeader( const QString &key ) { return mHttpHeaders[key].toString(); }
350
355 void setHttpHeaders( const QgsHttpHeaders &headers ) { mHttpHeaders = headers; }
356
357#ifdef SIP_RUN
358 SIP_PYOBJECT __repr__();
359 % MethodCode
360 QString str = QStringLiteral( "<QgsDataSourceUri: %1>" ).arg( sipCpp->uri( false ) );
361 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
362 % End
363#endif
364
365 private:
366 void skipBlanks( const QString &uri, int &i );
367 QString getValue( const QString &uri, int &i );
368 QString escape( const QString &uri, QChar delim ) const;
369
370 /* data */
371
373 QString mHost;
375 QString mPort;
377 QString mDriver;
379 QString mService;
381 QString mDatabase;
383 QString mSchema;
385 QString mTable;
387 QString mGeometryColumn;
389 QString mSql;
391 QString mAuthConfigId;
393 QString mUsername;
395 QString mPassword;
397 SslMode mSSLmode = SslPrefer;
399 QString mKeyColumn;
401 bool mUseEstimatedMetadata = false;
403 bool mSelectAtIdDisabled = false;
405 bool mSelectAtIdDisabledSet = false;
409 QString mSrid;
411 QMultiMap<QString, QString> mParams;
413 QgsHttpHeaders mHttpHeaders;
414};
415
416#endif //QGSDATASOURCEURI_H
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:182
@ Unknown
Unknown.
Class for storing the component parts of a RDBMS data source URI (e.g.
SslMode
Available SSL connection modes.
QgsDataSourceUri(const QByteArray &uri)
Constructor for QgsDataSourceUri which parses an input encoded uri).
QgsHttpHeaders httpHeaders() const
Returns http headers.
QgsHttpHeaders & httpHeaders()
Returns http headers.
void setHttpHeaders(const QgsHttpHeaders &headers)
Sets headers to headers.
QString httpHeader(const QString &key)
Returns the http header value according to key.
This class implements simple http header management.
#define str(x)
Definition qgis.cpp:38
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_PYNAME(name)
Definition qgis_sip.h:81