15namespace swift::misc::network
32 : m_host(address.trimmed()), m_port(port), m_path(path.trimmed())
69 const QString q(stripQueryString(query));
81 const QString q(stripQueryString(queryToAppend));
104 if (m_host.isEmpty())
171 const CUrl url(qurl);
201 if (i < 0)
return {};
202 if (f.
length() <= i + 1)
return {};
210 if (i < 0)
return {};
211 if (f.
length() <= i + 1)
return {};
217 static const QString h1(
".html");
218 static const QString h2(
".htm");
241 const QPair<QString, QJsonValue> v(
"url",
getFullUrl());
259 if (p ==
"ftp")
return 20;
260 if (p ==
"https")
return 443;
261 if (p ==
"http")
return 80;
280 if (q.startsWith(
"?") || q.startsWith(
"&"))
284 if (q.endsWith(
"?") || q.endsWith(
"&"))
286 q = q.left(q.size() - 1);
319 case IndexPort: this->
setPort(variant.
value<qint32>());
break;
static bool isExecutableFile(const QString &fileName)
Executable file (decided by appendix).
static bool isSwiftInstaller(const QString &fileName)
swift installer
static QString appendFilePaths(const QString &path1, const QString &path2)
Append file paths.
Thrown when a convertFromJson method encounters an unrecoverable error in JSON data.
Non-owning reference to a CPropertyIndex with a subset of its features.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
static QNetworkRequest getSwiftNetworkRequest(const QUrl &url, RequestType type=Get, const QString &userAgentDetails={})
Our tweaked network request with swift header.
QString convertToQString(bool i18n=false) const
Cast as QString.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
bool isSwiftInstaller() const
swift installer
CUrl withSwitchedScheme(const QString &protocol, int port) const
Switch protocol.
QString getFileSuffix() const
File appendix if any, otherwise empty, does not include the ".".
bool hasPath() const
Has path?
void setQUrl(const QUrl &url)
To QUrl.
QString getFileName() const
File name.
int getPort() const
Get port.
bool isFile() const
A path ends with "/", and file is anythingy beyond that, e.g. "path/file".
ColumnIndex
Properties by index.
static int protocolToDefaultPort(const QString &protocol)
Protocol to default port.
bool hasScheme() const
Protocol.
QString appendPath(const QString &pathToAppend)
Append path.
const QString & getScheme() const
Get protocl.
QString getFileSuffixPlusDot() const
Suffix plus dot.
CUrl(const QString &fullUrl=QString())
Default constructor.
void setScheme(const QString &protocol)
Set protocol.
const QString & getPath() const
Get path.
bool isEmpty() const
Empty.
void setQuery(const QString &query)
Set query.
CUrl withAppendedPath(const QString &path) const
Append path.
CUrl withAppendedQuery(const QString &query) const
Append path.
bool isHavingHtmlSuffix() const
Likely a HTM file?
bool isFileWithSuffix(const QString &suffix={}) const
Stricter version of isFile().
bool hasPort() const
Port?
bool hasQuery() const
Query string?
void appendQuery(const QString &queryToAppend)
Append query.
bool isExecutableFile() const
Executable file (decided by appendix).
void setHost(const QString &address)
Set address (e.g. myserver.foo.com).
void setPort(int port)
Set port.
QNetworkRequest toNetworkRequest() const
To request.
QJsonObject toJson() const
Cast to JSON object.
void setPath(const QString &path)
Set path.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
bool pathEndsWith(const QString &ending, Qt::CaseSensitivity cs=Qt::CaseInsensitive) const
Path ending with?
bool hasDefaultPort() const
Default port.
static bool isDefaultPort(const QString &protocol, int port)
Default port for given protocol.
static CUrl fromLocalFile(const QString &localFile)
From local file path.
void setFullUrl(const QString &fullUrl)
Set full URL.
QUrl toQUrl() const
To QUrl.
void convertFromJson(const QJsonObject &json)
Assign from JSON object.
void setFragment(const QString &fragment)
Set fragment.
bool hasFragment() const
Fragment string?
QString getFullUrl(bool withQuery=true) const
Qualified name.
bool isUndefined() const const
QString toString() const const
QString & append(QChar ch)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) &&
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString simplified() const const
QString toLower() const const
QString trimmed() const const
QString fileName(QUrl::ComponentFormattingOptions options) const const
QString fragment(QUrl::ComponentFormattingOptions options) const const
QUrl fromLocalFile(const QString &localFile)
QString host(QUrl::ComponentFormattingOptions options) const const
QString path(QUrl::ComponentFormattingOptions options) const const
int port(int defaultPort) const const
QString query(QUrl::ComponentFormattingOptions options) const const
QString scheme() const const
void setScheme(const QString &scheme)
QVariant fromValue(T &&value)
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.