/src/libtomahawk/thirdparty/quazip/quazip/quachecksum32.h

http://github.com/tomahawk-player/tomahawk · C++ Header · 54 lines · 13 code · 7 blank · 34 comment · 0 complexity · 8dc05519125e6d7b045484a364239b3c MD5 · raw file

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