tdesktop/Telegram/SourceFiles/base/qthelp_url.h

28 lines
770 B
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace qthelp {
inline QString url_encode(const QString &part) {
return QString::fromLatin1(QUrl::toPercentEncoding(part));
}
inline QString url_decode(const QString &encoded) {
return QUrl::fromPercentEncoding(encoded.toUtf8());
}
enum class UrlParamNameTransform {
NoTransform,
ToLower,
};
// Parses a string like "p1=v1&p2=v2&..&pn=vn" to a map.
QMap<QString, QString> url_parse_params(const QString &params, UrlParamNameTransform transform = UrlParamNameTransform::NoTransform);
} // namespace qthelp