6 #ifndef SWIFT_MISC_NETWORK_URL_H
7 #define SWIFT_MISC_NETWORK_URL_H
11 #include <QNetworkRequest>
22 namespace swift::misc::network
32 IndexScheme = CPropertyIndexRef::GlobalIndexCUrl,
40 CUrl(
const QString &fullUrl = QString());
43 CUrl(
const char *url);
46 CUrl(
const QUrl &url);
49 CUrl(
const QString &address,
int port);
52 CUrl(
const QString &scheme,
const QString &address,
int port,
const QString &path);
55 const QString &
getHost()
const {
return m_host; }
58 void setHost(
const QString &address) { m_host = address.trimmed(); }
61 const QString &
getScheme()
const {
return m_scheme; }
64 void setScheme(
const QString &protocol);
67 bool hasScheme()
const {
return !m_scheme.isEmpty(); }
70 const QString &
getPath()
const {
return m_path; }
73 void setPath(
const QString &path);
76 QString appendPath(
const QString &pathToAppend);
79 bool hasPath()
const {
return !m_path.isEmpty(); }
91 bool hasDefaultPort()
const;
97 void setQuery(
const QString &query);
100 bool hasQuery()
const;
103 void appendQuery(
const QString &queryToAppend);
106 void appendQuery(
const QString &key,
const QString &value);
109 bool hasFragment()
const;
112 void setFragment(
const QString &fragment);
115 bool isEmpty()
const;
118 QString getFullUrl(
bool withQuery =
true)
const;
121 void setFullUrl(
const QString &fullUrl);
124 QString getFileName()
const;
130 void setQUrl(
const QUrl &url);
133 QNetworkRequest toNetworkRequest()
const;
136 CUrl withAppendedPath(
const QString &path)
const;
139 CUrl withAppendedQuery(
const QString &query)
const;
142 CUrl withSwitchedScheme(
const QString &protocol,
int port)
const;
145 bool pathEndsWith(
const QString &ending, Qt::CaseSensitivity cs = Qt::CaseInsensitive)
const;
152 bool isFileWithSuffix(
const QString &suffix = {})
const;
156 QString getFileSuffix()
const;
159 QString getFileSuffixPlusDot()
const;
162 bool isHavingHtmlSuffix()
const;
165 bool isExecutableFile()
const;
168 bool isSwiftInstaller()
const;
177 QString convertToQString(
bool i18n =
false)
const;
180 QJsonObject toJson()
const;
183 void convertFromJson(
const QJsonObject &json);
186 static int protocolToDefaultPort(
const QString &protocol);
189 static bool isDefaultPort(
const QString &protocol,
int port);
192 static CUrl fromLocalFile(
const QString &localFile);
195 operator QUrl()
const {
return this->toQUrl(); }
205 static QString stripQueryString(
const QString &query);
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
ColumnIndex
Base class enums.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
bool hasPath() const
Has path?
QString getQuery() const
Get query part.
bool hasScheme() const
Protocol.
const QString & getScheme() const
Get protocl.
const QString & getHost() const
Get host.
void setHost(const QString &address)
Set address (e.g. myserver.foo.com)
void setPort(int port)
Set port.
const QString & getPath() const
Get path.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...