QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsDataSourceUri Class Reference

Class for storing the component parts of a PostgreSQL/RDBMS datasource URI. More...

#include <qgsdatasourceuri.h>

Public Types

enum  SslMode {
  SslPrefer, SslDisable, SslAllow, SslRequire,
  SslVerifyCa, SslVerifyFull
}
 

Public Member Functions

 QgsDataSourceUri ()
 default constructor More...
 
 QgsDataSourceUri (QString uri)
 constructor which parses input URI More...
 
 QgsDataSourceUri (const QByteArray &uri)
 constructor which parses input encoded URI (generic mode) More...
 
QString authConfigId () const
 Any associated authentication configuration ID. More...
 
void clearSchema ()
 Clears the schema. More...
 
QString connectionInfo (bool expandAuthConfig=true) const
 Returns connection part of URI. More...
 
QString database () const
 Returns the database. More...
 
void disableSelectAtId (bool flag)
 Sets to true to disable selection by id. More...
 
QString driver () const
 Returns the driver. More...
 
QByteArray encodedUri () const
 Returns complete encoded uri (generic mode) More...
 
QString geometryColumn () const
 Returns the name of the geometry column. More...
 
bool hasParam (const QString &key) const
 Test if param exists (generic mode) More...
 
QString host () const
 Returns the host. More...
 
QString keyColumn () const
 Returns the name of the (primary) key column. More...
 
QString param (const QString &key) const
 Gets generic param (generic mode) More...
 
QStringList params (const QString &key) const
 Gets multiple generic param (generic mode) More...
 
QString password () const
 Returns the password. More...
 
QString port () const
 Returns the port. More...
 
QString quotedTablename () const
 quoted table name More...
 
int removeParam (const QString &key)
 Remove generic param (generic mode) More...
 
QString schema () const
 Returns the schema. More...
 
bool selectAtIdDisabled () const
 Returns whether the selection by id is disabled. More...
 
QString service () const
 Returns the service name. More...
 
void setAuthConfigId (const QString &authcfg)
 Sets authentication configuration ID. More...
 
void setConnection (const QString &aHost, const QString &aPort, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SslMode sslmode=SslPrefer, const QString &authConfigId=QString())
 Sets all connection related members at once. More...
 
void setConnection (const QString &aService, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SslMode sslmode=SslPrefer, const QString &authConfigId=QString())
 Sets all connection related members at once (for the service case) More...
 
void setDatabase (const QString &database)
 Sets database. More...
 
void setDataSource (const QString &aSchema, const QString &aTable, const QString &aGeometryColumn, const QString &aSql=QString(), const QString &aKeyColumn=QString())
 Sets all data source related members at once. More...
 
void setDriver (const QString &driver)
 Sets the driver name. More...
 
void setEncodedUri (const QByteArray &uri)
 set complete encoded uri (generic mode) More...
 
void setEncodedUri (const QString &uri)
 Sets complete encoded uri (generic mode) More...
 
void setKeyColumn (const QString &column)
 Sets the name of the (primary) key column. More...
 
void setParam (const QString &key, const QString &value)
 Set generic param (generic mode) More...
 
void setParam (const QString &key, const QStringList &value)
 
void setPassword (const QString &password)
 Sets password. More...
 
void setSchema (const QString &schema)
 Sets the table schema. More...
 
void setSql (const QString &sql)
 Sets the SQL query. More...
 
void setSrid (const QString &srid)
 Sets the srid. More...
 
void setUseEstimatedMetadata (bool flag)
 Sets use Estimated Metadata. More...
 
void setUsername (const QString &username)
 Sets username. More...
 
void setWkbType (QgsWkbTypes::Type type)
 Sets the wkb type. More...
 
QString sql () const
 Returns the SQL query. More...
 
QString srid () const
 Returns the srid. More...
 
SslMode sslMode () const
 Returns the SSL mode. More...
 
QString table () const
 Returns the table. More...
 
QString uri (bool expandAuthConfig=true) const
 Returns complete uri. More...
 
bool useEstimatedMetadata () const
 Returns true if estimated metadata are used. More...
 
QString username () const
 Returns the username. More...
 
QgsWkbTypes::Type wkbType () const
 The wkb type. More...
 

Static Public Member Functions

static SslMode decodeSslMode (const QString &sslMode)
 Decodes SSL mode string into enum value. More...
 
static QString encodeSslMode (SslMode sslMode)
 Encodes SSL mode enum value into a string. More...
 
static QString removePassword (const QString &aUri)
 Removes password element from uris. More...
 

Detailed Description

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.

Definition at line 37 of file qgsdatasourceuri.h.

Member Enumeration Documentation

Enumerator
SslPrefer 
SslDisable 
SslAllow 
SslRequire 
SslVerifyCa 
SslVerifyFull 

Definition at line 41 of file qgsdatasourceuri.h.

Constructor & Destructor Documentation

QgsDataSourceUri::QgsDataSourceUri ( )

default constructor

Definition at line 29 of file qgsdatasourceuri.cpp.

QgsDataSourceUri::QgsDataSourceUri ( QString  uri)

constructor which parses input URI

Definition at line 34 of file qgsdatasourceuri.cpp.

QgsDataSourceUri::QgsDataSourceUri ( const QByteArray &  uri)

constructor which parses input encoded URI (generic mode)

Note
not available in Python bindings

Member Function Documentation

QString QgsDataSourceUri::authConfigId ( ) const

Any associated authentication configuration ID.

Definition at line 249 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::clearSchema ( )

Clears the schema.

Definition at line 367 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::connectionInfo ( bool  expandAuthConfig = true) const

Returns connection part of URI.

Definition at line 461 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::database ( ) const

Returns the database.

