|
My Project 3.7.1
C++ Distributed Hash Table
|
#include <infohash.h>
Public Types | |
| using | T = std::array<uint8_t, N> |
| typedef T::iterator | iterator |
| typedef T::const_iterator | const_iterator |
Public Member Functions | |
| Hash (const uint8_t *h, size_t data_len) | |
| Hash (std::string_view hex) | |
| Hash (const msgpack::object &o) | |
| const uint8_t * | data () const |
| uint8_t * | data () |
| iterator | begin () |
| const_iterator | cbegin () const |
| iterator | end () |
| const_iterator | cend () const |
| bool | operator== (const Hash &h) const |
| bool | operator!= (const Hash &h) const |
| bool | operator< (const Hash &o) const |
| Hash | operator^ (const Hash &o) const |
| operator bool () const | |
| uint8_t & | operator[] (size_t index) |
| const uint8_t & | operator[] (size_t index) const |
| int | lowbit () const |
| int | xorCmp (const Hash &id1, const Hash &id2) const |
| bool | getBit (unsigned nbit) const |
| void | setBit (unsigned nbit, bool b) |
| double | toFloat () const |
| std::string_view | to_view () const |
| const char * | to_c_str () const |
| std::string | toString () const |
| template<typename Packer> | |
| void | msgpack_pack (Packer &pk) const |
| void | msgpack_unpack (msgpack::object o) |
| template<typename Rd> | |
| Hash< N > | getRandom (Rd &rdev) |
Static Public Member Functions | |
| static constexpr size_t | size () noexcept |
| static constexpr Hash | zero () noexcept |
| static int | cmp (const Hash &id1, const Hash &id2) |
| static unsigned | commonBits (const Hash &id1, const Hash &id2) |
| static Hash | get (std::string_view data) |
| static Hash | get (const std::vector< uint8_t > &data) |
| template<size_t H> | |
| static Hash | get (const Hash< H > &o) |
| static Hash | get (const uint8_t *data, size_t data_len) |
| static Hash | getRandom () |
| template<typename Rd> | |
| static Hash | getRandom (Rd &) |
Friends | |
| template<size_t M> | |
| std::ostream & | operator<< (std::ostream &s, const Hash< M > &h) |
| template<size_t M> | |
| std::istream & | operator>> (std::istream &s, Hash< M > &h) |
Represents an Hash, a byte array of N bytes. Hashes identify nodes and values in the Dht.
Definition at line 50 of file infohash.h.
| typedef T::const_iterator dht::Hash< N >::const_iterator |
Definition at line 55 of file infohash.h.
| typedef T::iterator dht::Hash< N >::iterator |
Definition at line 54 of file infohash.h.
| using dht::Hash< N >::T = std::array<uint8_t, N> |
Definition at line 53 of file infohash.h.
|
inlinenoexcept |
Definition at line 57 of file infohash.h.
|
inline |
Definition at line 58 of file infohash.h.
|
inlineexplicit |
Constructor from an hexadecimal string (without "0x"). hex must be at least 2.HASH_LEN characters long. If too long, only the first 2.HASH_LEN characters are read.
Definition at line 70 of file infohash.h.
|
inline |
Definition at line 78 of file infohash.h.
|
inline |
Definition at line 83 of file infohash.h.
|
inline |
Definition at line 84 of file infohash.h.
|
inline |
Definition at line 86 of file infohash.h.
|
inlinestatic |
Definition at line 143 of file infohash.h.
|
inlinestatic |
Find how many bits two ids have in common.
Definition at line 149 of file infohash.h.
|
inline |
Definition at line 82 of file infohash.h.
|
inline |
Definition at line 81 of file infohash.h.
|
inline |
Definition at line 85 of file infohash.h.
Definition at line 213 of file infohash.h.
|
inlinestatic |
Definition at line 210 of file infohash.h.
|
inlinestatic |
Computes the hash from a given data buffer of size data_len.
Definition at line 221 of file infohash.h.
|
inlinestatic |
Definition at line 208 of file infohash.h.
|
inline |
Definition at line 185 of file infohash.h.
|
static |
Definition at line 312 of file infohash.h.
Definition at line 326 of file infohash.h.
|
inline |
Find the lowest 1 bit in an id. Result will allways be lower than 8*N
Definition at line 129 of file infohash.h.
|
inline |
Definition at line 246 of file infohash.h.
|
inline |
Definition at line 252 of file infohash.h.
|
inlineexplicit |
Definition at line 111 of file infohash.h.
|
inline |
Definition at line 91 of file infohash.h.
|
inline |
Definition at line 93 of file infohash.h.
|
inline |
Definition at line 90 of file infohash.h.
|
inline |
Definition at line 122 of file infohash.h.
|
inline |
Definition at line 123 of file infohash.h.
|
inline |
Definition at line 102 of file infohash.h.
|
inline |
Definition at line 192 of file infohash.h.
|
inlinestaticconstexprnoexcept |
Definition at line 80 of file infohash.h.
| const char * dht::Hash< N >::to_c_str | ( | ) | const |
Definition at line 374 of file infohash.h.
|
inline |
Returns view to thread-allocated memory, only valid until the next call to this function.
Definition at line 240 of file infohash.h.
|
inline |
Definition at line 199 of file infohash.h.
| std::string dht::Hash< N >::toString | ( | ) | const |
Definition at line 388 of file infohash.h.
|
inline |
Determine whether id1 or id2 is closer to this
Definition at line 173 of file infohash.h.
|
inlinestaticconstexprnoexcept |
Definition at line 88 of file infohash.h.