QGIS API Documentation  2.99.0-Master (ba079d8)
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 
35 // (Radim Blazek 4/2012)
36 class CORE_EXPORT QgsDataSourceUri
37 {
38  public:
39  enum SslMode
40  {
46  SslVerifyFull
47  };
48 
51 
53  QgsDataSourceUri( QString uri );
54 
59  QgsDataSourceUri( const QByteArray &uri ) SIP_SKIP;
60 
62  QString connectionInfo( bool expandAuthConfig = true ) const;
63 
65  QString uri( bool expandAuthConfig = true ) const;
66 
68  QByteArray encodedUri() const;
69 
74  void setEncodedUri( const QByteArray &uri ) SIP_SKIP;
75 
77  void setEncodedUri( const QString &uri );
78 
80  QString quotedTablename() const;
81 
84  void setParam( const QString &key, const QString &value );
86  void setParam( const QString &key, const QStringList &value ) SIP_PYNAME( setParamList );
87 
90  int removeParam( const QString &key );
91 
93  QString param( const QString &key ) const;
94 
96  QStringList params( const QString &key ) const;
97 
99  bool hasParam( const QString &key ) const;
100 
102  void setConnection( const QString &aHost,
103  const QString &aPort,
104  const QString &aDatabase,
105  const QString &aUsername,
106  const QString &aPassword,
107  SslMode sslmode = SslPrefer,
108  const QString &authConfigId = QString() );
109 
111  void setConnection( const QString &aService,
112  const QString &aDatabase,
113  const QString &aUsername,
114  const QString &aPassword,
115  SslMode sslmode = SslPrefer,
116  const QString &authConfigId = QString() );
117 
119  void setDatabase( const QString &database );
120 
122  void setDataSource( const QString &aSchema,
123  const QString &aTable,
124  const QString &aGeometryColumn,
125  const QString &aSql = QString(),
126  const QString &aKeyColumn = QString() );
127 
129  void setAuthConfigId( const QString &authcfg );
130 
132  void setUsername( const QString &username );
133 
135  void setPassword( const QString &password );
136 
138  static QString removePassword( const QString &aUri );
139 
141  QString authConfigId() const;
142 
144  QString username() const;
145 
147  QString schema() const;
148 
150  QString table() const;
151 
153  QString sql() const;
154 
156  QString geometryColumn() const;
157 
159  void setUseEstimatedMetadata( bool flag );
160 
162  bool useEstimatedMetadata() const;
163 
165  void disableSelectAtId( bool flag );
167  bool selectAtIdDisabled() const;
168 
170  void clearSchema();
171 
173  // \since QGIS 2.11
174  void setSchema( const QString &schema );
175 
177  void setSql( const QString &sql );
178 
180  QString host() const;
182  QString database() const;
184  QString port() const;
186  // \since QGIS 2.16
187  QString driver() const;
189  // \since QGIS 2.16
190  void setDriver( const QString &driver );
192  QString password() const;
194  SslMode sslMode() const;
195 
197  QString service() const;
198 
200  QString keyColumn() const;
202  void setKeyColumn( const QString &column );
203 
206  QgsWkbTypes::Type wkbType() const;
207 
209  void setWkbType( QgsWkbTypes::Type type );
210 
212  QString srid() const;
214  void setSrid( const QString &srid );
215 
216  private:
217  void skipBlanks( const QString &uri, int &i );
218  QString getValue( const QString &uri, int &i );
219  QString escape( const QString &uri, QChar delim ) const;
220 
221  /* data */
222 
224  QString mHost;
226  QString mPort;
228  QString mDriver;
230  QString mService;
232  QString mDatabase;
234  QString mSchema;
236  QString mTable;
238  QString mGeometryColumn;
240  QString mSql;
242  QString mAuthConfigId;
244  QString mUsername;
246  QString mPassword;
248  SslMode mSSLmode;
250  QString mKeyColumn;
252  bool mUseEstimatedMetadata;
254  bool mSelectAtIdDisabled;
256  QgsWkbTypes::Type mWkbType;
258  QString mSrid;
260  QMap<QString, QString> mParams;
261 };
262 
263 #endif //QGSDATASOURCEURI_H
264 
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:66
#define SIP_SKIP
Definition: qgis_sip.h:102
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
#define SIP_PYNAME(name)
Definition: qgis_sip.h:62