33#ifndef _QX_SERIALIZE_QJSON_STD_UNORDERED_SET_H_
34#define _QX_SERIALIZE_QJSON_STD_UNORDERED_SET_H_
47#include <QtCore/qjsonvalue.h>
48#include <QtCore/qjsonobject.h>
49#include <QtCore/qjsonarray.h>
51#include <unordered_set>
63 static inline QJsonValue
toJson(
const std::unordered_set<T> & t,
const QString & format)
66 typedef typename std::unordered_set<T>::const_iterator type_itr;
67 for (type_itr itr = t.begin(); itr != t.end(); ++itr)
69 return QJsonValue(arr);
76 static inline qx_bool fromJson(
const QJsonValue & j, std::unordered_set<T> & t,
const QString & format)
79 if (! j.isArray()) {
return qx_bool(
true); } QJsonArray arr = j.toArray();
80 t.reserve(
static_cast<typename std::unordered_set<T>::size_type
>(arr.count()));
81 for (
int i = 0; i < arr.count(); i++)
90 static inline QJsonValue
toJson(
const std::unordered_multiset<T> & t,
const QString & format)
93 typedef typename std::unordered_multiset<T>::const_iterator type_itr;
94 for (type_itr itr = t.begin(); itr != t.end(); ++itr)
96 return QJsonValue(arr);
103 static inline qx_bool fromJson(
const QJsonValue & j, std::unordered_multiset<T> & t,
const QString & format)
106 if (! j.isArray()) {
return qx_bool(
true); } QJsonArray arr = j.toArray();
107 t.reserve(
static_cast<typename std::unordered_multiset<T>::size_type
>(arr.count()));
108 for (
int i = 0; i < arr.count(); i++)
qx::cvt : namespace to provide global functions to convert any kind of objects to/from QString and QV...
qx_bool : boolean type with code and description message when an error occured
qx_bool from_json(const QJsonValue &j, T &t, const QString &format=QString())
QJsonValue to_json(const T &t, const QString &format=QString())
Root namespace for all QxOrm library features.
static qx_bool fromJson(const QJsonValue &j, std::unordered_multiset< T > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, std::unordered_set< T > &t, const QString &format)
static QJsonValue toJson(const std::unordered_multiset< T > &t, const QString &format)
static QJsonValue toJson(const std::unordered_set< T > &t, const QString &format)