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 d23e244c authored by EXT Arnaud Clère's avatar EXT Arnaud Clère
Browse files

minor changes

parent 593cac6c
......@@ -133,11 +133,11 @@ private:
// TODO BindNative other QVariant-supported types?
// //////////////////////////////////////////////////////////////////////////
// QBind<_,QVariant&> example support for the fixed set of QVariantBuilder's BindNative types + other convenient types
// QBind<_,QVariant&> example support for the fixed set of IBind's BindNative types + other convenient types
template<class TResult>
struct QBind<TResult, QVariant> {
static TResult bind(Val<TResult>&& v, QVariant&& src) {
template<>
struct QBind<Cursor, 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 ?
......@@ -161,7 +161,7 @@ struct QBind<TResult, QVariant> {
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static TResult bind(Val<TResult>&& v, QVariant& dst) {
static Cursor bind(Val<Cursor>&& v, QVariant& dst) {
if (v->mode()==Write) {
return bind(std::move(v),std::move(dst));
}
......@@ -169,11 +169,11 @@ struct QBind<TResult, QVariant> {
}
};
//template<class TResult>
//struct QBind<TResult, QVariant&, IsReader<TResult>> { static TResult bind(Val<TResult>&& v, QVariant& dst) {
// TResult r;
//template<>
//struct QBind<Cursor, QVariant&, IsReader<Cursor>> { static Cursor bind(Val<Cursor>&& v, QVariant& dst) {
// Cursor r;
// {
// QScopedChoice<Val<TResult>> choice(src);
// 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; }
......
......@@ -95,6 +95,15 @@ QDataStream &operator<<(QDataStream &out, const Person &p)
<< p.phones
<< p.comments;
}
QDataStream &operator>>(QDataStream &in, Person &p)
{
return in
>> p.firstName >> p.lastName // sequence is implicit
>> p.height
>> p.age
>> p.phones
>> p.comments;
}
// //////////////////////////////////////////////////////////////////////////
// IBind basic implementation example
......@@ -128,11 +137,11 @@ private:
#include <QtCore/qbuffer.h>
class Text : public TextWriter
class Text
{
QBuffer result;
public:
template<typename T> Text(T&& t) : TextWriter(&result) { result.open(QIODevice::WriteOnly); bind(std::forward<T>(t)); }
template<typename T> Text(T&& t) { result.open(QIODevice::WriteOnly); TextWriter(&result).bind(std::forward<T>(t)); }
operator QUtf8String() const { return result.buffer(); }
};
......
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