[xsd-users] serialization into QDataStream binary format

Boris Kolpackov boris at codesynthesis.com
Fri Feb 11 11:04:30 EST 2011


Hi Erik,

Erik Sjölund <erik.sjolund at gmail.com> writes:

> Please also take a look at the functions for insertion and extraction of
> const buffer<C>& x
> I saved the length into the datatype quint64. Is it the right choice?

Yes, either 32 or 64 bit unsigned integer should work fine.


> In the file qdatastream-stream-extraction.hxx :
> -------
> int bytes_read = s.impl ().readRawData (x.data (), len_as_int);
> if (bytes_read != len_as_int) {
>     std::cerr << "readRawBytes did not read all bytes" << std::endl;
>     exit (EXIT_FAILURE);
> }
> --------
> If readRawData() reads less than requested we probably should not exit().

Yes, definitely. Throwing an exception is probably a good idea.


> Maybe a while loop is better?

This really depends on the semantics of readRawBytes(). Does the Qt
documentation say that you have to keep calling it until you get all
the data?


> Feel free to modify the code and incorporate it into XSD. See my
> modifications to these files as public domain.

This looks very cool but I think a better approach would be to upload
your implementation (perhaps with an example and a README file) to the
wiki:

http://wiki.codesynthesis.com/XSD

Boris



More information about the xsd-users mailing list