QGIS API Documentation  2.99.0-Master (b058df7)
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.h"
24 
25 #include <QMap>
26 
36 // (Radim Blazek 4/2012)
37 class CORE_EXPORT QgsDataSourceUri
38 {
39  public:
40  enum SslMode
41  {
47  SslVerifyFull
48  };
49 
52 
54  QgsDataSourceUri( QString uri );
55 
60  QgsDataSourceUri( const QByteArray &uri ) SIP_SKIP;
61 
63  QString connectionInfo( bool expandAuthConfig = true ) const;
64 
66  QString uri( bool expandAuthConfig = true ) const;
67 
69  QByteArray encodedUri() const;
70 
75  void setEncodedUri( const QByteArray &uri ) SIP_SKIP;
76 
78  void setEncodedUri( const QString &uri );
79 
81  QString quotedTablename() const;
82 
87  void setParam( const QString &key, const QString &value );
89  void setParam( const QString &key, const QStringList &value ) SIP_PYNAME( setParamList );
90 
95  int removeParam( const QString &key );
96 
98  QString param( const QString &key ) const;
99 
101  QStringList params( const QString &key ) const;
102 
104  bool hasParam( const QString &key ) const;
105 
107  void setConnection( const QString &aHost,
108  const QString &aPort,
109  const QString &aDatabase,
110  const QString &aUsername,
111  const QString &aPassword,
112  SslMode sslmode = SslPrefer,
113  const QString &authConfigId = QString() );
114 
116  void setConnection( const QString &aService,
117  const QString &aDatabase,
118  const QString &aUsername,
119  const QString &aPassword,
120  SslMode sslmode = SslPrefer,
121  const QString &authConfigId = QString() );
122 
124  void setDatabase( const QString &database );
125 
127  void setDataSource( const QString &aSchema,
128  const QString &aTable,
129  const QString &aGeometryColumn,
130  const QString &aSql = QString(),
131  const QString &aKeyColumn = QString() );
132 
134  void setAuthConfigId( const QString &authcfg );
135 
137  void setUsername( const QString &username );
138 
140  void setPassword( const QString &password );
141 
143  static QString removePassword( const QString &aUri );
144 
146  QString authConfigId() const;
147 
149  QString username() const;
150 
152  QString schema() const;
153 
155  QString table() const;
156 
158  QString sql() const;
159 
161  QString geometryColumn() const;
162 
164  void setUseEstimatedMetadata( bool flag );
165 
167  bool useEstimatedMetadata() const;
168 
170  void disableSelectAtId( bool flag );
172  bool selectAtIdDisabled() const;
173 
175  void clearSchema();
176 
178  // \since QGIS 2.11
179  void setSchema( const QString &schema );
180 
182  void setSql( const QString &sql );
183 
185  QString host() const;
187  QString database() const;
189  QString port() const;
191  // \since QGIS 2.16
192  QString driver() const;
194  // \since QGIS 2.16
195  void setDriver( const QString &driver );
197  QString password() const;
199  SslMode sslMode() const;
200 
202  QString service() const;
203 
205  QString keyColumn() const;
207  void setKeyColumn( const QString &column );
208 
212  QgsWkbTypes::Type wkbType() const;
213 
215  void setWkbType( QgsWkbTypes::Type type );
216 
218  QString srid() const;
220  void setSrid( const QString &srid );
221 
222  private:
223  void skipBlanks( const QString &uri, int &i );
224  QString getValue( const QString &uri, int &i );
225  QString escape( const QString &uri, QChar delim ) const;
226 
227  /* data */
228 
230  QString mHost;
232  QString mPort;
234  QString mDriver;
236  QString mService;
238  QString mDatabase;
240  QString mSchema;
242  QString mTable;
244  QString mGeometryColumn;
246  QString mSql;
248  QString mAuthConfigId;
250  QString mUsername;
252  QString mPassword;
254  SslMode mSSLmode = SslPrefer;
256  QString mKeyColumn;
258  bool mUseEstimatedMetadata = false;
260  bool mSelectAtIdDisabled = false;
264  QString mSrid;
266  QMap<QString, QString> mParams;
267 };
268 
269 #endif //QGSDATASOURCEURI_H
270 
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:67
#define SIP_SKIP
Definition: qgis_sip.h:119
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
#define SIP_PYNAME(name)
Definition: qgis_sip.h:74