Cupt
hashsums.hpp
Go to the documentation of this file.
1/**************************************************************************
2* Copyright (C) 2010 by Eugene V. Lyubimkin *
3* *
4* This program is free software; you can redistribute it and/or modify *
5* it under the terms of the GNU General Public License *
6* (version 3 or above) as published by the Free Software Foundation. *
7* *
8* This program is distributed in the hope that it will be useful, *
9* but WITHOUT ANY WARRANTY; without even the implied warranty of *
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11* GNU General Public License for more details. *
12* *
13* You should have received a copy of the GNU GPL *
14* along with this program; if not, write to the *
15* Free Software Foundation, Inc., *
16* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
17**************************************************************************/
18#ifndef CUPT_HASHSUMS_SEEN
19#define CUPT_HASHSUMS_SEEN
20
22
23#include <cupt/common.hpp>
24
25namespace cupt {
26
28class CUPT_API HashSums
29{
30 public:
32 enum Type { MD5, SHA1, SHA256, Count };
33
35 string values[Count];
36
38 string& operator[](const Type& type);
40 const string& operator[](const Type& type) const;
42
47 bool verify(const string& path) const;
49
55 bool match(const HashSums& other) const;
57
60 bool empty() const;
61
63
66 void fill(const string& path);
67
69
74 static string getHashOfString(const Type& type, const string& pattern);
75};
76
77}
78
79#endif
80
hash sums
Definition hashsums.hpp:29
Type
hash sum type
Definition hashsums.hpp:32
const string & operator[](const Type &type) const
shortcut to values[type]
void fill(const string &path)
fills the object with the hash sums of the file content
static string getHashOfString(const Type &type, const string &pattern)
gets hash of the string
string & operator[](const Type &type)
shortcut to values[type]
bool verify(const string &path) const
does file content match hash sums?
bool empty() const
does object contain no hash sums?
bool match(const HashSums &other) const
compares with other HashSums object