1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtCore module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
49 // This file is not part of the Qt API. It exists for the convenience of
50 // qurl*.cpp This header file may change from version to version without
51 // notice, or even be removed.
60 struct QUrlErrorInfo {
61 inline QUrlErrorInfo() : _source(0), _message(0), _expected(0), _found(0)
69 inline void setParams(const char *source, const char *message, char expected, char found)
85 UserInfo = UserName | Password,
88 Authority = UserInfo | Host | Port,
90 Hierarchy = Authority | Path,
96 QUrlPrivate(const QUrlPrivate ©);
98 void parse(const QString &url);
101 // no QString scheme() const;
102 void appendAuthority(QString &appendTo, QUrl::FormattingOptions options) const;
103 void appendUserInfo(QString &appendTo, QUrl::FormattingOptions options) const;
104 void appendUserName(QString &appendTo, QUrl::FormattingOptions options) const;
105 void appendPassword(QString &appendTo, QUrl::FormattingOptions options) const;
106 void appendHost(QString &appendTo, QUrl::FormattingOptions options) const;
107 void appendPath(QString &appendTo, QUrl::FormattingOptions options) const;
108 void appendQuery(QString &appendTo, QUrl::FormattingOptions options) const;
109 void appendFragment(QString &appendTo, QUrl::FormattingOptions options) const;
111 // the "end" parameters are like STL iterators: they point to one past the last valid element
112 bool setScheme(const QString &value, int len, bool decoded = false);
113 bool setAuthority(const QString &auth, int from, int end);
114 void setUserInfo(const QString &userInfo, int from, int end);
115 void setUserName(const QString &value, int from, int end);
116 void setPassword(const QString &value, int from, int end);
117 bool setHost(const QString &value, int from, int end, bool maybePercentEncoded = true);
118 void setPath(const QString &value, int from, int end);
119 void setQuery(const QString &value, int from, int end);
120 void setFragment(const QString &value, int from, int end);
122 inline bool hasScheme() const { return sectionIsPresent & Scheme; }
123 inline bool hasAuthority() const { return sectionIsPresent & Authority; }
124 inline bool hasUserInfo() const { return sectionIsPresent & UserInfo; }
125 inline bool hasUserName() const { return sectionIsPresent & UserName; }
126 inline bool hasPassword() const { return sectionIsPresent & Password; }
127 inline bool hasHost() const { return sectionIsPresent & Host; }
128 inline bool hasPort() const { return port != -1; }
129 inline bool hasPath() const { return !path.isEmpty(); }
130 inline bool hasQuery() const { return sectionIsPresent & Query; }
131 inline bool hasFragment() const { return sectionIsPresent & Fragment; }
133 QString mergePaths(const QString &relativePath) const;
147 // - Port (port == -1 means absence)
148 // - Path (there's no path delimiter, so we optimize its use out of existence)
149 // Schemes are never supposed to be empty, but we keep the flag anyway
150 uchar sectionIsPresent;
152 // UserName, Password, Path, Query, and Fragment never contain errors in TolerantMode.
153 // Those flags are set only by the strict parser.
154 uchar sectionHasError;
156 mutable QUrlErrorInfo errorInfo;
157 QString createErrorString();
162 extern Q_AUTOTEST_EXPORT int qt_urlRecode(QString &appendTo, const QChar *begin, const QChar *end,
163 QUrl::ComponentFormattingOptions encoding, const ushort *tableModifications);
166 enum AceOperation { ToAceOnly, NormalizeAce };
167 extern QString qt_ACE_do(const QString &domain, AceOperation op);
168 extern Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from);
169 extern Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QChar *uc, int len);
170 extern Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString *output);
171 extern Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc);