~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/core/qgsdatasourceuri.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef QGSDATASOURCEURI_H
2
 
#define QGSDATASOURCEURI_H
3
1
/***************************************************************************
4
2
      qgsdatasourceuri.h  -  Structure to contain the component parts
5
3
                             of a data source URI
17
15
 *   (at your option) any later version.                                   *
18
16
 *                                                                         *
19
17
 ***************************************************************************/
20
 
/* $Id: qgsdatasourceuri.h 5423 2006-05-07 05:29:25Z g_j_m $ */
21
 
/** 
22
 
\struct QgsDataSourceURI 
23
 
\brief Structure for storing the component parts of a PostgreSQL/RDBMS datasource URI.
24
 
           
25
 
 This structure stores the database connection information, including host, database,
26
 
  user name, password, schema, password, and sql where clause
 
18
/* $Id$ */
 
19
 
 
20
#ifndef QGSDATASOURCEURI_H
 
21
#define QGSDATASOURCEURI_H
 
22
 
 
23
#include <QString>
 
24
 
 
25
/** \ingroup core
 
26
 * Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
 
27
 * This structure stores the database connection information, including host, database,
 
28
 * user name, password, schema, password, and sql where clause
27
29
 */
28
 
#include <QString> 
29
 
class QgsDataSourceURI
 
30
class CORE_EXPORT QgsDataSourceURI
30
31
{
31
 
 public:
32
 
  //! host name
33
 
  QString host;
34
 
  //! database name
35
 
  QString database;
36
 
  //! port the database server listens on
37
 
  QString port;
38
 
  //! schema
39
 
  QString schema;
40
 
  //! spatial table
41
 
  QString table;
42
 
  //! geometry column
43
 
  QString geometryColumn;
44
 
  //! SQL where clause used to limit features returned from the layer
45
 
  QString sql;
46
 
  //! username 
47
 
  QString username;
48
 
  //! password
49
 
  QString password;
50
 
  //! All in a single string
51
 
  QString text()
52
 
    {
53
 
      return QString("host=" + host + 
54
 
                     " dbname=" + database + 
55
 
                     " port=" + port + 
56
 
                     " user=" + username + 
57
 
                     " password=" + password + 
58
 
                     " table=" + schema + '.' + table + 
59
 
                     " (" + geometryColumn + ")" +
60
 
                     " sql=" + sql);
61
 
    }
62
 
  };
 
32
  public:
 
33
    //! \note enumeration added in version 1.1
 
34
    enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };
 
35
 
 
36
    //! default constructor
 
37
    QgsDataSourceURI();
 
38
 
 
39
    //! constructor which parses input URI
 
40
    QgsDataSourceURI( QString uri );
 
41
 
 
42
    //! return connection part of URI
 
43
    QString connectionInfo() const;
 
44
 
 
45
    //! return complete uri
 
46
    QString uri() const;
 
47
 
 
48
    //! quoted table name
 
49
    QString quotedTablename() const;
 
50
 
 
51
    //! Set all connection related members at once
 
52
    //! \note This optional sslmode parameter has been added in version 1.1
 
53
    void setConnection( const QString& aHost,
 
54
                        const QString& aPort,
 
55
                        const QString& aDatabase,
 
56
                        const QString& aUsername,
 
57
                        const QString& aPassword,
 
58
                        SSLmode sslmode = SSLprefer );
 
59
 
 
60
    //! Set database
 
61
    // \note added in 1.4
 
62
    void setDatabase( const QString &database );
 
63
 
 
64
    //! Set all data source related members at once
 
65
    void setDataSource( const QString& aSchema,
 
66
                        const QString& aTable,
 
67
                        const QString& aGeometryColumn,
 
68
                        const QString& aSql = QString(),
 
69
                        const QString& aKeyColumn = QString() );
 
70
 
 
71
    //! Removes password element from uris
 
72
    static QString removePassword( const QString& aUri );
 
73
 
 
74
    QString username() const;
 
75
    QString schema() const;
 
76
    QString table() const;
 
77
    QString sql() const;
 
78
    QString geometryColumn() const;
 
79
 
 
80
    void clearSchema();
 
81
    void setSql( QString sql );
 
82
 
 
83
    // added in version 1.1
 
84
    QString host() const;
 
85
    QString database() const;
 
86
    QString port() const;
 
87
    QString password() const;
 
88
    enum SSLmode sslMode() const;
 
89
 
 
90
    // added in version 1.2
 
91
    QString keyColumn() const;
 
92
    void setKeyColumn( QString column );
 
93
 
 
94
  private:
 
95
    void skipBlanks( const QString &uri, int &i );
 
96
    QString getValue( const QString &uri, int &i );
 
97
    QString escape( const QString &uri ) const;
 
98
 
 
99
    /* data */
 
100
 
 
101
    //! host name
 
102
    QString mHost;
 
103
    //! database name
 
104
    QString mDatabase;
 
105
    //! port the database server listens on
 
106
    QString mPort;
 
107
    //! schema
 
108
    QString mSchema;
 
109
    //! spatial table
 
110
    QString mTable;
 
111
    //! geometry column
 
112
    QString mGeometryColumn;
 
113
    //! SQL where clause used to limit features returned from the layer
 
114
    QString mSql;
 
115
    //! username
 
116
    QString mUsername;
 
117
    //! password
 
118
    QString mPassword;
 
119
    //! ssl mode
 
120
    enum SSLmode mSSLmode;
 
121
    //! key column
 
122
    QString mKeyColumn;
 
123
};
 
124
 
63
125
#endif //QGSDATASOURCEURI_H
64
126