QGIS API Documentation  master-59fd5e0
QgsDataSourceURI Class Reference

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

#include <qgsdatasourceuri.h>

List of all members.

Public Types

enum  SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire }

Public Member Functions

 QgsDataSourceURI ()
 default constructor
 QgsDataSourceURI (QString uri)
 constructor which parses input URI
 QgsDataSourceURI (const QByteArray &uri)
 constructor which parses input encoded URI (generic mode)
void clearSchema ()
QString connectionInfo () const
 return connection part of URI
QString database () const
void disableSelectAtId (bool theFlag)
QByteArray encodedUri () const
 return complete encoded uri (generic mode)
QString geometryColumn () const
bool hasParam (const QString &key) const
 Test if param exists (generic mode)
QString host () const
QString keyColumn () const
QString param (const QString &key) const
 Get generic param (generic mode)
QStringList params (const QString &key) const
 Get multiple generic param (generic mode)
QString password () const
QString port () const
QString quotedTablename () const
 quoted table name
int removeParam (const QString &key)
 Remove generic param (generic mode)
QString schema () const
bool selectAtIdDisabled () const
QString service () const
void setConnection (const QString &aHost, const QString &aPort, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SSLmode sslmode=SSLprefer)
 Set all connection related members at once.
void setConnection (const QString &aService, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SSLmode sslmode=SSLprefer)
 Set all connection related members at once (for the service case)
void setDatabase (const QString &database)
 Set database.
void setDataSource (const QString &aSchema, const QString &aTable, const QString &aGeometryColumn, const QString &aSql=QString(), const QString &aKeyColumn=QString())
 Set all data source related members at once.
void setEncodedUri (const QByteArray &uri)
 set complete encoded uri (generic mode)
void setEncodedUri (const QString &uri)
 set complete encoded uri (generic mode)
void setKeyColumn (QString column)
void setParam (const QString &key, const QString &value)
 Set generic param (generic mode)
void setParam (const QString &key, const QStringList &value)
void setPassword (QString password)
 set password
void setSql (QString sql)
void setSrid (QString srid)
void setUseEstimatedMetadata (bool theFlag)
 set use Estimated Metadata
void setUsername (QString username)
 set username
void setWkbType (QGis::WkbType type)
QString sql () const
QString srid () const
enum SSLmode sslMode () const
QString table () const
QString uri () const
 return complete uri
bool useEstimatedMetadata () const
QString username () const
QGis::WkbType wkbType () const

Static Public Member Functions

static QString removePassword (const QString &aUri)
 Removes password element from uris.

Private Member Functions

QString escape (const QString &uri, QChar delim) const
QString getValue (const QString &uri, int &i)
void skipBlanks (const QString &uri, int &i)

Private Attributes

QString mDatabase
 database name
QString mGeometryColumn
 geometry column
QString mHost
 host name
QString mKeyColumn
 key column
QMap< QString, QString > mParams
 Generic params store.
QString mPassword
 password
QString mPort
 port the database server listens on
QString mSchema
 schema
bool mSelectAtIdDisabled
 Disable SelectAtId capability (eg. to trigger the attribute table memory model for expensive views)
QString mService
 service name
QString mSql
 SQL query or where clause used to limit features returned from the layer.
QString mSrid
 SRID or a null string if not specified.
enum SSLmode mSSLmode
 ssl mode
QString mTable
 spatial table
bool mUseEstimatedMetadata
 Use estimated metadata flag.
QString mUsername
 username
QGis::WkbType mWkbType
 geometry type (or QGis::WKBUnknown if not specified)

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. (Radim Blazek 4/2012)

Definition at line 35 of file qgsdatasourceuri.h.


Member Enumeration Documentation

Note:
enumeration added in version 1.1
Enumerator:
SSLprefer 
SSLdisable 
SSLallow 
SSLrequire 

Definition at line 39 of file qgsdatasourceuri.h.


Constructor & Destructor Documentation

default constructor

Definition at line 26 of file qgsdatasourceuri.cpp.

QgsDataSourceURI::QgsDataSourceURI ( const QByteArray &  uri)

