File indexing completed on 2025-01-26 04:24:53
0001 #ifndef QUACHECKSUM32_H 0002 #define QUACHECKSUM32_H 0003 0004 /* 0005 Copyright (C) 2005-2014 Sergey A. Tachenov 0006 0007 This file is part of QuaZIP. 0008 0009 QuaZIP is free software: you can redistribute it and/or modify 0010 it under the terms of the GNU Lesser General Public License as published by 0011 the Free Software Foundation, either version 2.1 of the License, or 0012 (at your option) any later version. 0013 0014 QuaZIP is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU Lesser General Public License for more details. 0018 0019 You should have received a copy of the GNU Lesser General Public License 0020 along with QuaZIP. If not, see <http://www.gnu.org/licenses/>. 0021 0022 See COPYING file for the full LGPL text. 0023 0024 Original ZIP package is copyrighted by Gilles Vollant and contributors, 0025 see quazip/(un)zip.h files for details. Basically it's the zlib license. 0026 */ 0027 0028 #include <QByteArray> 0029 #include "quazip_global.h" 0030 0031 /// Checksum interface. 0032 /** \class QuaChecksum32 quachecksum32.h <quazip/quachecksum32.h> 0033 * This is an interface for 32 bit checksums. 0034 * Classes implementing this interface can calcunate a certin 0035 * checksum in a single step: 0036 * \code 0037 * QChecksum32 *crc32 = new QuaCrc32(); 0038 * rasoult = crc32->calculate(data); 0039 * \endcode 0040 * or by streaming the data: 0041 * \code 0042 * QChecksum32 *crc32 = new QuaCrc32(); 0043 * while(!fileA.atEnd()) 0044 * crc32->update(fileA.read(bufSize)); 0045 * resoultA = crc32->value(); 0046 * crc32->reset(); 0047 * while(!fileB.atEnd()) 0048 * crc32->update(fileB.read(bufSize)); 0049 * resoultB = crc32->value(); 0050 * \endcode 0051 */ 0052 class QUAZIP_EXPORT QuaChecksum32 0053 { 0054 0055 public: 0056 ///Calculates the checksum for data. 0057 /** \a data source data 0058 * \return data checksum 0059 * 0060 * This function has no efect on the value returned by value(). 0061 */ 0062 virtual quint32 calculate(const QByteArray &data) = 0; 0063 0064 ///Resets the calculation on a checksun for a stream. 0065 virtual void reset() = 0; 0066 0067 ///Updates the calculated checksum for the stream 0068 /** \a buf next portion of data from the stream 0069 */ 0070 virtual void update(const QByteArray &buf) = 0; 0071 0072 ///Value of the checksum calculated for the stream passed throw update(). 0073 /** \return checksum 0074 */ 0075 virtual quint32 value() = 0; 0076 }; 0077 0078 #endif //QUACHECKSUM32_H