QGIS API Documentation 3.41.0-Master (d5b93354e9c)
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
243 void setSchema( const QString &schema );
244
253 void setSql( const QString &sql );
254
256 QString host() const;
258 QString database() const;
260 QString port() const;
261
265 QString driver() const;
266
270 void setDriver( const QString &driver );
271
273 QString password() const;
274
276 SslMode sslMode() const;
277
279 QString service() const;
280
282 QString keyColumn() const;
283
285 void setKeyColumn( const QString &column );
286
290 Qgis::WkbType wkbType() const;
291
293 void setWkbType( Qgis::WkbType type );
294
296 QString srid() const;
297
299 void setSrid( const QString &srid );
300
305 static SslMode decodeSslMode( const QString &sslMode );
306
311 static QString encodeSslMode( SslMode sslMode );
312
317 void setTable( const QString &table );
318
323 void setGeometryColumn( const QString &geometryColumn );
324
329 QSet<QString> parameterKeys() const;
330
331#ifndef SIP_RUN
333 QgsHttpHeaders httpHeaders() const { return mHttpHeaders; }
334#endif
335
340 QgsHttpHeaders &httpHeaders() { return mHttpHeaders; }
341
346 QString httpHeader( const QString &key ) { return mHttpHeaders[key].toString(); }
347
352 void setHttpHeaders( const QgsHttpHeaders &headers ) { mHttpHeaders = headers; }
353
354#ifdef SIP_RUN
355 SIP_PYOBJECT __repr__();
356 % MethodCode
357 QString str = QStringLiteral( "<QgsDataSourceUri: %1>" ).arg( sipCpp->uri( false ) );
358 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
359 % End
360#endif
361
362 private:
363 void skipBlanks( const QString &uri, int &i );
364 QString getValue( const QString &uri, int &i );
365 QString escape( const QString &uri, QChar delim ) const;
366
367 /* data */
368
370 QString mHost;
372 QString mPort;
374 QString mDriver;
376 QString mService;
378 QString mDatabase;
380 QString mSchema;
382 QString mTable;
384 QString mGeometryColumn;
386 QString mSql;
388 QString mAuthConfigId;
390 QString mUsername;
392 QString mPassword;
394 SslMode mSSLmode = SslPrefer;
396 QString mKeyColumn;
398 bool mUseEstimatedMetadata = false;
400 bool mSelectAtIdDisabled = false;
402 bool mSelectAtIdDisabledSet = false;
406 QString mSrid;
408 QMultiMap<QString, QString> mParams;
410 QgsHttpHeaders mHttpHeaders;
411};
412
413#endif //QGSDATASOURCEURI_H
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
@ 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 SIP_SKIP
Definition qgis_sip.h:126
#define SIP_PYNAME(name)
Definition qgis_sip.h:81