Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QDataStream for general purposes or standard c++ stream ?
I'm developing a system to manage information (data of any kind, but not objects).
QDataStream offers platform independent, endianness , network.
Is it worth to use Qdatastream only to manage data at memory level ? Maybe faster c++ stream ?
I'd want to use Qdatastream, thinking at future uses of my data.
What is your opinion.?
dangelog last edited by
Can you rephrase that? What are you trying to do?
(By the way, QDataStream does NOT offer network. It cannot handle short reads nor short writes.)
Using QIODevice I could do anything with the data
What I want to do is a general data system, ready to be used at memory level, file, etc. and the platform independent, endianness 'free'. This is thi first reason to try to use Qdatastream.
By now, I'm using it to read-write floats, doubles, structures,etc.
In adittion I'm using then qbytearray associated to retrieve data doing casting.
Using a c++ stream for only this, are going to be faster ?
veeeee_d last edited by
Any form of "pure" C++ is faster than using Qt. Qt is a framework, and frameworks are rarely ever faster than writing an specific implementation for what you need.
Thanks veeee_d. How many faster ? I know that it can be difficult to evaluate, imagine I want to use this schema to write 100 000 points (float, float, double). A similar system in pure c++ (with code to let platform independent and endianness free ) how many (in percent time) faster are going to be ? Thanks
goetz last edited by
That depends on your implementation.
The question you asked is far too vague to give a proper answer.
Of course you can do almost everything with QDataStream - the question is, whether this is reasonable in your actual context.
If you use QDataStream to write your data, you will also need Qt for the application that reads the data.
A last question, using qdatastream, writing a float with 4, 8 for double, using litteendian, are going to means a file with 12 bytes. Knowing this information, the data coulde be recovered using another languaje ins't ?. Or could not ?
andre last edited by
Yes, you can read the data again using another toolkit or language. The format of the data is documented. Reading in the data may not be as easy as it would be using Qt again, though.