Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
util
hash_type.h
Go to the documentation of this file.
1
// Copyright (c) 2020-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_UTIL_HASH_TYPE_H
6
#define BITCOIN_UTIL_HASH_TYPE_H
7
8
template
<
typename
HashType>
9
class
BaseHash
10
{
11
protected
:
12
HashType
m_hash
;
13
14
public
:
15
BaseHash
() :
m_hash
() {}
16
explicit
BaseHash
(
const
HashType& in) :
m_hash
(in) {}
17
18
unsigned
char
*
begin
()
19
{
20
return
m_hash
.begin();
21
}
22
23
const
unsigned
char
*
begin
()
const
24
{
25
return
m_hash
.begin();
26
}
27
28
unsigned
char
*
end
()
29
{
30
return
m_hash
.end();
31
}
32
33
const
unsigned
char
*
end
()
const
34
{
35
return
m_hash
.end();
36
}
37
38
operator
std::vector<unsigned char>()
const
39
{
40
return
std::vector<unsigned char>{
m_hash
.begin(),
m_hash
.end()};
41
}
42
43
std::string
ToString
()
const
44
{
45
return
m_hash
.ToString();
46
}
47
48
bool
operator==
(
const
BaseHash<HashType>
& other)
const
noexcept
49
{
50
return
m_hash
== other.m_hash;
51
}
52
53
bool
operator<
(
const
BaseHash<HashType>
& other)
const
noexcept
54
{
55
return
m_hash
< other.m_hash;
56
}
57
58
size_t
size
()
const
59
{
60
return
m_hash
.size();
61
}
62
63
unsigned
char
*
data
() {
return
m_hash
.data(); }
64
const
unsigned
char
*
data
()
const
{
return
m_hash
.data(); }
65
};
66
67
#endif
// BITCOIN_UTIL_HASH_TYPE_H
BaseHash::data
unsigned char * data()
Definition
hash_type.h:63
BaseHash::end
const unsigned char * end() const
Definition
hash_type.h:33
BaseHash::ToString
std::string ToString() const
Definition
hash_type.h:43
BaseHash::size
size_t size() const
Definition
hash_type.h:58
BaseHash::m_hash
HashType m_hash
Definition
hash_type.h:12
BaseHash::begin
unsigned char * begin()
Definition
hash_type.h:18
BaseHash::end
unsigned char * end()
Definition
hash_type.h:28
BaseHash::operator==
bool operator==(const BaseHash< HashType > &other) const noexcept
Definition
hash_type.h:48
BaseHash::begin
const unsigned char * begin() const
Definition
hash_type.h:23
BaseHash::BaseHash
BaseHash(const HashType &in)
Definition
hash_type.h:16
BaseHash::operator<
bool operator<(const BaseHash< HashType > &other) const noexcept
Definition
hash_type.h:53
BaseHash::data
const unsigned char * data() const
Definition
hash_type.h:64
BaseHash::BaseHash
BaseHash()
Definition
hash_type.h:15
Generated on
for Bitcoin Core by
1.17.0