constructor which parses input encoded URI (generic mode)


Member Function Documentation

Definition at line 384 of file qgsdatasourceuri.cpp.

References mSchema.

return connection part of URI

Definition at line 473 of file qgsdatasourceuri.cpp.

References escape(), mDatabase, mHost, mPassword, mPort, mService, mSSLmode, mUsername, SSLallow, SSLdisable, SSLprefer, and SSLrequire.

Referenced by uri().

void QgsDataSourceURI::disableSelectAtId ( bool  theFlag)

Definition at line 369 of file qgsdatasourceuri.cpp.

References mSelectAtIdDisabled.

QByteArray QgsDataSourceURI::encodedUri ( ) const

return complete encoded uri (generic mode)

Definition at line 605 of file qgsdatasourceuri.cpp.

References mParams.

Referenced by QgsMapLayer::readLayerXML(), and QgsRasterLayer::readXml().

QString QgsDataSourceURI::escape ( const QString &  uri,
QChar  delim = '\'' 
) const [private]

Definition at line 389 of file qgsdatasourceuri.cpp.

Referenced by connectionInfo(), quotedTablename(), and uri().

Definition at line 343 of file qgsdatasourceuri.cpp.

References mGeometryColumn.

Referenced by setDataSource().

QString QgsDataSourceURI::getValue ( const QString &  uri,
int &  i 
) [private]

Definition at line 406 of file qgsdatasourceuri.cpp.

References QgsDebugMsg, and skipBlanks().

Referenced by QgsDataSourceURI().

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

Test if param exists (generic mode)

Definition at line 741 of file qgsdatasourceuri.cpp.

References mParams.

QString QgsDataSourceURI::host ( ) const

Definition at line 298 of file qgsdatasourceuri.cpp.

References mHost.

Referenced by setConnection(), and QgsMapLayer::writeLayerXML().

QString QgsDataSourceURI::keyColumn ( ) const

Definition at line 348 of file qgsdatasourceuri.cpp.

References mKeyColumn.

Referenced by setDataSource().

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

Get generic param (generic mode)

Definition at line 731 of file qgsdatasourceuri.cpp.

References mParams.

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

Get multiple generic param (generic mode)

Definition at line 736 of file qgsdatasourceuri.cpp.

References mParams.

QString QgsDataSourceURI::password ( ) const

Definition at line 308 of file qgsdatasourceuri.cpp.

References mPassword.

Referenced by setConnection(), setPassword(), and QgsMapLayer::writeLayerXML().

QString QgsDataSourceURI::port ( ) const

Definition at line 318 of file qgsdatasourceuri.cpp.

References mPort.

Referenced by setConnection(), and QgsMapLayer::writeLayerXML().

quoted table name

Definition at line 635 of file qgsdatasourceuri.cpp.

References escape(), mSchema, and mTable.

Referenced by uri().

int QgsDataSourceURI::removeParam ( const QString &  key)

Remove generic param (generic mode)

Definition at line 726 of file qgsdatasourceuri.cpp.

References mParams.

QString QgsDataSourceURI::removePassword ( const QString &  aUri) [static]

Removes password element from uris.

Definition at line 249 of file qgsdatasourceuri.cpp.

Referenced by QgsMapLayer::publicSource().

QString QgsDataSourceURI::schema ( ) const

Definition at line 328 of file qgsdatasourceuri.cpp.

References mSchema.

Referenced by setDataSource().

Definition at line 374 of file qgsdatasourceuri.cpp.

References mSelectAtIdDisabled.

QString QgsDataSourceURI::service ( ) const

Definition at line 293 of file qgsdatasourceuri.cpp.

References mService.

Referenced by setConnection().

void QgsDataSourceURI::setConnection ( const QString &  aHost,
const QString &  aPort,
const QString &  aDatabase,
const QString &  aUsername,
const QString &  aPassword,
SSLmode  sslmode = SSLprefer 
)

Set all connection related members at once.

Note:
This optional sslmode parameter has been added in version 1.1

Definition at line 646 of file qgsdatasourceuri.cpp.

