VHISTlib  1.84.0.3018
Public Member Functions
vhist::Validator Class Reference

A class for validating streams of data. More...

#include <validator.h>

List of all members.

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.

Detailed Description

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.

Examples:

validator_example.cpp.


Constructor & Destructor Documentation

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.

Parameters:
[in]md5The expected md5 sum of the uncompressed stream.
[in]compressedMD5The expected md5 sum of the compressed stream. If the stream is not compressed, pass an empty string as compressedMD5. This will deactivate the inflation.

Member Function Documentation

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.

Returns:
Whether the validation has been successful.
Examples:
validator_example.cpp.
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.

Parameters:
[in]md5The expected md5 sum of the uncompressed stream.
[in]compressedMD5The expected md5 sum of the compressed stream. If the stream is not compressed, pass an empty string as compressedMD5. This will deactivate the inflation.
Examples:
validator_example.cpp.
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.

Parameters:
[in]dataThe next part of the datastream.
Examples:
validator_example.cpp.

The documentation for this class was generated from the following files:

VHISTlib 1.84.0.3018 of Jun 28 2013, generated by doxygen.