Commit ad0429bf authored by EXT Arnaud Clère's avatar EXT Arnaud Clère

minor fixes and changes

parent 8e837650
......@@ -16,7 +16,6 @@ public:
Phone(Type t=Unknown, QString n=QString()) : _t(t), _n(n) {}
static bool isOffice(const Phone& phone) { return phone._t == Phone::Office; } // for custom bind example
//private:
Type _t; QString _n;
};
......
......@@ -85,17 +85,18 @@ struct Person
int id; QString firstName, lastName; double height; int age; QVector<Phone> phones; QString comments; QList<Person> children;
QValueStatus zap(QValue&& value) { // works with value->mode()==Read as well as Write
auto r = value.record("Person");
auto s = r.sequence("names");
s = s.bind(firstName);
s = s.bind( lastName);
r = s.out();
r = r.bind("height" ,height );
r = r.bind("age" ,age ,-1); // reads null() as -1
r = r.bind("phones" ,phones ); // recursive calls to QTransmogrifier will take care of that part
r = r.bind("comments",comments);
r = r.bind("children",children);
return r; // automagically closes opened record()
return value
.record("Person")
.sequence("names")
.bind(firstName)
.bind( lastName)
.out()
.bind("height" ,height )
.bind("age" ,age ,-1) // reads null() as -1
.bind("phones" ,phones ) // recursive calls to QTransmogrifier will take care of that part
.bind("comments",comments)
.bind("children",children)
; // automagically closes opened record()
}
};
......@@ -684,7 +685,7 @@ int main(int argc, char *argv[])
s.append("type" );s.append(person.phones[i]._t);
s.append("number");s.append(person.phones[i]._n);
s.endMap();
};
}
s.endArray();
s.append("comments");s.append(person.comments);
s.append("children");s.startArray(quint64(person.children.size()));
......
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