You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.0 KiB
48 lines
1.0 KiB
#include "XGlobal.h"
|
|
|
|
XGlobal XGlobal::instance;
|
|
|
|
XGlobal::XGlobal()
|
|
: callback(nullptr)
|
|
{
|
|
|
|
}
|
|
|
|
XGlobal::~XGlobal() {
|
|
|
|
}
|
|
|
|
XGlobal& XGlobal::getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
void XGlobal::onError(unsigned int errType, const QString& errTxt, int extValue /* = 0 */) {
|
|
if (nullptr != callback)
|
|
callback->onError(errType, errTxt.toStdString().c_str(), extValue);
|
|
}
|
|
|
|
void XGlobal::onHttpRequest(const char* id, const QString& method, bool isCorrect, const QString& json) {
|
|
if (nullptr == callback)
|
|
return;
|
|
|
|
callback->onHttpRequest(id, method.toStdString().c_str(), isCorrect, json.toStdString().c_str());
|
|
}
|
|
|
|
bool XGlobal::parseCustomFormat(const char* input, QMap<QString, QString>& outValue) {
|
|
if (nullptr == input)
|
|
return false;
|
|
|
|
QString str = QString::fromUtf8(input);
|
|
|
|
QStringList pairs = str.split(";", Qt::SkipEmptyParts);
|
|
for (const QString& pair : pairs) {
|
|
int idx = pair.indexOf('=');
|
|
if (idx > 0) {
|
|
QString key = pair.left(idx);
|
|
QString value = pair.mid(idx + 1);
|
|
outValue[key] = value;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
} |