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