Changeset View
Changeset View
Standalone View
Standalone View
src/hash.h
| Show First 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | template <typename T> CHashVerifier<Source> &operator>>(T &&obj) { | ||||
| ::Unserialize(*this, obj); | ::Unserialize(*this, obj); | ||||
| return (*this); | return (*this); | ||||
| } | } | ||||
| }; | }; | ||||
| /** | /** | ||||
| * Writes data to an underlying source stream, while hashing the written data. | * Writes data to an underlying source stream, while hashing the written data. | ||||
| */ | */ | ||||
| template <typename Source> class HashedSourceWriter : public CHashWriter { | template <typename Source> class HashedSourceWriter : public HashWriter { | ||||
| private: | private: | ||||
| Source &m_source; | Source &m_source; | ||||
| public: | public: | ||||
| explicit HashedSourceWriter(Source &source LIFETIMEBOUND) | explicit HashedSourceWriter(Source &source LIFETIMEBOUND) | ||||
| : CHashWriter{source.GetType(), source.GetVersion()}, m_source{source} { | : HashWriter{}, m_source{source} {} | ||||
| } | |||||
| void write(Span<const std::byte> src) { | void write(Span<const std::byte> src) { | ||||
| m_source.write(src); | m_source.write(src); | ||||
| CHashWriter::write(src); | HashWriter::write(src); | ||||
| } | } | ||||
| template <typename T> HashedSourceWriter &operator<<(const T &obj) { | template <typename T> HashedSourceWriter &operator<<(const T &obj) { | ||||
| ::Serialize(*this, obj); | ::Serialize(*this, obj); | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| }; | }; | ||||
| Show All 15 Lines | |||||