|
BuildCache
|
A class for hashing data. More...
#include <hasher.hpp>
Classes | |
| class | hash_t |
| A helper class for storing the data hash. More... | |
Public Member Functions | |
| hasher_t (const hasher_t &other) | |
| Copy the hash state into a new hasher_t object. More... | |
| hasher_t & | operator= (const hasher_t &other) |
| Copy the hash state to an existing hasher_t object. More... | |
| void | update (const void *data, const size_t size) |
| Update the hash with more data. More... | |
| void | update (const std::string &text) |
| Update the hash with more data. More... | |
| void | update (const string_list_t &data) |
| Update the hash with more data. More... | |
| void | update (const std::map< std::string, std::string > &data) |
| Update the hash with more data. More... | |
| void | update_from_file (const std::string &path) |
| Update the hash with more data. More... | |
| void | update_from_file_deterministic (const std::string &path) |
| Update the hash with more data. More... | |
| void | inject_separator () |
| Update the hash with a separator sequence. More... | |
| hash_t | final () |
| Finalize the hash calculation. More... | |
Private Member Functions | |
| void | update_from_ar_data (const std::string &data) |
| Update the hash with data from an AR archive. More... | |
Private Attributes | |
| void * | m_state = nullptr |
A class for hashing data.
| bcache::hasher_t::hasher_t | ( | const hasher_t & | other | ) |
Copy the hash state into a new hasher_t object.
| other | The source state to be duplicated. |
| hasher_t::hash_t bcache::hasher_t::final | ( | ) |
Finalize the hash calculation.
| void bcache::hasher_t::inject_separator | ( | ) |
Update the hash with a separator sequence.
Injecting a separator sequence between other data items is useful for avoiding hash collisions due to similarities of adjacent elements (e.g. "hello","world" v.s. "hell","oworld").
Copy the hash state to an existing hasher_t object.
| other | The source state to be duplicated. |
| void bcache::hasher_t::update | ( | const std::map< std::string, std::string > & | data | ) |
Update the hash with more data.
| data | The data to hash. |
|
inline |
Update the hash with more data.
| text | The data to hash. |
| void bcache::hasher_t::update | ( | const string_list_t & | data | ) |
Update the hash with more data.
| data | The data to hash. |
| void bcache::hasher_t::update | ( | const void * | data, |
| const size_t | size | ||
| ) |
Update the hash with more data.
| data | Pointer to the data to hash. |
| size | The number of bytes to hash. |
|
private |
Update the hash with data from an AR archive.
| data | The raw AR data. |
| void bcache::hasher_t::update_from_file | ( | const std::string & | path | ) |
Update the hash with more data.
| path | Path to a file that contains the data to hash. |
| runtime_error | if the operation could not be completed. |
| void bcache::hasher_t::update_from_file_deterministic | ( | const std::string & | path | ) |
Update the hash with more data.
This method tries to produce a deterministic hash by employing file format specific heuristics to exclude things like time stamps.
| path | Path to a file that contains the data to hash. |
| runtime_error | if the operation could not be completed. |
1.8.17