Reviewing merge request #8: Nested-type support with Stream class
Hello,
First of all, this isn't really a merge request, cause the code is very inmature. Rather, I intend to start a discussion to get ideas to work on a good design that will allow Nested Type (De)Serialization.
The idea is to do similiar of what QDataStream does: create stream operators to serialize to a stream class (QJson::Stream at stream.h).
Like QDataStream, the user create his own class and the register it with QJson::registerType at stream.h (like qRegisterMetaTypeStreamOperators). And the user is also responsible to put his data on the stream through this operators. The class must has a QMetaType registered (using Q_DECLARE_METATYPE).
I've some tests to prove the concept: see them at teststream directory at tests.
Now comes the dirty part: we now javascript and qjon don't care about types. But C++/Qt depend on types specifically. So, I've arbitrarily chose a format to store them on the deserialization to be later parsed. It is:
"instance" :
{ "metatype" : "userclass",
"data" : { "field1" : "value1", "field2" : "value2"}
TODO:
- Fix CMakeLists.txt according to qmake .pro files modifications.
- Clean up.
That's it.
Cheers,
bráulio
Commits that would be merged:
- 47d5583
47d5583Comments
I have not found these files: stream.cpp and stream.h.
Could you put them on your repository?
Sorry, they are now included in the merge request.
Hello Flavio,
Could you use it? What did you think?
Cheers,
bráulio
I'm really sorry for the delay, but I've been really busy. Yesterday I looked at your code and I merged it into the stream branch.
I’ll write more about that in the next days.
I'm happy to see your fixes to the code at the stream branch. :)
See you,
braulio


Add a new comment:
Login or create an account to post a comment