~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/corelib/io/qurl.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the core module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QURL_H
 
30
#define QURL_H
 
31
 
 
32
#include <QtCore/qobjectdefs.h>
 
33
#include <QtCore/qpair.h>
 
34
#include <QtCore/qstring.h>
 
35
 
 
36
class QByteArray;
 
37
class QUrlPrivate;
 
38
class QDataStream;
 
39
 
 
40
class Q_CORE_EXPORT QUrl
 
41
{
 
42
public:
 
43
    QUrl();
 
44
    QUrl(const QString &url);
 
45
    QUrl(const QUrl &copy);
 
46
    ~QUrl();
 
47
 
 
48
    // encoding / toString values
 
49
    enum FormattingOption {
 
50
        None = 0x0,
 
51
        RemoveScheme = 0x1,
 
52
        RemovePassword = 0x2,
 
53
        RemoveUserInfo = RemovePassword | 0x4,
 
54
        RemovePort = 0x8,
 
55
        RemoveAuthority = RemoveUserInfo | RemovePort | 0x10,
 
56
        RemovePath = 0x20,
 
57
        RemoveQuery = 0x40,
 
58
        RemoveFragment = 0x80,
 
59
 
 
60
        StripTrailingSlash = 0x10000
 
61
    };
 
62
    Q_DECLARE_FLAGS(FormattingOptions, FormattingOption)
 
63
 
 
64
    void setUrl(const QString &url);
 
65
    void setEncodedUrl(const QByteArray &url);
 
66
 
 
67
    bool isValid() const;
 
68
 
 
69
    bool isEmpty() const;
 
70
 
 
71
    void clear();
 
72
 
 
73
    void setScheme(const QString &scheme);
 
74
    QString scheme() const;
 
75
 
 
76
    void setAuthority(const QString &authority);
 
77
    QString authority() const;
 
78
 
 
79
    void setUserInfo(const QString &userInfo);
 
80
    QString userInfo() const;
 
81
 
 
82
    void setUserName(const QString &userName);
 
83
    QString userName() const;
 
84
 
 
85
    void setPassword(const QString &password);
 
86
    QString password() const;
 
87
 
 
88
    void setHost(const QString &host);
 
89
    QString host() const;
 
90
 
 
91
    void setPort(int port);
 
92
    int port() const;
 
93
 
 
94
    void setPath(const QString &path);
 
95
    QString path() const;
 
96
 
 
97
    void setEncodedQuery(const QByteArray &query);
 
98
    QByteArray encodedQuery() const;
 
99
 
 
100
    void setQueryDelimiters(char valueDelimiter, char pairDelimiter);
 
101
    char queryValueDelimiter() const;
 
102
    char queryPairDelimiter() const;
 
103
 
 
104
    void setQueryItems(const QList<QPair<QString, QString> > &query);
 
105
    void addQueryItem(const QString &key, const QString &value);
 
106
    QList<QPair<QString, QString> > queryItems() const;
 
107
    bool hasQueryItem(const QString &key) const;
 
108
    QString queryItemValue(const QString &key) const;
 
109
    QStringList allQueryItemValues(const QString &key) const;
 
110
    void removeQueryItem(const QString &key);
 
111
    void removeAllQueryItems(const QString &key);
 
112
    
 
113
 
 
114
    void setFragment(const QString &fragment);
 
115
    QString fragment() const;
 
116
 
 
117
    QUrl resolved(const QUrl &relative) const;
 
118
 
 
119
    bool isRelative() const;
 
120
    bool isParentOf(const QUrl &url) const;
 
121
 
 
122
    static QUrl fromLocalFile(const QString &localfile);
 
123
    QString toLocalFile() const;
 
124
 
 
125
    QString toString(FormattingOptions options = None) const;
 
126
 
 
127
    QByteArray toEncoded(FormattingOptions options = None) const;
 
128
    static QUrl fromEncoded(const QByteArray &url);
 
129
 
 
130
    void detach();
 
131
    bool isDetached() const;
 
132
 
 
133
    bool operator <(const QUrl &url) const;
 
134
    bool operator ==(const QUrl &url) const;
 
135
    bool operator !=(const QUrl &url) const;
 
136
    QUrl &operator =(const QUrl &copy);
 
137
 
 
138
    static QString fromPercentEncoding(const QByteArray &);
 
139
    static QByteArray toPercentEncoding(const QString &,
 
140
                                        const QByteArray &exclude = QByteArray(),
 
141
                                        const QByteArray &include = QByteArray());
 
142
    static QString fromPunycode(const QByteArray &);
 
143
    static QByteArray toPunycode(const QString &);
 
144
 
 
145
#if defined QT3_SUPPORT
 
146
    inline QT3_SUPPORT QString protocol() const { return scheme(); }
 
147
    inline QT3_SUPPORT void setProtocol(const QString &s) { setScheme(s); }
 
148
    inline QT3_SUPPORT void setUser(const QString &s) { setUserName(s); }
 
149
    inline QT3_SUPPORT QString user() const { return userName(); }
 
150
    inline QT3_SUPPORT bool hasUser() const { return !userName().isEmpty(); }
 
151
    inline QT3_SUPPORT bool hasPassword() const { return !password().isEmpty(); }
 
152
    inline QT3_SUPPORT bool hasHost() const { return !host().isEmpty(); }
 
153
    inline QT3_SUPPORT bool hasPort() const { return port() != -1; }
 
154
    inline QT3_SUPPORT bool hasPath() const { return !path().isEmpty(); }
 
155
    inline QT3_SUPPORT void setQuery(const QString &txt)
 
156
    {
 
157
        setEncodedQuery(txt.toLatin1());
 
158
    }
 
159
    inline QT3_SUPPORT QString query() const
 
160
    {
 
161
        return QString::fromLatin1(encodedQuery());
 
162
    }
 
163
    inline QT3_SUPPORT QString ref() const { return fragment(); }
 
164
    inline QT3_SUPPORT void setRef(const QString &txt) { setFragment(txt); }
 
165
    inline QT3_SUPPORT bool hasRef() const { return !fragment().isEmpty(); }
 
166
    inline QT3_SUPPORT void addPath(const QString &p) { setPath(path() + QLatin1String("/") + p); }
 
167
    QT3_SUPPORT void setFileName(const QString &txt);
 
168
    QT3_SUPPORT QString fileName() const;
 
169
    QT3_SUPPORT QString dirPath() const;
 
170
    static inline QT3_SUPPORT void decode(QString &url)
 
171
    {
 
172
        url = QUrl::fromPercentEncoding(url.toLatin1());
 
173
    }
 
174
    static inline QT3_SUPPORT void encode(QString &url)
 
175
    {
 
176
        url = QString::fromLatin1(QUrl::toPercentEncoding(url));
 
177
    }
 
178
    inline QT3_SUPPORT operator QString() const { return toString(); }
 
179
    inline QT3_SUPPORT bool cdUp()
 
180
    {
 
181
        *this = resolved(QUrl(QLatin1String("..")));
 
182
        return true;
 
183
    }
 
184
    static inline QT3_SUPPORT bool isRelativeUrl(const QString &url)
 
185
    {
 
186
        return QUrl(url).isRelative();
 
187
    }
 
188
#endif
 
189
 
 
190
protected:
 
191
#if defined (QT3_SUPPORT)
 
192
    inline QT3_SUPPORT void reset() { clear(); }
 
193
#endif
 
194
 
 
195
    QUrl(QUrlPrivate &d);
 
196
 
 
197
private:
 
198
    QUrlPrivate *d;
 
199
};
 
200
 
 
201
Q_DECLARE_TYPEINFO(QUrl, Q_MOVABLE_TYPE);
 
202
Q_DECLARE_SHARED(QUrl)
 
203
Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::FormattingOptions)
 
204
 
 
205
#ifndef QT_NO_DATASTREAM
 
206
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QUrl &);
 
207
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QUrl &);
 
208
#endif
 
209
 
 
210
#ifndef QT_NO_DEBUG_STREAM
 
211
Q_CORE_EXPORT QDebug operator<<(QDebug, const QUrl &);
 
212
#endif
 
213
 
 
214
#endif // QURL_H