foobar2000 SDK  2015-08-03
hasher_md5.h
Go to the documentation of this file.
2  char m_data[128];
3 };
4 
6  char m_data[16];
7 
8  t_uint64 xorHalve() const;
9 
10  static hasher_md5_result null() {hasher_md5_result h = {}; return h;}
11 };
12 
13 inline bool operator==(const hasher_md5_result & p_item1,const hasher_md5_result & p_item2) {return memcmp(&p_item1,&p_item2,sizeof(hasher_md5_result)) == 0;}
14 inline bool operator!=(const hasher_md5_result & p_item1,const hasher_md5_result & p_item2) {return memcmp(&p_item1,&p_item2,sizeof(hasher_md5_result)) != 0;}
15 
16 namespace pfc {
17  template<> class traits_t<hasher_md5_state> : public traits_rawobject {};
18  template<> class traits_t<hasher_md5_result> : public traits_rawobject {};
19 
20  template<> inline int compare_t(const hasher_md5_result & p_item1, const hasher_md5_result & p_item2) {
21  return memcmp(&p_item1, &p_item2, sizeof(hasher_md5_result));
22  }
23 
24 }
25 
26 class NOVTABLE hasher_md5 : public service_base
27 {
28 public:
29 
30  virtual void initialize(hasher_md5_state & p_state) = 0;
31  virtual void process(hasher_md5_state & p_state,const void * p_buffer,t_size p_bytes) = 0;
32  virtual hasher_md5_result get_result(const hasher_md5_state & p_state) = 0;
33 
34 
35  static GUID guid_from_result(const hasher_md5_result & param);
36 
37  hasher_md5_result process_single(const void * p_buffer,t_size p_bytes);
38  hasher_md5_result process_single_string(const char * str) {return process_single(str, strlen(str));}
39  GUID process_single_guid(const void * p_buffer,t_size p_bytes);
40  GUID get_result_guid(const hasher_md5_state & p_state) {return guid_from_result(get_result(p_state));}
41 
42 
44  void process_string(hasher_md5_state & p_state,const char * p_string,t_size p_length = ~0) {return process(p_state,p_string,pfc::strlen_max(p_string,p_length));}
45 
46  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(hasher_md5);
47 };
48 
49 
51 public:
53  m_hasher->initialize(m_state);
54  }
55  void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
56  p_abort.check();
57  m_hasher->process(m_state,p_buffer,p_bytes);
58  }
60  return m_hasher->get_result(m_state);
61  }
62  GUID resultGuid() const {
63  return hasher_md5::guid_from_result(result());
64  }
65 private:
68 };
69 template<bool isBigEndian = false>
71 public:
72  stream_formatter_hasher_md5() : stream_writer_formatter<isBigEndian>(_m_stream,_m_abort) {}
73 
75  return _m_stream.result();
76  }
77  GUID resultGuid() const {
78  return hasher_md5::guid_from_result(result());
79  }
80 private:
83 };
char m_data[128]
Definition: hasher_md5.h:2
GUID get_result_guid(const hasher_md5_state &p_state)
Definition: hasher_md5.h:40
Definition: pfc.h:71
hasher_md5_result result() const
Definition: hasher_md5.h:74
uint64_t t_uint64
Definition: int_types.h:3
bool operator==(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:13
abort_callback_impl abort_callback_dummy
abort_callback_dummy _m_abort
Definition: hasher_md5.h:81
void write(const void *p_buffer, t_size p_bytes, abort_callback &p_abort)
Definition: hasher_md5.h:55
void process_string(hasher_md5_state &p_state, const char *p_string, t_size p_length=~0)
Helper.
Definition: hasher_md5.h:44
hasher_md5_result process_single_string(const char *str)
Definition: hasher_md5.h:38
hasher_md5_result result() const
Definition: hasher_md5.h:59
bool operator!=(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:14
static hasher_md5_result null()
Definition: hasher_md5.h:10
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
size_t t_size
Definition: int_types.h:48
static GUID guid_from_result(const hasher_md5_result &param)
Definition: hasher_md5.cpp:3
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
int compare_t(const hasher_md5_result &p_item1, const hasher_md5_result &p_item2)
Definition: hasher_md5.h:20
hasher_md5_state m_state
Definition: hasher_md5.h:66
GUID resultGuid() const
Definition: hasher_md5.h:77
stream_writer_hasher_md5 _m_stream
Definition: hasher_md5.h:82
GUID resultGuid() const
Definition: hasher_md5.h:62
static_api_ptr_t< hasher_md5 > m_hasher
Definition: hasher_md5.h:67