Definition at line 274 of file qgsdatasourceuri.cpp.

QgsDataSourceUri::SslMode QgsDataSourceUri::decodeSslMode ( const QString &  sslMode)
static

Decodes SSL mode string into enum value.

If the string is not recognized, SslPrefer is returned.

Since
QGIS 3.2

Definition at line 689 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::disableSelectAtId ( bool  flag)

Sets to true to disable selection by id.

Definition at line 352 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::driver ( ) const

Returns the driver.

Definition at line 294 of file qgsdatasourceuri.cpp.

QByteArray QgsDataSourceUri::encodedUri ( ) const

Returns complete encoded uri (generic mode)

Definition at line 576 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::encodeSslMode ( QgsDataSourceUri::SslMode  sslMode)
static

Encodes SSL mode enum value into a string.

Since
QGIS 3.2

Definition at line 707 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::geometryColumn ( ) const

Returns the name of the geometry column.

Definition at line 319 of file qgsdatasourceuri.cpp.

bool QgsDataSourceUri::hasParam ( const QString &  key) const

Test if param exists (generic mode)

Definition at line 750 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::host ( ) const

Returns the host.

Definition at line 269 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::keyColumn ( ) const

Returns the name of the (primary) key column.

Definition at line 324 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::param ( const QString &  key) const

Gets generic param (generic mode)

Definition at line 740 of file qgsdatasourceuri.cpp.

QStringList QgsDataSourceUri::params ( const QString &  key) const

Gets multiple generic param (generic mode)

Definition at line 745 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::password ( ) const

Returns the password.

Definition at line 279 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::port ( ) const

Returns the port.

Definition at line 289 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::quotedTablename ( ) const

quoted table name

Definition at line 603 of file qgsdatasourceuri.cpp.

int QgsDataSourceUri::removeParam ( const QString &  key)

Remove generic param (generic mode)

Note
remove all occurrences of key, returns number of params removed

Definition at line 735 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::removePassword ( const QString &  aUri)
static

Removes password element from uris.

Definition at line 215 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::schema ( ) const

Returns the schema.

Definition at line 304 of file qgsdatasourceuri.cpp.

bool QgsDataSourceUri::selectAtIdDisabled ( ) const

Returns whether the selection by id is disabled.

Definition at line 357 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::service ( ) const

Returns the service name.

Definition at line 264 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setAuthConfigId ( const QString &  authcfg)

Sets authentication configuration ID.

Definition at line 659 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setConnection ( const QString &  aHost,
const QString &  aPort,
const QString &  aDatabase,
const QString &  aUsername,
const QString &  aPassword,
SslMode  sslmode = SslPrefer,
const QString &  authConfigId = QString() 
)

Sets all connection related members at once.

Definition at line 614 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setConnection ( const QString &  aService,
const QString &  aDatabase,
const QString &  aUsername,
const QString &  aPassword,
SslMode  sslmode = SslPrefer,
const QString &  authConfigId = QString() 
)

Sets all connection related members at once (for the service case)

Definition at line 631 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setDatabase ( const QString &  database)

Sets database.

Definition at line 664 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setDataSource ( const QString &  aSchema,
const QString &  aTable,
const QString &  aGeometryColumn,
const QString &  aSql = QString(),
const QString &  aKeyColumn = QString() 
)

Sets all data source related members at once.

Definition at line 646 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setDriver ( const QString &  driver)

Sets the driver name.

Definition at line 330 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setEncodedUri ( const QByteArray &  uri)

set complete encoded uri (generic mode)

Note
not available in Python bindings

Definition at line 586 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setEncodedUri ( const QString &  uri)

Sets complete encoded uri (generic mode)

Definition at line 598 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setKeyColumn ( const QString &  column)

Sets the name of the (primary) key column.

Definition at line 336 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setParam ( const QString &  key,
const QString &  value 
)

Set generic param (generic mode)

Note
if key exists, another is inserted

Definition at line 721 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setParam ( const QString &  key,
const QStringList &  value 
)
Note
available in Python as setParamList

Definition at line 727 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setPassword ( const QString &  password)

Sets password.

Definition at line 284 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setSchema ( const QString &  schema)

Sets the table schema.

Definition at line 372 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setSql ( const QString &  sql)

Sets the SQL query.

Definition at line 362 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setSrid ( const QString &  srid)

Sets the srid.

Definition at line 684 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setUseEstimatedMetadata ( bool  flag)

Sets use Estimated Metadata.

Definition at line 342 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setUsername ( const QString &  username)

Sets username.

Definition at line 259 of file qgsdatasourceuri.cpp.

void QgsDataSourceUri::setWkbType ( QgsWkbTypes::Type  type)

Sets the wkb type.

Definition at line 674 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::sql ( ) const

Returns the SQL query.

Definition at line 314 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::srid ( ) const

Returns the srid.

Definition at line 679 of file qgsdatasourceuri.cpp.

QgsDataSourceUri::SslMode QgsDataSourceUri::sslMode ( ) const

Returns the SSL mode.

Definition at line 299 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::table ( ) const

Returns the table.

Definition at line 309 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::uri ( bool  expandAuthConfig = true) const

Returns complete uri.

Definition at line 523 of file qgsdatasourceuri.cpp.

bool QgsDataSourceUri::useEstimatedMetadata ( ) const

Returns true if estimated metadata are used.

Definition at line 347 of file qgsdatasourceuri.cpp.

QString QgsDataSourceUri::username ( ) const

Returns the username.

Definition at line 254 of file qgsdatasourceuri.cpp.

QgsWkbTypes::Type QgsDataSourceUri::wkbType ( ) const

The wkb type.

Definition at line 669 of file qgsdatasourceuri.cpp.


The documentation for this class was generated from the following files: