[kde-edu]: KTouch Statistics - compressed XML

Albert Astals Cid tsdgeos at yahoo.es
Sun May 1 12:48:08 CEST 2005


There are several ways, one of them is using 

QByteArray qCompress ( const QByteArray & data ) 
QByteArray qUncompress ( const QByteArray & data ) 

that uses the zlib compression method.

Snipplets of code

// save function
QFile file(name);
file.open(IO_WriteOnly)
QByteArray array;
QTextStream ts(array, IO_WriteOnly);
// use ts to save the data
array = qCompress(array);
file.writeBlock(array);
file.close();

// load function
QFile file(name);
file.open(IO_ReadOnly);
QByteArray array;
array = file.readAll();
array = qUncompress(array);
QTextStream ts(array, IO_ReadOnly);
//use ts to read the data
file.close();

Albert

A Diumenge 01 Maig 2005 01:36, Andreas Nicolai va escriure:
> Hi there,
>
> I'm currently working on the KTouch statistics which will be stored in an
> XML file as well. Now if KTouch is used a lot (like it is in schools for
> teaching), those statistic files may become a bit bigger (well, probably
> not more then a couple of hundred kB, but still...)
>
> Now, what would be the easiest way to read/write compressed XML using the
> KDE-FrameWork?
>
> Bye,
> Andreas
>
> _______________________________________________
> kde-edu mailing list
> kde-edu at mail.kde.org
> https://mail.kde.org/mailman/listinfo/kde-edu



More information about the kde-edu mailing list