1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00
SqMod/source/Library/Hashing.hpp

59 lines
1.7 KiB
C++
Raw Normal View History

#ifndef _LIBRARY_HASHING_HPP_
#define _LIBRARY_HASHING_HPP_
2015-09-30 02:56:11 +02:00
// ------------------------------------------------------------------------------------------------
#include "SqBase.hpp"
2015-09-30 02:56:11 +02:00
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
2015-10-30 05:37:55 +01:00
template < class T > class HashWrapper
{
public:
// --------------------------------------------------------------------------------------------
HashWrapper()
: m_Encoder()
2015-10-30 05:37:55 +01:00
{
2015-10-30 05:37:55 +01:00
}
// --------------------------------------------------------------------------------------------
HashWrapper(const HashWrapper & o)
: m_Encoder(o.m_Encoder)
2015-10-30 05:37:55 +01:00
{
2015-10-30 05:37:55 +01:00
}
// --------------------------------------------------------------------------------------------
~HashWrapper()
2015-10-30 05:37:55 +01:00
{
2015-10-30 05:37:55 +01:00
}
// --------------------------------------------------------------------------------------------
HashWrapper & operator = (const HashWrapper & o)
2015-10-30 05:37:55 +01:00
{
m_Encoder = o.m_Encoder;
return *this;
2015-10-30 05:37:55 +01:00
}
// --------------------------------------------------------------------------------------------
String ToString() { return m_Encoder.getHash(); }
void Reset() { m_Encoder.reset(); }
String Compute(const String & str) { return m_Encoder(str); }
String GetHash() { return m_Encoder.getHash(); }
void AddStr(const String & str)
{ m_Encoder.add(str.data(), str.length() * sizeof(String::value_type)); }
2015-10-30 05:37:55 +01:00
private:
// --------------------------------------------------------------------------------------------
T m_Encoder;
};
2015-09-30 02:56:11 +02:00
} // Namespace:: SqMod
#endif // _LIBRARY_HASHING_HPP_