References database(), host(), mDatabase, mHost, mPassword, mPort, mSSLmode, mUsername, password(), port(), and username().

Referenced by QgsMapLayer::writeLayerXML().

void QgsDataSourceURI::setConnection ( const QString &  aService,
const QString &  aDatabase,
const QString &  aUsername,
const QString &  aPassword,
SSLmode  sslmode = SSLprefer 
)

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

Note:
This optional sslmode parameter has been added in version 1.7

Definition at line 661 of file qgsdatasourceuri.cpp.

References database(), mDatabase, mPassword, mService, mSSLmode, mUsername, password(), service(), and username().

void QgsDataSourceURI::setDatabase ( const QString &  database)

Set database.

Definition at line 687 of file qgsdatasourceuri.cpp.

References database(), and mDatabase.

Referenced by QgsMapLayer::readLayerXML().

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

Set all data source related members at once.

Definition at line 674 of file qgsdatasourceuri.cpp.

References geometryColumn(), keyColumn(), mGeometryColumn, mKeyColumn, mSchema, mSql, mTable, schema(), sql(), and table().

void QgsDataSourceURI::setEncodedUri ( const QByteArray &  uri)

set complete encoded uri (generic mode)

Definition at line 618 of file qgsdatasourceuri.cpp.

References mParams.

Referenced by QgsRasterLayer::readXml(), and setEncodedUri().

void QgsDataSourceURI::setEncodedUri ( const QString &  uri)

set complete encoded uri (generic mode)

Definition at line 630 of file qgsdatasourceuri.cpp.

References setEncodedUri().

void QgsDataSourceURI::setKeyColumn ( QString  column)

Definition at line 353 of file qgsdatasourceuri.cpp.

References mKeyColumn.

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

Set generic param (generic mode)

Definition at line 712 of file qgsdatasourceuri.cpp.

References mParams.

Referenced by QgsOWSConnection::QgsOWSConnection(), QgsMapLayer::readLayerXML(), and QgsRasterLayer::readXml().

void QgsDataSourceURI::setParam ( const QString &  key,
const QStringList &  value 
)

Definition at line 718 of file qgsdatasourceuri.cpp.

References mParams.

void QgsDataSourceURI::setPassword ( QString  password)

set password

Definition at line 313 of file qgsdatasourceuri.cpp.

References mPassword, and password().

void QgsDataSourceURI::setSql ( QString  sql)

Definition at line 379 of file qgsdatasourceuri.cpp.

References mSql, and sql().

void QgsDataSourceURI::setSrid ( QString  srid)

Definition at line 707 of file qgsdatasourceuri.cpp.

References mSrid, and srid().

set use Estimated Metadata

Definition at line 359 of file qgsdatasourceuri.cpp.

References mUseEstimatedMetadata.

void QgsDataSourceURI::setUsername ( QString  username)

set username

Definition at line 288 of file qgsdatasourceuri.cpp.

References mUsername, and username().

Definition at line 697 of file qgsdatasourceuri.cpp.

References mWkbType, and wkbType().

void QgsDataSourceURI::skipBlanks ( const QString &  uri,
int &  i 
) [private]

Definition at line 399 of file qgsdatasourceuri.cpp.

Referenced by getValue(), and QgsDataSourceURI().

QString QgsDataSourceURI::sql ( ) const

Definition at line 338 of file qgsdatasourceuri.cpp.

References mSql.

Referenced by setDataSource(), and setSql().

QString QgsDataSourceURI::srid ( ) const

Definition at line 702 of file qgsdatasourceuri.cpp.

References mSrid.

Referenced by setSrid().

Definition at line 323 of file qgsdatasourceuri.cpp.

References mSSLmode.

QString QgsDataSourceURI::table ( ) const

Definition at line 333 of file qgsdatasourceuri.cpp.

References mTable.

Referenced by QgsOfflineEditing::committedFeaturesAdded(), and setDataSource().

Definition at line 364 of file qgsdatasourceuri.cpp.

References mUseEstimatedMetadata.

QString QgsDataSourceURI::username ( ) const

