6 #ifndef BITCOIN_UINT256_H 7 #define BITCOIN_UINT256_H 16 template<
unsigned int BITS>
20 static constexpr
int WIDTH = BITS / 8;
27 constexpr
explicit base_blob(uint8_t v) : m_data{v} {}
29 explicit base_blob(
const std::vector<unsigned char>& vch);
33 for (
int i = 0; i <
WIDTH; i++)
41 memset(m_data, 0,
sizeof(m_data));
50 std::string
GetHex()
const;
51 void SetHex(
const char* psz);
52 void SetHex(
const std::string& str);
65 return &m_data[
WIDTH];
68 const unsigned char*
begin()
const 73 const unsigned char*
end()
const 75 return &m_data[
WIDTH];
85 const uint8_t* ptr = m_data + pos * 8;
86 return ((uint64_t)ptr[0]) | \
87 ((uint64_t)ptr[1]) << 8 | \
88 ((uint64_t)ptr[2]) << 16 | \
89 ((uint64_t)ptr[3]) << 24 | \
90 ((uint64_t)ptr[4]) << 32 | \
91 ((uint64_t)ptr[5]) << 40 | \
92 ((uint64_t)ptr[6]) << 48 | \
93 ((uint64_t)ptr[7]) << 56;
96 template<
typename Stream>
99 s.write((
char*)m_data,
sizeof(m_data));
102 template<
typename Stream>
105 s.read((
char*)m_data,
sizeof(m_data));
154 #endif // BITCOIN_UINT256_H
const unsigned char * begin() const
friend bool operator==(const base_blob &a, const base_blob &b)
void Serialize(Stream &s) const
constexpr uint256(uint8_t v)
const unsigned char * data() const
int Compare(const base_blob &other) const
friend bool operator!=(const base_blob &a, const base_blob &b)
const unsigned char * end() const
uint256(const std::vector< unsigned char > &vch)
void Unserialize(Stream &s)
uint256 uint256S(const char *str)
static const uint256 ZERO
friend bool operator<(const base_blob &a, const base_blob &b)
std::string ToString() const
unsigned int size() const
Template base class for fixed-sized opaque blobs.
static constexpr int WIDTH
std::string GetHex() const
uint160(const std::vector< unsigned char > &vch)
uint64_t GetUint64(int pos) const
void SetHex(const char *psz)
constexpr base_blob(uint8_t v)