6 #ifndef BITCOIN_UINT256_H 7 #define BITCOIN_UINT256_H 18 static constexpr
int WIDTH = BITS / 8;
24 explicit base_blob(
const std::vector<uint8_t> &vch);
27 for (
int i = 0; i <
WIDTH; i++) {
35 void SetNull() { memset(data, 0,
sizeof(data)); }
38 for (
size_t i = 0; i <
sizeof(
data); i++) {
39 uint8_t a = data[
sizeof(
data) - 1 - i];
40 uint8_t b = other.
data[
sizeof(
data) - 1 - i];
71 std::string
GetHex()
const;
72 void SetHex(
const char *psz);
73 void SetHex(
const std::string &str);
76 uint8_t *
begin() {
return &data[0]; }
80 const uint8_t *
begin()
const {
return &data[0]; }
82 const uint8_t *
end()
const {
return &data[
WIDTH]; }
84 unsigned int size()
const {
return sizeof(
data); }
87 const uint8_t *ptr = data + pos * 8;
88 return uint64_t(ptr[0]) | (uint64_t(ptr[1]) << 8) |
89 (uint64_t(ptr[2]) << 16) | (uint64_t(ptr[3]) << 24) |
90 (uint64_t(ptr[4]) << 32) | (uint64_t(ptr[5]) << 40) |
91 (uint64_t(ptr[6]) << 48) | (uint64_t(ptr[7]) << 56);
94 template <
typename Stream>
void Serialize(Stream &s)
const {
95 s.write((
char *)data,
sizeof(data));
99 s.read((
char *)data,
sizeof(data));
162 #endif // BITCOIN_UINT256_H
uint160(const std::vector< uint8_t > &vch)
friend bool operator==(const base_blob &a, const base_blob &b)
void Serialize(Stream &s) const
int Compare(const base_blob &other) const
friend bool operator!=(const base_blob &a, const base_blob &b)
friend bool operator>=(const base_blob &a, const base_blob &b)
void Unserialize(Stream &s)
uint256 uint256S(const char *str)
uint256 from const char *.
friend bool operator<(const base_blob &a, const base_blob &b)
std::string ToString() const
unsigned int size() const
uint160 uint160S(const char *str)
Template base class for fixed-sized opaque blobs.
uint256(const std::vector< uint8_t > &vch)
static constexpr int WIDTH
std::string GetHex() const
friend bool operator<=(const base_blob &a, const base_blob &b)
const uint8_t * end() const
const uint8_t * begin() const
uint64_t GetUint64(int pos) const
void SetHex(const char *psz)
friend bool operator>(const base_blob &a, const base_blob &b)