Files
hpcore/src/util/h32.hpp
Ravin Perera 5b56d9c1b3 Updated hpfs hash verification with file mode checks. (#257)
* Added file mode to hpfs responses.

* Parse file mode on hpfs response read.

* Apply file/dir mode.

* Fixed mode apply logic.

* Fixed code review comments.

* Additional fix.
2021-02-24 11:13:28 +05:30

42 lines
1.0 KiB
C++

#ifndef _HP_UTIL_H32_
#define _HP_UTIL_H32_
#include "../pchheader.hpp"
namespace util
{
// blake3b hash is 32 bytes which we store as 4 quad words
// Originally from https://github.com/codetsunami/file-ptracer/blob/master/merkle.cpp
struct h32
{
uint64_t data[4];
bool operator==(const h32 rhs) const;
bool operator!=(const h32 rhs) const;
void operator^=(const h32 rhs);
std::string_view to_string_view() const;
h32 &operator=(std::string_view sv);
void operator^=(std::string_view sv);
bool operator<(const h32 rhs) const;
h32()
{
memset(data, 0, sizeof(data));
}
};
extern h32 h32_empty;
std::ostream &operator<<(std::ostream &output, const h32 &h);
// Helper class to support std::map/std::unordered_map custom hashing function.
// This is needed to use h32 as the std map container key.
class h32_std_key_hasher
{
public:
size_t operator()(const h32 h) const;
};
} // namespace util
#endif