File indexing completed on 2024-04-28 15:39:58

0001 /*
0002   SPDX-FileCopyrightText: 2018 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
0003   SPDX-FileCopyrightText: 2007-2010 Tuomas Suutari <thsuut@utu.fi>
0004 
0005   SPDX-License-Identifier: GPL-2.0-or-later
0006 
0007   This program is distributed in the hope that it will be useful, but
0008   WITHOUT ANY WARRANTY; without even the implied warranty of
0009   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0010   General Public License for more details.
0011 
0012   You should have received a copy of the GNU General Public License
0013   along with this program (see the file COPYING); if not, write to the
0014   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
0015   MA 02110-1301 USA.
0016 */
0017 
0018 #ifndef DB_MD5_H
0019 #define DB_MD5_H
0020 
0021 #include <QString>
0022 #include <qglobal.h>
0023 
0024 namespace DB
0025 {
0026 class FileName;
0027 
0028 class MD5
0029 {
0030 public:
0031     MD5();
0032 
0033     explicit MD5(const QString &md5str);
0034 
0035     bool isNull() const;
0036 
0037     MD5 &operator=(const QString &md5str);
0038 
0039     /** Get hex string representation of this.
0040      * If this->isNull(), returns null string.
0041      */
0042     QString toHexString() const;
0043 
0044     bool operator==(const MD5 &other) const;
0045 
0046     bool operator!=(const MD5 &other) const;
0047 
0048     bool operator<(const MD5 &other) const;
0049 
0050     inline uint hash() const { return (uint)m_v0 ^ m_v1; }
0051 
0052     static void resetMD5Cache();
0053 
0054 private:
0055     bool m_isNull;
0056     qulonglong m_v0;
0057     qulonglong m_v1;
0058 };
0059 
0060 inline uint qHash(const MD5 &key)
0061 {
0062     return key.hash();
0063 }
0064 
0065 DB::MD5 MD5Sum(const DB::FileName &fileName);
0066 void PreloadMD5Sum(const DB::FileName &fileName);
0067 }
0068 
0069 #endif /* DB_MD5_H */
0070 // vi:expandtab:tabstop=4 shiftwidth=4: