Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 0d4ad27b authored by EXT Arnaud Clère's avatar EXT Arnaud Clère
Browse files

enabled more QBind<QVariant> cases

parent 1d653f16
......@@ -174,18 +174,36 @@ template<>
struct QBind<QVariant> {
static Cursor bind(Val<Cursor>&& v, QVariant&& src) {
if (v->mode()==Write) {
if (src.type()==QVariant::List ) return v.bind(src.value<QVariantList>()); // TODO QSequentialIterable ?
if (src.type()==QVariant::Map ) return v.bind(src.value<QVariantMap >()); // TODO QAssociativeIterable ?
// TODO QVariant::Hash
if (src.canConvert<QVariantList>()) {
QSequentialIterable ts = src.value<QSequentialIterable>();
quint32 size=quint32(ts.size());
auto s(v.sequence(&size));
for (auto t : ts) {
s = s.bind(t);
}
return s;
}
if (src.canConvert<QVariantMap >() ) {
QAssociativeIterable ts = src.value<QAssociativeIterable>();
quint32 size=quint32(ts.size());
auto s(v.record(&size));
QAssociativeIterable::const_iterator i = ts.begin();
const QAssociativeIterable::const_iterator end = ts.end();
for ( ; i != end; ++i) {
QVariant t = *i;
s = s.bind(i.key().toString().toUtf8().constData(),t);
}
return s;
}
if (src.type()==QVariant::Bool ) return v.bind(src.value< bool>());
if (src.type()==QVariant::ByteArray) return v.bind(src.value< QByteArray>());
if (src.type()==QVariant::String ) return v.bind(src.value< QString>());
if (src.type()==QVariant::Char ) return v.bind(src.toString());
if (src.type()==QVariant::ULongLong) return v.bind(src.value< quint64>());
if (src.type()==QVariant::ULongLong) return v.bind(src.value< quint64>());
if (src.type()==QVariant::UInt ) return v.bind(src.value<unsigned int>());
if (src.type()==QVariant::LongLong ) return v.bind(src.value< qint64>());
if (src.type()==QVariant::LongLong ) return v.bind(src.value< qint64>());
if (src.type()==QVariant::Int ) return v.bind(src.value< int>());
if (src.type()==QVariant::Double ) return v.bind(src.value< double>());
......@@ -197,26 +215,23 @@ struct QBind<QVariant> {
if (v->mode()==Write) {
return bind(std::move(v),std::move(dst));
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
else {
Cursor r;
{
QScopedChoice<Val<Cursor>> choice(v);
QVariantList a; if ((r = v.bind(a))) { dst = a ; return r; } // NB We cannot try QStringList before QVariantList as it will always work with our logical model...
QVariantMap o; if ((r = v.bind(o))) { dst = o ; return r; }
bool b; if ((r = v.bind(b))) { dst = QVariant(b); return r; }
quint64 u; if ((r = v.bind(u))) { dst = QVariant(u); return r; }
qint64 l; if ((r = v.bind(l))) { dst = QVariant(l); return r; }
double d; if ((r = v.bind(d))) { dst = QVariant(d); return r; }
QByteArray x; if ((r = v.bind(x))) { dst = QVariant(x); return r; }
QString t; if ((r = v.bind(t))) { dst = QVariant(t); return r; }
}
if (!(r = v.null())) r.reportError("Expected boolean|decimal|bytes|text|sequence|record|null");
/**/ dst = QVariant( ); return r;
}
}
};
//template<>
//struct QBind<QVariant, Cursor, IsReader<Cursor>> { static Cursor bind(Val<Cursor>&& v, QVariant& dst) {
// Cursor r;
// {
// QScopedChoice<Val<Cursor>> choice(src);
// QVariantList a; if ((r = src.bind(a))) { dst = a ; return r; } // NB We cannot try QStringList before QVariantList as it will always work with our logical model...
// QVariantMap o; if ((r = src.bind(o))) { dst = o ; return r; }
// bool b; if ((r = src.bind(b))) { dst = QVariant(b); return r; }
// quint64 u; if ((r = src.bind(u))) { dst = QVariant(u); return r; }
// qint64 l; if ((r = src.bind(l))) { dst = QVariant(l); return r; }
// double d; if ((r = src.bind(d))) { dst = QVariant(d); return r; }
// QByteArray x; if ((r = src.bind(x))) { dst = QVariant(x); return r; }
// QString t; if ((r = src.bind(t))) { dst = QVariant(t); return r; }
// }
// if (!(r = src.null())) r.reportError("Expected boolean|decimal|text|sequence|record|null");
// /**/ dst = QVariant( ); return r;
//}};
// TODO convert builtin types which canConvert<QString>
// TODO convert builtin types which canConvert<QString> ?
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment