karazeh
A cross-platform software updating library.
hasher.hpp
Go to the documentation of this file.
1 
21 #ifndef H_KARAZEH_HASHER_H
22 #define H_KARAZEH_HASHER_H
23 
24 #include "karazeh_export.h"
25 #include "karazeh/karazeh.hpp"
26 
27 namespace kzh {
29  {
30  public:
31 
32  inline hasher(string_t const& name) : name_(name) { };
33  inline virtual ~hasher() {};
34 
39  struct digest_rc {
41  bool valid;
42 
45 
46  digest_rc() : valid(false) {}
47  ~digest_rc() { }
48 
49  bool operator==(string_t const& checksum) {
50  return valid && checksum == digest;
51  }
52 
53  bool operator!=(string_t const& checksum) {
54  return !valid || checksum != digest;
55  }
56  };
57 
59  virtual digest_rc hex_digest(string_t const& data) const = 0;
60 
62  virtual digest_rc hex_digest(std::ifstream& src) const = 0;
63  virtual digest_rc hex_digest(path_t const& path) const = 0;
64 
65  inline string_t const& name() const {
66  return name_;
67  };
68 
69  protected:
71  };
72 
73 } // end of namespace kzh
74 
75 #endif
Definition: hasher.hpp:28
boost::filesystem::path path_t
Definition: karazeh.hpp:57
string_t name_
Definition: hasher.hpp:67
~digest_rc()
Definition: hasher.hpp:47
bool operator==(string_t const &checksum)
Definition: hasher.hpp:49
std::string string_t
Definition: karazeh.hpp:55
Definition: config.hpp:32
string_t const & name() const
Definition: hasher.hpp:65
virtual ~hasher()
Definition: hasher.hpp:33
hasher(string_t const &name)
Definition: hasher.hpp:32
bool valid
Definition: hasher.hpp:41
Definition: config.hpp:27
Definition: hasher.hpp:39
bool operator!=(string_t const &checksum)
Definition: hasher.hpp:53
string_t digest
Definition: hasher.hpp:44
digest_rc()
Definition: hasher.hpp:46