Definition at line 283 of file qgsdatasourceuri.cpp.

References mUsername.

Referenced by setConnection(), setUsername(), and QgsMapLayer::writeLayerXML().

Definition at line 692 of file qgsdatasourceuri.cpp.

References mWkbType.

Referenced by setWkbType().


Member Data Documentation

QString QgsDataSourceURI::mDatabase [private]

database name

Definition at line 188 of file qgsdatasourceuri.h.

Referenced by connectionInfo(), database(), QgsDataSourceURI(), setConnection(), and setDatabase().

geometry column

Definition at line 194 of file qgsdatasourceuri.h.

Referenced by geometryColumn(), QgsDataSourceURI(), setDataSource(), and uri().

QString QgsDataSourceURI::mHost [private]

host name

Definition at line 182 of file qgsdatasourceuri.h.

Referenced by connectionInfo(), host(), QgsDataSourceURI(), and setConnection().

QString QgsDataSourceURI::mKeyColumn [private]

key column

Definition at line 204 of file qgsdatasourceuri.h.

Referenced by keyColumn(), QgsDataSourceURI(), setDataSource(), setKeyColumn(), and uri().

QMap<QString, QString> QgsDataSourceURI::mParams [private]

Generic params store.

Definition at line 214 of file qgsdatasourceuri.h.

Referenced by encodedUri(), hasParam(), param(), params(), removeParam(), setEncodedUri(), and setParam().

QString QgsDataSourceURI::mPassword [private]

password

Definition at line 200 of file qgsdatasourceuri.h.

Referenced by connectionInfo(), password(), QgsDataSourceURI(), setConnection(), and setPassword().

QString QgsDataSourceURI::mPort [private]

port the database server listens on

Definition at line 184 of file qgsdatasourceuri.h.

Referenced by connectionInfo(), port(), QgsDataSourceURI(), and setConnection().

QString QgsDataSourceURI::mSchema [private]

schema

Definition at line 190 of file qgsdatasourceuri.h.

Referenced by clearSchema(), QgsDataSourceURI(), quotedTablename(), schema(), and setDataSource().

Disable SelectAtId capability (eg. to trigger the attribute table memory model for expensive views)

Definition at line 208 of file qgsdatasourceuri.h.

Referenced by disableSelectAtId(), QgsDataSourceURI(), selectAtIdDisabled(), and uri().

QString QgsDataSourceURI::mService [private]

service name

Definition at line 186 of file qgsdatasourceuri.h.

Referenced by connectionInfo(), QgsDataSourceURI(), service(), and setConnection().

QString QgsDataSourceURI::mSql [private]

SQL query or where clause used to limit features returned from the layer.

Definition at line 196 of file qgsdatasourceuri.h.

Referenced by QgsDataSourceURI(), setDataSource(), setSql(), sql(), and uri().

QString QgsDataSourceURI::mSrid [private]

SRID or a null string if not specified.

Definition at line 212 of file qgsdatasourceuri.h.

Referenced by QgsDataSourceURI(), setSrid(), srid(), and uri().

ssl mode

Definition at line 202 of file qgsdatasourceuri.h.

Referenced by connectionInfo(), QgsDataSourceURI(), setConnection(), and sslMode().

QString QgsDataSourceURI::mTable [private]

spatial table

Definition at line 192 of file qgsdatasourceuri.h.

Referenced by QgsDataSourceURI(), quotedTablename(), setDataSource(), and table().

Use estimated metadata flag.

Definition at line 206 of file qgsdatasourceuri.h.

Referenced by QgsDataSourceURI(), setUseEstimatedMetadata(), uri(), and useEstimatedMetadata().

QString QgsDataSourceURI::mUsername [private]

username

Definition at line 198 of file qgsdatasourceuri.h.

Referenced by connectionInfo(), QgsDataSourceURI(), setConnection(), setUsername(), and username().

geometry type (or QGis::WKBUnknown if not specified)

Definition at line 210 of file qgsdatasourceuri.h.

Referenced by QgsDataSourceURI(), setWkbType(), uri(), and wkbType().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines