1 /*
2   SPDX-FileCopyrightText: 2018 Johannes Zarl-Zierl <johannes@zarl-zierl.at>
3   SPDX-FileCopyrightText: 2007-2010 Tuomas Suutari <thsuut@utu.fi>
4 
5   SPDX-License-Identifier: GPL-2.0-or-later
6 
7   This program is distributed in the hope that it will be useful, but
8   WITHOUT ANY WARRANTY; without even the implied warranty of
9   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10   General Public License for more details.
11 
12   You should have received a copy of the GNU General Public License
13   along with this program (see the file COPYING); if not, write to the
14   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
15   MA 02110-1301 USA.
16 */
17 
18 #ifndef DB_MD5_H
19 #define DB_MD5_H
20 
21 #include <QString>
22 #include <qglobal.h>
23 
24 namespace DB
25 {
26 class FileName;
27 
28 class MD5
29 {
30 public:
31     MD5();
32 
33     explicit MD5(const QString &md5str);
34 
35     bool isNull() const;
36 
37     MD5 &operator=(const QString &md5str);
38 
39     /** Get hex string representation of this.
40      * If this->isNull(), returns null string.
41      */
42     QString toHexString() const;
43 
44     bool operator==(const MD5 &other) const;
45 
46     bool operator!=(const MD5 &other) const;
47 
48     bool operator<(const MD5 &other) const;
49 
hash()50     inline uint hash() const { return (uint)m_v0 ^ m_v1; }
51 
52     static void resetMD5Cache();
53 
54 private:
55     bool m_isNull;
56     qulonglong m_v0;
57     qulonglong m_v1;
58 };
59 
qHash(const MD5 & key)60 inline uint qHash(const MD5 &key)
61 {
62     return key.hash();
63 }
64 
65 DB::MD5 MD5Sum(const DB::FileName &fileName);
66 void PreloadMD5Sum(const DB::FileName &fileName);
67 }
68 
69 #endif /* DB_MD5_H */
70 // vi:expandtab:tabstop=4 shiftwidth=4:
71