misc/quazip/quachecksum32.h
changeset 5752 ea95ee97c805
equal deleted inserted replaced
5750:6bbf7aee2cdf 5752:ea95ee97c805
       
     1 #ifndef QUACHECKSUM32_H
       
     2 #define QUACHECKSUM32_H
       
     3 
       
     4 #include <QByteArray>
       
     5 #include "quazip_global.h"
       
     6 
       
     7 /// Checksum interface.
       
     8 /** \class QuaChecksum32 quachecksum32.h <quazip/quachecksum32.h>
       
     9  * This is an interface for 32 bit checksums.
       
    10  * Classes implementing this interface can calcunate a certin
       
    11  * checksum in a single step:
       
    12  * \code
       
    13  * QChecksum32 *crc32 = new QuaCrc32(); 
       
    14  * rasoult = crc32->calculate(data);
       
    15  * \endcode
       
    16  * or by streaming the data:
       
    17  * \code
       
    18  * QChecksum32 *crc32 = new QuaCrc32(); 
       
    19  * while(!fileA.atEnd())
       
    20  *     crc32->update(fileA.read(bufSize));
       
    21  * resoultA = crc32->value();
       
    22  * crc32->reset();
       
    23  * while(!fileB.atEnd())
       
    24  *     crc32->update(fileB.read(bufSize));
       
    25  * resoultB = crc32->value();
       
    26  * \endcode
       
    27  */
       
    28 class QUAZIP_EXPORT QuaChecksum32
       
    29 {
       
    30 
       
    31 public:
       
    32 	///Calculates the checksum for data.
       
    33 	/** \a data source data
       
    34 	 * \return data checksum
       
    35 	 *
       
    36 	 * This function has no efect on the value returned by value().
       
    37 	 */
       
    38 	virtual quint32 calculate(const QByteArray &data) = 0;
       
    39 
       
    40 	///Resets the calculation on a checksun for a stream.
       
    41 	virtual void reset() = 0;
       
    42 
       
    43 	///Updates the calculated checksum for the stream
       
    44 	/** \a buf next portion of data from the stream
       
    45 	 */
       
    46 	virtual void update(const QByteArray &buf) = 0;
       
    47 
       
    48 	///Value of the checksum calculated for the stream passed throw update().
       
    49 	/** \return checksum
       
    50 	 */
       
    51 	virtual quint32 value() = 0;
       
    52 };
       
    53 
       
    54 #endif //QUACHECKSUM32_H