I am saving the contents of several variables using QDataStream.
out << objWidth << "\n" << objHeight << "\n";
out << objWidth << "\n" << objHeight << "\n";
To copy to clipboard, switch view to plain text mode
Where objWidth and objHeight are a single byte (unsigned char, value from 0 to 255).
then it outputs another series of bytes from a vector
for(int i = 0; i < objWidth; i++)
{
for(int j = 0; j < objHeight; j++)
{
byte value = getCellValue(i, j);
out << value << ",";
}
}
for(int i = 0; i < objWidth; i++)
{
for(int j = 0; j < objHeight; j++)
{
byte value = getCellValue(i, j);
out << value << ",";
}
}
To copy to clipboard, switch view to plain text mode
Then it does it again after separating data with a new line character with another vector of data, the exact same dimensions, only different data, but same statement.
so the whole file would look like:
objWidth
\n
objHeight
\n
Vector1 data each element separated with a comma
\n
Vector2 data each element separated with a comma
objWidth
\n
objHeight
\n
Vector1 data each element separated with a comma
\n
Vector2 data each element separated with a comma
To copy to clipboard, switch view to plain text mode
Now when I read this data back from a file using QDataStream, do I want to process it directly from a file, or read it into QByteArray so I can process it there, removing new lines and commas etc?
Which is easier?
Bookmarks