2016-02-14 03:50:23 +01:00
|
|
|
/** \ingroup core
|
|
|
|
* Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
|
|
|
|
* This structure stores the database connection information, including host, database,
|
|
|
|
* user name, password, schema, password, and sql where clause
|
|
|
|
*
|
|
|
|
* Extended to support generic params so that it may be used by any provider.
|
|
|
|
* The 2 modes (the old - RDMS specific and the new generic) may not yet be mixed.
|
|
|
|
* (Radim Blazek 4/2012)
|
2009-09-12 20:37:31 +00:00
|
|
|
*/
|
|
|
|
class QgsDataSourceURI
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsdatasourceuri.h>
|
|
|
|
%End
|
|
|
|
|
2012-08-02 23:57:11 +02:00
|
|
|
public:
|
2016-02-26 20:40:57 +01:00
|
|
|
enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire, SSLverifyCA, SSLverifyFull };
|
2012-08-02 23:57:11 +02:00
|
|
|
|
|
|
|
//! default constructor
|
|
|
|
QgsDataSourceURI();
|
|
|
|
|
|
|
|
//! constructor which parses input URI
|
|
|
|
QgsDataSourceURI( QString uri );
|
|
|
|
|
|
|
|
//! return connection part of URI
|
2015-09-21 05:42:53 -06:00
|
|
|
QString connectionInfo( bool expandAuthConfig = true ) const;
|
2012-08-02 23:57:11 +02:00
|
|
|
|
|
|
|
//! return complete uri
|
2015-09-21 05:42:53 -06:00
|
|
|
QString uri( bool expandAuthConfig = true ) const;
|
2012-08-02 23:57:11 +02:00
|
|
|
|
2012-10-10 11:57:00 +03:00
|
|
|
//! return complete encoded uri (generic mode)
|
|
|
|
QByteArray encodedUri() const;
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! set complete encoded uri (generic mode)
|
|
|
|
// \note not available in python bindings
|
|
|
|
// void setEncodedUri( const QByteArray & uri );
|
|
|
|
|
2012-08-02 23:57:11 +02:00
|
|
|
//! set complete encoded uri (generic mode)
|
|
|
|
void setEncodedUri( const QString & uri );
|
|
|
|
|
|
|
|
//! quoted table name
|
|
|
|
QString quotedTablename() const;
|
|
|
|
|
|
|
|
//! Set generic param (generic mode)
|
|
|
|
// \note if key exists, another is inserted
|
|
|
|
void setParam( const QString &key, const QString &value );
|
2015-11-08 19:18:00 +00:00
|
|
|
//! @note available in python as setParamList
|
2014-01-26 18:35:21 +01:00
|
|
|
void setParam( const QString &key, const QStringList &value ) /PyName=setParamList/;
|
2012-08-02 23:57:11 +02:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
//! Remove generic param (generic mode)
|
|
|
|
// \note remove all occurrences of key, returns number of params removed
|
|
|
|
int removeParam( const QString &key );
|
|
|
|
|
2012-08-02 23:57:11 +02:00
|
|
|
//! Get generic param (generic mode)
|
|
|
|
QString param( const QString &key ) const;
|
|
|
|
|
|
|
|
//! Get multiple generic param (generic mode)
|
|
|
|
QStringList params( const QString &key ) const;
|
|
|
|
|
|
|
|
//! Test if param exists (generic mode)
|
|
|
|
bool hasParam( const QString &key ) const;
|
|
|
|
|
|
|
|
//! Set all connection related members at once
|
|
|
|
void setConnection( const QString& aHost,
|
|
|
|
const QString& aPort,
|
|
|
|
const QString& aDatabase,
|
|
|
|
const QString& aUsername,
|
|
|
|
const QString& aPassword,
|
2015-09-21 05:42:53 -06:00
|
|
|
SSLmode sslmode = SSLprefer,
|
|
|
|
const QString& authConfigId = QString() );
|
2012-08-02 23:57:11 +02:00
|
|
|
|
|
|
|
//! Set all connection related members at once (for the service case)
|
|
|
|
void setConnection( const QString& aService,
|
|
|
|
const QString& aDatabase,
|
|
|
|
const QString& aUsername,
|
|
|
|
const QString& aPassword,
|
2015-09-21 05:42:53 -06:00
|
|
|
SSLmode sslmode = SSLprefer,
|
|
|
|
const QString& authConfigId = QString() );
|
2012-08-02 23:57:11 +02:00
|
|
|
|
|
|
|
//! Set database
|
|
|
|
void setDatabase( const QString &database );
|
|
|
|
|
|
|
|
//! Set all data source related members at once
|
|
|
|
void setDataSource( const QString& aSchema,
|
|
|
|
const QString& aTable,
|
|
|
|
const QString& aGeometryColumn,
|
|
|
|
const QString& aSql = QString(),
|
|
|
|
const QString& aKeyColumn = QString() );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Set authentication configuration ID
|
2015-09-21 05:42:53 -06:00
|
|
|
void setAuthConfigId( const QString& authcfg );
|
|
|
|
|
2012-08-02 23:57:11 +02:00
|
|
|
//! set username
|
2015-10-07 11:55:34 +11:00
|
|
|
void setUsername( const QString& username );
|
2012-08-02 23:57:11 +02:00
|
|
|
|
|
|
|
//! set password
|
2015-10-07 11:55:34 +11:00
|
|
|
void setPassword( const QString& password );
|
2012-08-02 23:57:11 +02:00
|
|
|
|
|
|
|
//! Removes password element from uris
|
|
|
|
static QString removePassword( const QString& aUri );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Any associated authentication configuration ID
|
2015-09-21 05:42:53 -06:00
|
|
|
QString authConfigId() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
|
|
|
|
//! Returns the username
|
2012-08-02 23:57:11 +02:00
|
|
|
QString username() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
|
|
|
|
//! Returns the schema
|
2012-08-02 23:57:11 +02:00
|
|
|
QString schema() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
|
|
|
|
//! Returns the table
|
2012-08-02 23:57:11 +02:00
|
|
|
QString table() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
|
|
|
|
//! Returns the SQL query
|
2012-08-02 23:57:11 +02:00
|
|
|
QString sql() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
|
|
|
|
//! Return the name of the geometry column
|
2012-08-02 23:57:11 +02:00
|
|
|
QString geometryColumn() const;
|
|
|
|
|
|
|
|
//! set use Estimated Metadata
|
|
|
|
void setUseEstimatedMetadata( bool theFlag );
|
2016-02-14 03:50:23 +01:00
|
|
|
|
|
|
|
//! Returns true if estimated metadata are used
|
2012-08-02 23:57:11 +02:00
|
|
|
bool useEstimatedMetadata() const;
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Set to true to disable selection by id
|
2012-08-02 23:57:11 +02:00
|
|
|
void disableSelectAtId( bool theFlag );
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns whether the selection by id is disabled
|
2012-08-02 23:57:11 +02:00
|
|
|
bool selectAtIdDisabled() const;
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Clears the schema
|
2012-08-02 23:57:11 +02:00
|
|
|
void clearSchema();
|
2016-01-04 22:51:18 +11:00
|
|
|
|
|
|
|
//! set the table schema
|
|
|
|
// @note added in 2.11
|
|
|
|
void setSchema( const QString& schema );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Sets the SQL query
|
2015-10-07 11:55:34 +11:00
|
|
|
void setSql( const QString& sql );
|
2012-08-02 23:57:11 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns the host
|
2012-08-02 23:57:11 +02:00
|
|
|
QString host() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns the database
|
2012-08-02 23:57:11 +02:00
|
|
|
QString database() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns the port
|
2012-08-02 23:57:11 +02:00
|
|
|
QString port() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns the password
|
2012-08-02 23:57:11 +02:00
|
|
|
QString password() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns the SSL mode
|
2012-08-02 23:57:11 +02:00
|
|
|
SSLmode sslMode() const;
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns the service name
|
2012-08-02 23:57:11 +02:00
|
|
|
QString service() const;
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns the name of the (primary) key column
|
2012-08-02 23:57:11 +02:00
|
|
|
QString keyColumn() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Sets the name of the (primary) key column
|
2015-10-07 11:55:34 +11:00
|
|
|
void setKeyColumn( const QString& column );
|
2012-08-02 23:57:11 +02:00
|
|
|
|
2016-02-04 10:05:29 +01:00
|
|
|
/** The (old) wkb type.
|
|
|
|
@deprecated Will return QgsWKBTypes::Type in 3.0. Prefer newWkbType() in the meantime */
|
|
|
|
QGis::WkbType wkbType() const /Deprecated/;
|
|
|
|
|
|
|
|
/** The wkb type.
|
|
|
|
@note Will be removed in 3.0 */
|
|
|
|
QgsWKBTypes::Type newWkbType() const;
|
|
|
|
|
|
|
|
//! @deprecated See setWkbType( QgsWKBTypes::Type )
|
|
|
|
void setWkbType( QGis::WkbType type ) /Deprecated/;
|
|
|
|
|
|
|
|
//! Sets the wkb type
|
|
|
|
void setWkbType( QgsWKBTypes::Type type );
|
2012-08-02 23:57:11 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Returns the srid
|
2012-08-02 23:57:11 +02:00
|
|
|
QString srid() const;
|
2016-02-14 03:50:23 +01:00
|
|
|
//! Sets the srid
|
2015-10-07 11:55:34 +11:00
|
|
|
void setSrid( const QString& srid );
|
2009-09-12 20:37:31 +00:00
|
|
|
};
|