ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
quacrc32.cpp
Go to the documentation of this file.
1 /*
2 Copyright (C) 2005-2014 Sergey A. Tachenov
3 
4 This file is part of QuaZIP.
5 
6 QuaZIP is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 2.1 of the License, or
9 (at your option) any later version.
10 
11 QuaZIP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15 
16 You should have received a copy of the GNU Lesser General Public License
17 along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
18 
19 See COPYING file for the full LGPL text.
20 
21 Original ZIP package is copyrighted by Gilles Vollant and contributors,
22 see quazip/(un)zip.h files for details. Basically it's the zlib license.
23 */
24 
25 #include "quacrc32.h"
26 
27 #include "zlib.h"
28 
30 
31 quint32 QuaCrc32::calculate(const QByteArray &data) {
32  return crc32(crc32(0L, Z_NULL, 0), (const Bytef *)data.data(), data.size());
33 }
34 
35 void QuaCrc32::reset() { checksum = crc32(0L, Z_NULL, 0); }
36 
37 void QuaCrc32::update(const QByteArray &buf) {
38  checksum = crc32(checksum, (const Bytef *)buf.data(), buf.size());
39 }
40 
41 quint32 QuaCrc32::value() { return checksum; }
QuaCrc32()
Definition: quacrc32.cpp:29
void reset()
Resets the calculation on a checksun for a stream.
Definition: quacrc32.cpp:35
void update(const QByteArray &buf)
Updates the calculated checksum for the stream.
Definition: quacrc32.cpp:37
quint32 value()
Value of the checksum calculated for the stream passed throw update().
Definition: quacrc32.cpp:41
quint32 calculate(const QByteArray &data)
Calculates the checksum for data.
Definition: quacrc32.cpp:31