QGIS API Documentation
3.8.0-Zanzibar (11aff65)
|
Class for storing the component parts of a RDBMS data source URI (e.g. More...
#include <qgsdatasourceuri.h>
Public Types | |
enum | SslMode { SslPrefer, SslDisable, SslAllow, SslRequire, SslVerifyCa, SslVerifyFull } |
Available SSQL connection modes. More... | |
Public Member Functions | |
QgsDataSourceUri () | |
QgsDataSourceUri (const QString &uri) | |
Constructor for QgsDataSourceUri which parses an input uri string. More... | |
QgsDataSourceUri (const QByteArray &uri) | |
Constructor for QgsDataSourceUri which parses an input encoded uri). More... | |
QString | authConfigId () const |
Returns any associated authentication configuration ID stored in the URI. More... | |
void | clearSchema () |
Clears the schema stored in the URI. More... | |
QString | connectionInfo (bool expandAuthConfig=true) const |
Returns the connection part of the URI. More... | |
QString | database () const |
Returns the database name stored in the URI. More... | |
void | disableSelectAtId (bool flag) |
Set to true to disable selection by feature ID. More... | |
QString | driver () const |
Returns the driver name stored in the URI. More... | |
QByteArray | encodedUri () const |
Returns the complete encoded URI as a byte array. More... | |
QString | geometryColumn () const |
Returns the name of the geometry column stored in the URI, if set. More... | |
bool | hasParam (const QString &key) const |
Returns true if a parameter with the specified key exists. More... | |
QString | host () const |
Returns the host name stored in the URI. More... | |
QString | keyColumn () const |
Returns the name of the (primary) key column for the referenced table. More... | |
QString | param (const QString &key) const |
Returns a generic parameter value corresponding to the specified key. More... | |
QStringList | params (const QString &key) const |
Returns multiple generic parameter values corresponding to the specified key. More... | |
QString | password () const |
Returns the password stored in the URI. More... | |
QString | port () const |
Returns the port stored in the URI. More... | |
QString | quotedTablename () const |
Returns the URI's table name, escaped and quoted. More... | |
int | removeParam (const QString &key) |
Removes a generic parameter by key. More... | |
QString | schema () const |
Returns the schema stored in the URI. More... | |
bool | selectAtIdDisabled () const |
Returns whether the selection by feature ID is disabled. More... | |
QString | service () const |
Returns the service name associated with the URI. More... | |
void | setAuthConfigId (const QString &authcfg) |
Sets the authentication configuration ID for the URI. 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 a service case). More... | |
void | setDatabase (const QString &database) |
Sets the URI database name. 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 stored in the URI. More... | |
void | setEncodedUri (const QByteArray &uri) |
Sets the complete encoded uri. More... | |
void | setEncodedUri (const QString &uri) |
Sets the complete encoded uri from a string value. More... | |
void | setKeyColumn (const QString &column) |
Sets the name of the (primary) key column. More... | |
void | setParam (const QString &key, const QString &value) |
Sets a generic parameter value on the URI. More... | |
void | setParam (const QString &key, const QStringList &value) |
Sets a generic parameter list value on the URI. More... | |
void | setPassword (const QString &password) |
Sets the password for the URI. More... | |
void | setSchema (const QString &schema) |
Sets the scheme for the URI. More... | |
void | setSql (const QString &sql) |
Sets the SQL query for the URI. More... | |
void | setSrid (const QString &srid) |
Sets the spatial reference ID associated with the URI. More... | |
void | setUseEstimatedMetadata (bool flag) |
Sets whether estimated metadata should be used for the connection. More... | |
void | setUsername (const QString &username) |
Sets the username for the URI. More... | |
void | setWkbType (QgsWkbTypes::Type type) |
Sets the WKB type associated with the URI. More... | |
QString | sql () const |
Returns the SQL query stored in the URI, if set. More... | |
QString | srid () const |
Returns the spatial reference ID associated with the URI. More... | |
SslMode | sslMode () const |
Returns the SSL mode associated with the URI. More... | |
QString | table () const |
Returns the table name stored in the URI. More... | |
QString | uri (bool expandAuthConfig=true) const |
Returns the complete URI as a string. More... | |
bool | useEstimatedMetadata () const |
Returns true if estimated metadata should be used for the connection. More... | |
QString | username () const |
Returns the username stored in the URI. More... | |
QgsWkbTypes::Type | wkbType () const |
Returns the WKB type associated with the URI. 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 the password element from a URI. More... | |
Class for storing the component parts of a RDBMS data source URI (e.g.
a Postgres data source).
This structure stores the database connection information, including host, database, user name, password, schema, password, and SQL where clause.
Definition at line 35 of file qgsdatasourceuri.h.
Available SSQL connection modes.
Enumerator | |
---|---|
SslPrefer | |
SslDisable | |
SslAllow | |
SslRequire | |
SslVerifyCa | |
SslVerifyFull |
Definition at line 43 of file qgsdatasourceuri.h.
QgsDataSourceUri::QgsDataSourceUri | ( | ) |
Definition at line 29 of file qgsdatasourceuri.cpp.
QgsDataSourceUri::QgsDataSourceUri | ( | const QString & | uri | ) |
Constructor for QgsDataSourceUri which parses an input uri string.
Definition at line 34 of file qgsdatasourceuri.cpp.
QgsDataSourceUri::QgsDataSourceUri | ( | const QByteArray & | uri | ) |
Constructor for QgsDataSourceUri which parses an input encoded uri).
QString QgsDataSourceUri::authConfigId | ( | ) | const |
Returns any associated authentication configuration ID stored in the URI.
Definition at line 250 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::clearSchema | ( | ) |
Clears the schema stored in the URI.
Definition at line 368 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::connectionInfo | ( | bool | expandAuthConfig = true | ) | const |
Returns the connection part of the URI.
Definition at line 462 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::database | ( | ) | const |
Returns the database name stored in the URI.
Definition at line 275 of file qgsdatasourceuri.cpp.
|
static |
Decodes SSL mode string into enum value.
If the string is not recognized, SslPrefer is returned.
Definition at line 691 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::disableSelectAtId | ( | bool | flag | ) |
Set to true
to disable selection by feature ID.
Definition at line 353 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::driver | ( | ) | const |
Returns the driver name stored in the URI.
Definition at line 295 of file qgsdatasourceuri.cpp.
QByteArray QgsDataSourceUri::encodedUri | ( | ) | const |
Returns the complete encoded URI as a byte array.
Definition at line 577 of file qgsdatasourceuri.cpp.
|
static |
Encodes SSL mode enum value into a string.
Definition at line 709 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::geometryColumn | ( | ) | const |
Returns the name of the geometry column stored in the URI, if set.
Definition at line 320 of file qgsdatasourceuri.cpp.
bool QgsDataSourceUri::hasParam | ( | const QString & | key | ) | const |
Returns true
if a parameter with the specified key exists.
Definition at line 753 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::host | ( | ) | const |
Returns the host name stored in the URI.
Definition at line 270 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::keyColumn | ( | ) | const |
Returns the name of the (primary) key column for the referenced table.
Definition at line 325 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::param | ( | const QString & | key | ) | const |
Returns a generic parameter value corresponding to the specified key.
Definition at line 743 of file qgsdatasourceuri.cpp.
QStringList QgsDataSourceUri::params | ( | const QString & | key | ) | const |
Returns multiple generic parameter values corresponding to the specified key.
Definition at line 748 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::password | ( | ) | const |
Returns the password stored in the URI.
Definition at line 280 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::port | ( | ) | const |
Returns the port stored in the URI.
Definition at line 290 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::quotedTablename | ( | ) | const |
Returns the URI's table name, escaped and quoted.
Definition at line 605 of file qgsdatasourceuri.cpp.
int QgsDataSourceUri::removeParam | ( | const QString & | key | ) |
Removes a generic parameter by key.
Definition at line 738 of file qgsdatasourceuri.cpp.
|
static |
Removes the password element from a URI.
Definition at line 216 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::schema | ( | ) | const |
Returns the schema stored in the URI.
Definition at line 305 of file qgsdatasourceuri.cpp.
bool QgsDataSourceUri::selectAtIdDisabled | ( | ) | const |
Returns whether the selection by feature ID is disabled.
Definition at line 358 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::service | ( | ) | const |
Returns the service name associated with the URI.
Definition at line 265 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setAuthConfigId | ( | const QString & | authcfg | ) |
Sets the authentication configuration ID for the URI.
Definition at line 661 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 616 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 a service case).
Definition at line 633 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setDatabase | ( | const QString & | database | ) |
Sets the URI database name.
Definition at line 666 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 648 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setDriver | ( | const QString & | driver | ) |
Sets the driver name stored in the URI.
Definition at line 331 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setEncodedUri | ( | const QByteArray & | uri | ) |
Sets the complete encoded uri.
Definition at line 587 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setEncodedUri | ( | const QString & | uri | ) |
Sets the complete encoded uri from a string value.
Definition at line 600 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setKeyColumn | ( | const QString & | column | ) |
Sets the name of the (primary) key column.
Definition at line 337 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setParam | ( | const QString & | key, |
const QString & | value | ||
) |
Sets a generic parameter value on the URI.
Definition at line 723 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setParam | ( | const QString & | key, |
const QStringList & | value | ||
) |
Sets a generic parameter list value on the URI.
Definition at line 729 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setPassword | ( | const QString & | password | ) |
Sets the password for the URI.
Definition at line 285 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setSchema | ( | const QString & | schema | ) |
void QgsDataSourceUri::setSql | ( | const QString & | sql | ) |
Sets the SQL query for the URI.
Definition at line 363 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setSrid | ( | const QString & | srid | ) |
Sets the spatial reference ID associated with the URI.
Definition at line 686 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setUseEstimatedMetadata | ( | bool | flag | ) |
Sets whether estimated metadata should be used for the connection.
Definition at line 343 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setUsername | ( | const QString & | username | ) |
Sets the username for the URI.
Definition at line 260 of file qgsdatasourceuri.cpp.
void QgsDataSourceUri::setWkbType | ( | QgsWkbTypes::Type | type | ) |
Sets the WKB type associated with the URI.
Definition at line 676 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::sql | ( | ) | const |
Returns the SQL query stored in the URI, if set.
Definition at line 315 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::srid | ( | ) | const |
Returns the spatial reference ID associated with the URI.
Definition at line 681 of file qgsdatasourceuri.cpp.
QgsDataSourceUri::SslMode QgsDataSourceUri::sslMode | ( | ) | const |
Returns the SSL mode associated with the URI.
Definition at line 300 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::table | ( | ) | const |
Returns the table name stored in the URI.
Definition at line 310 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::uri | ( | bool | expandAuthConfig = true | ) | const |
Returns the complete URI as a string.
Definition at line 524 of file qgsdatasourceuri.cpp.
bool QgsDataSourceUri::useEstimatedMetadata | ( | ) | const |
Returns true
if estimated metadata should be used for the connection.
Definition at line 348 of file qgsdatasourceuri.cpp.
QString QgsDataSourceUri::username | ( | ) | const |
Returns the username stored in the URI.
Definition at line 255 of file qgsdatasourceuri.cpp.
QgsWkbTypes::Type QgsDataSourceUri::wkbType | ( | ) | const |
Returns the WKB type associated with the URI.
Definition at line 671 of file qgsdatasourceuri.cpp.