VHISTlib
1.84.0.3018
|
A class for validating streams of data. More...
#include <validator.h>
Public Member Functions | |
Validator (const QString &md5="", const QString &compressedMD5="") | |
Creates a new Validator object. | |
virtual | ~Validator () |
Destroys the Validator object. | |
void | reinit (const QString &md5, const QString &compressedMD5="") |
Resets the Validator. | |
void | update (const QByteArray &data) |
Validates the next consecutive part of the datastream. | |
bool | isValid () |
Returns true if the validation of the datastream has been successful. |
A class for validating streams of data.
The Validator tests if the streams MD5 sum matches a given sum. If the datastream is compressed using flate compression, the Validator will inflate the data on the fly and match the MD5 sums of both, the compressed and uncompressed datastreams, with given MD5 sums.
Validator::Validator | ( | const QString & | md5 = "" , |
const QString & | compressedMD5 = "" |
||
) |
Creates a new Validator object.
The MD5 sums passed as arguments are the checksums you expect the stream to have.
[in] | md5 | The expected md5 sum of the uncompressed stream. |
[in] | compressedMD5 | The expected md5 sum of the compressed stream. If the stream is not compressed, pass an empty string as compressedMD5. This will deactivate the inflation. |
bool Validator::isValid | ( | ) |
Returns true
if the validation of the datastream has been successful.
The reason for a failed validation can be a corrupted compressed stream or a mismatch of MD5 sums.
void Validator::reinit | ( | const QString & | md5, |
const QString & | compressedMD5 = "" |
||
) |
Resets the Validator.
This function can be used to reuse the same Validator object for several datastreams.
[in] | md5 | The expected md5 sum of the uncompressed stream. |
[in] | compressedMD5 | The expected md5 sum of the compressed stream. If the stream is not compressed, pass an empty string as compressedMD5. This will deactivate the inflation. |
void Validator::update | ( | const QByteArray & | data | ) |
Validates the next consecutive part of the datastream.
The data will be decompressed if neccessary and the md5 sums are updated.
You can call isValid() after feeding the Validator with the complete datastream to check if the md5 sums matched and the compressed stream has been consistent.
[in] | data | The next part of the datastream. |