All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
cpp-qt-client.helpers-header.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
#ifndef {{prefix}}_HELPERS_H
#define {{prefix}}_HELPERS_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "{{prefix}}Enum.h"
#include "{{prefix}}HttpFileElement.h"
#include "{{prefix}}Object.h"
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
template
class OptionalParam {
public:
T m_Value;
bool m_hasValue;
public:
OptionalParam(){
m_hasValue = false;
}
OptionalParam(const T &val){
m_hasValue = true;
m_Value = val;
}
bool hasValue() const {
return m_hasValue;
}
T value() const{
return m_Value;
}
};
bool setDateTimeFormat(const QString &format);
bool setDateTimeFormat(const Qt::DateFormat &format);
template
QString toStringValue(const QList &val);
template
QString toStringValue(const QSet &val);
template
bool fromStringValue(const QList &inStr, QList &val);
template
bool fromStringValue(const QSet &inStr, QList &val);
template
bool fromStringValue(const QMap &inStr, QMap &val);
template
QJsonValue toJsonValue(const QList &val);
template
QJsonValue toJsonValue(const QSet &val);
template
QJsonValue toJsonValue(const QMap &val);
template
bool fromJsonValue(QList &val, const QJsonValue &jval);
template
bool fromJsonValue(QSet &val, const QJsonValue &jval);
template
bool fromJsonValue(QMap &val, const QJsonValue &jval);
QString toStringValue(const QString &value);
QString toStringValue(const QDateTime &value);
QString toStringValue(const QByteArray &value);
QString toStringValue(const QDate &value);
QString toStringValue(const qint32 &value);
QString toStringValue(const qint64 &value);
QString toStringValue(const bool &value);
QString toStringValue(const float &value);
QString toStringValue(const double &value);
QString toStringValue(const {{prefix}}Object &value);
QString toStringValue(const {{prefix}}Enum &value);
QString toStringValue(const {{prefix}}HttpFileElement &value);
template
QString toStringValue(const QList &val) {
QString strArray;
for (const auto &item : val) {
strArray.append(toStringValue(item) + ",");
}
if (val.count() > 0) {
strArray.chop(1);
}
return strArray;
}
template
QString toStringValue(const QSet &val) {
QString strArray;
for (const auto &item : val) {
strArray.append(toStringValue(item) + ",");
}
if (val.count() > 0) {
strArray.chop(1);
}
return strArray;
}
QJsonValue toJsonValue(const QString &value);
QJsonValue toJsonValue(const QDateTime &value);
QJsonValue toJsonValue(const QByteArray &value);
QJsonValue toJsonValue(const QDate &value);
QJsonValue toJsonValue(const qint32 &value);
QJsonValue toJsonValue(const qint64 &value);
QJsonValue toJsonValue(const bool &value);
QJsonValue toJsonValue(const float &value);
QJsonValue toJsonValue(const double &value);
QJsonValue toJsonValue(const {{prefix}}Object &value);
QJsonValue toJsonValue(const {{prefix}}Enum &value);
QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value);
QJsonValue toJsonValue(const QJsonValue &value);
template
QJsonValue toJsonValue(const QList &val) {
QJsonArray jArray;
for (const auto &item : val) {
jArray.append(toJsonValue(item));
}
return jArray;
}
template
QJsonValue toJsonValue(const QSet &val) {
QJsonArray jArray;
for (const auto &item : val) {
jArray.append(toJsonValue(item));
}
return jArray;
}
template
QJsonValue toJsonValue(const QMap &val) {
QJsonObject jObject;
for (const auto &itemkey : val.keys()) {
jObject.insert(itemkey, toJsonValue(val.value(itemkey)));
}
return jObject;
}
bool fromStringValue(const QString &inStr, QString &value);
bool fromStringValue(const QString &inStr, QDateTime &value);
bool fromStringValue(const QString &inStr, QByteArray &value);
bool fromStringValue(const QString &inStr, QDate &value);
bool fromStringValue(const QString &inStr, qint32 &value);
bool fromStringValue(const QString &inStr, qint64 &value);
bool fromStringValue(const QString &inStr, bool &value);
bool fromStringValue(const QString &inStr, float &value);
bool fromStringValue(const QString &inStr, double &value);
bool fromStringValue(const QString &inStr, {{prefix}}Object &value);
bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
bool fromStringValue(const QString &inStr, {{prefix}}HttpFileElement &value);
template
bool fromStringValue(const QList &inStr, QList &val) {
bool ok = (inStr.count() > 0);
for (const auto &item : inStr) {
T itemVal;
ok &= fromStringValue(item, itemVal);
val.push_back(itemVal);
}
return ok;
}
template
bool fromStringValue(const QSet &inStr, QList &val) {
bool ok = (inStr.count() > 0);
for (const auto &item : inStr) {
T itemVal;
ok &= fromStringValue(item, itemVal);
val.push_back(itemVal);
}
return ok;
}
template
bool fromStringValue(const QMap &inStr, QMap &val) {
bool ok = (inStr.count() > 0);
for (const auto &itemkey : inStr.keys()) {
T itemVal;
ok &= fromStringValue(inStr.value(itemkey), itemVal);
val.insert(itemkey, itemVal);
}
return ok;
}
bool fromJsonValue(QString &value, const QJsonValue &jval);
bool fromJsonValue(QDateTime &value, const QJsonValue &jval);
bool fromJsonValue(QByteArray &value, const QJsonValue &jval);
bool fromJsonValue(QDate &value, const QJsonValue &jval);
bool fromJsonValue(qint32 &value, const QJsonValue &jval);
bool fromJsonValue(qint64 &value, const QJsonValue &jval);
bool fromJsonValue(bool &value, const QJsonValue &jval);
bool fromJsonValue(float &value, const QJsonValue &jval);
bool fromJsonValue(double &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval);
bool fromJsonValue(QJsonValue &value, const QJsonValue &jval);
template
bool fromJsonValue(QList &val, const QJsonValue &jval) {
bool ok = true;
if (jval.isArray()) {
for (const auto jitem : jval.toArray()) {
T item;
ok &= fromJsonValue(item, jitem);
val.push_back(item);
}
} else {
ok = false;
}
return ok;
}
template
bool fromJsonValue(QSet &val, const QJsonValue &jval) {
bool ok = true;
if (jval.isArray()) {
for (const auto jitem : jval.toArray()) {
T item;
ok &= fromJsonValue(item, jitem);
val.insert(item);
}
} else {
ok = false;
}
return ok;
}
template
bool fromJsonValue(QMap &val, const QJsonValue &jval) {
bool ok = true;
if (jval.isObject()) {
auto varmap = jval.toObject().toVariantMap();
if (varmap.count() > 0) {
for (const auto &itemkey : varmap.keys()) {
T itemVal;
ok &= fromJsonValue(itemVal, QJsonValue::fromVariant(varmap.value(itemkey)));
val.insert(itemkey, itemVal);
}
}
} else {
ok = false;
}
return ok;
}
{{#cppNamespaceDeclarations}}
} // namespace {{this}}
{{/cppNamespaceDeclarations}}
#endif // {{prefix}}_HELPERS_H