Quantum GIS API Documentation
1.8
|
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 00029 class CORE_EXPORT QgsDataSourceURI 00030 { 00031 public: 00033 enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire }; 00034 00036 QgsDataSourceURI(); 00037 00039 QgsDataSourceURI( QString uri ); 00040 00042 QString connectionInfo() const; 00043 00045 QString uri() const; 00046 00048 QString quotedTablename() const; 00049 00052 void setConnection( const QString& aHost, 00053 const QString& aPort, 00054 const QString& aDatabase, 00055 const QString& aUsername, 00056 const QString& aPassword, 00057 SSLmode sslmode = SSLprefer ); 00058 00061 void setConnection( const QString& aService, 00062 const QString& aDatabase, 00063 const QString& aUsername, 00064 const QString& aPassword, 00065 SSLmode sslmode = SSLprefer ); 00066 00068 // \note added in 1.4 00069 void setDatabase( const QString &database ); 00070 00072 void setDataSource( const QString& aSchema, 00073 const QString& aTable, 00074 const QString& aGeometryColumn, 00075 const QString& aSql = QString(), 00076 const QString& aKeyColumn = QString() ); 00077 00079 // added in 1.5 00080 void setUsername( QString username ); 00081 00083 // added in 1.5 00084 void setPassword( QString password ); 00085 00087 static QString removePassword( const QString& aUri ); 00088 00089 QString username() const; 00090 QString schema() const; 00091 QString table() const; 00092 QString sql() const; 00093 QString geometryColumn() const; 00094 00096 // added in 1.5 00097 void setUseEstimatedMetadata( bool theFlag ); 00098 bool useEstimatedMetadata() const; 00099 00100 void disableSelectAtId( bool theFlag ); 00101 bool selectAtIdDisabled() const; 00102 00103 void clearSchema(); 00104 void setSql( QString sql ); 00105 00106 // added in version 1.1 00107 QString host() const; 00108 QString database() const; 00109 QString port() const; 00110 QString password() const; 00111 enum SSLmode sslMode() const; 00112 00113 // added in 1.7 00114 QString service() const; 00115 00116 // added in version 1.2 00117 QString keyColumn() const; 00118 void setKeyColumn( QString column ); 00119 00120 // added in 1.9 00121 QGis::WkbType wkbType() const; 00122 void setWkbType( QGis::WkbType type ); 00123 00124 QString srid() const; 00125 void setSrid( QString srid ); 00126 00127 private: 00128 void skipBlanks( const QString &uri, int &i ); 00129 QString getValue( const QString &uri, int &i ); 00130 QString escape( const QString &uri, QChar delim ) const; 00131 00132 /* data */ 00133 00135 QString mHost; 00137 QString mPort; 00139 QString mService; 00141 QString mDatabase; 00143 QString mSchema; 00145 QString mTable; 00147 QString mGeometryColumn; 00149 QString mSql; 00151 QString mUsername; 00153 QString mPassword; 00155 enum SSLmode mSSLmode; 00157 QString mKeyColumn; 00159 bool mUseEstimatedMetadata; 00161 bool mSelectAtIdDisabled; 00163 QGis::WkbType mWkbType; 00165 QString mSrid; 00166 }; 00167 00168 #endif //QGSDATASOURCEURI_H 00169