QGIS API Documentation  master-3f58142
src/core/qgsdatasourceuri.h
Go to the documentation of this file.
00001 /***************************************************************************
00002       qgsdatasourceuri.h  -  Structure to contain the component parts
00003                              of a data source URI
00004                              -------------------
00005     begin                : Dec 5, 2004
00006     copyright            : (C) 2004 by Gary E.Sherman
00007     email                : sherman at mrcc.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef QGSDATASOURCEURI_H
00020 #define QGSDATASOURCEURI_H
00021 
00022 #include "qgis.h"
00023 
00024 #include <QMap>
00025 
00035 class CORE_EXPORT QgsDataSourceURI
00036 {
00037   public:
00039     enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };
00040 
00042     QgsDataSourceURI();
00043 
00045     QgsDataSourceURI( QString uri );
00046 
00048     // \note added in 1.9
00049     QgsDataSourceURI( const QByteArray & uri );
00050 
00052     QString connectionInfo() const;
00053 
00055     QString uri() const;
00056 
00058     // \note added in 1.9
00059     QByteArray encodedUri() const;
00060 
00062     // \note added in 1.9
00063     // \note not available in python bindings
00064     void setEncodedUri( const QByteArray & uri );
00065 
00067     // \note added in 1.9
00068     void setEncodedUri( const QString & uri );
00069 
00071     QString quotedTablename() const;
00072 
00074     // \note if key exists, another is inserted
00075     // \note added in 1.9
00076     void setParam( const QString &key, const QString &value );
00077     void setParam( const QString &key, const QStringList &value );
00078 
00080     // \note remove all occurrences of key, returns number of params removed
00081     // \note added in 1.9
00082     int removeParam( const QString &key );
00083 
00085     // \note added in 1.9
00086     QString param( const QString &key ) const;
00087 
00089     // \note added in 1.9
00090     QStringList params( const QString &key ) const;
00091 
00093     // \note added in 1.9
00094     bool hasParam( const QString &key ) const;
00095 
00098     void setConnection( const QString& aHost,
00099                         const QString& aPort,
00100                         const QString& aDatabase,
00101                         const QString& aUsername,
00102                         const QString& aPassword,
00103                         SSLmode sslmode = SSLprefer );
00104 
00107     void setConnection( const QString& aService,
00108                         const QString& aDatabase,
00109                         const QString& aUsername,
00110                         const QString& aPassword,
00111                         SSLmode sslmode = SSLprefer );
00112 
00114     // \note added in 1.4
00115     void setDatabase( const QString &database );
00116 
00118     void setDataSource( const QString& aSchema,
00119                         const QString& aTable,
00120                         const QString& aGeometryColumn,
00121                         const QString& aSql = QString(),
00122                         const QString& aKeyColumn = QString() );
00123 
00125     // added in 1.5
00126     void setUsername( QString username );
00127 
00129     // added in 1.5
00130     void setPassword( QString password );
00131 
00133     static QString removePassword( const QString& aUri );
00134 
00135     QString username() const;
00136     QString schema() const;
00137     QString table() const;
00138     QString sql() const;
00139     QString geometryColumn() const;
00140 
00142     // added in 1.5
00143     void setUseEstimatedMetadata( bool theFlag );
00144     bool useEstimatedMetadata() const;
00145 
00146     void disableSelectAtId( bool theFlag );
00147     bool selectAtIdDisabled() const;
00148 
00149     void clearSchema();
00150     void setSql( QString sql );
00151 
00152     // added in version 1.1
00153     QString host() const;
00154     QString database() const;
00155     QString port() const;
00156     QString password() const;
00157     enum SSLmode sslMode() const;
00158 
00159     // added in 1.7
00160     QString service() const;
00161 
00162     // added in version 1.2
00163     QString keyColumn() const;
00164     void setKeyColumn( QString column );
00165 
00166     // added in 1.9
00167     QGis::WkbType wkbType() const;
00168     void setWkbType( QGis::WkbType type );
00169 
00170     // added in 1.9
00171     QString srid() const;
00172     void setSrid( QString srid );
00173 
00174   private:
00175     void skipBlanks( const QString &uri, int &i );
00176     QString getValue( const QString &uri, int &i );
00177     QString escape( const QString &uri, QChar delim ) const;
00178 
00179     /* data */
00180 
00182     QString mHost;
00184     QString mPort;
00186     QString mService;
00188     QString mDatabase;
00190     QString mSchema;
00192     QString mTable;
00194     QString mGeometryColumn;
00196     QString mSql;
00198     QString mUsername;
00200     QString mPassword;
00202     enum SSLmode mSSLmode;
00204     QString mKeyColumn;
00206     bool mUseEstimatedMetadata;
00208     bool mSelectAtIdDisabled;
00210     QGis::WkbType mWkbType;
00212     QString mSrid;
00214     QMap<QString, QString> mParams;
00215 };
00216 
00217 #endif //QGSDATASOURCEURI_H
00218 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines