Core: Reworked hashes

-Removed HashDigest class (replaced by ByteArray)
-Removed Hashable/Hash classes (replaced by ComputeHash function and
Hashable template struct)
-Fixed ByteArray operator<<
-Renamed File::GetHash to File::ComputeHash


Former-commit-id: cc5eaf2d4c88a556878190b8205e66713512e2d2
This commit is contained in:
Lynix
2015-11-16 14:04:39 +01:00
parent 86da939520
commit 21f223f1c7
37 changed files with 294 additions and 621 deletions

View File

@@ -193,6 +193,17 @@ namespace Nz
m_array.swap(other.m_array);
}
inline String ByteArray::ToHex() const
{
unsigned int length = m_array.size() * 2;
String hexOutput(length, '\0');
for (unsigned int i = 0; i < m_array.size(); ++i)
std::sprintf(&hexOutput[i * 2], "%02x", m_array[i]);
return hexOutput;
}
inline String ByteArray::ToString() const
{
return String(reinterpret_cast<const char*>(GetConstBuffer()), GetSize());
@@ -321,6 +332,16 @@ namespace Nz
{
return m_array >= rhs.m_array;
}
template<>
struct Hashable<ByteArray>
{
bool operator()(const ByteArray& byteArray, AbstractHash* hash) const
{
hash->Append(byteArray.GetConstBuffer(), byteArray.GetSize());
return true;
}
};
}
namespace std