6 #ifndef FABCOIN_UINT256_H 7 #define FABCOIN_UINT256_H 24 template<
unsigned int BITS>
33 memset(data, 0,
sizeof(data));
36 explicit base_blob(
const std::vector<unsigned char>& vch);
40 for (
int i = 0; i <
WIDTH; i++)
48 memset(data, 0,
sizeof(data));
57 std::string
GetHex()
const;
59 void SetHex(
const char* psz);
60 void SetHex(
const std::string& str);
75 const unsigned char*
begin()
const 80 const unsigned char*
end()
const 92 const uint8_t* ptr = data + pos * 8;
93 return ((uint64_t)ptr[0]) | \
94 ((uint64_t)ptr[1]) << 8 | \
95 ((uint64_t)ptr[2]) << 16 | \
96 ((uint64_t)ptr[3]) << 24 | \
97 ((uint64_t)ptr[4]) << 32 | \
98 ((uint64_t)ptr[5]) << 40 | \
99 ((uint64_t)ptr[6]) << 48 | \
100 ((uint64_t)ptr[7]) << 56;
103 template<
typename Stream>
106 s.write((
char*)data,
sizeof(data));
109 template<
typename Stream>
112 s.read((
char*)data,
sizeof(data));
145 return ReadLE64(
data);
173 std::vector<unsigned char> vHashBlock;
174 vHashBlock.assign(in.
begin(), in.
end());
180 std::vector<unsigned char> vHashBlock = in.
asBytes();
186 std::vector<unsigned char> rawValue;
187 rawValue.assign(in.
begin(), in.
end());
188 return dev::fromBigEndian<dev::u256, dev::bytes>(rawValue);
193 std::vector<unsigned char> rawValue(32, 0);
194 dev::toBigEndian<dev::u256, dev::bytes>(in, rawValue);
199 #endif // FABCOIN_UINT256_H
uint256(const base_blob< 256 > &b)
void Serialize(Stream &s) const
friend bool operator==(const base_blob &a, const base_blob &b)
std::string GetHex() const
const unsigned char * end() const
uint64_t GetUint64(int pos) const
const unsigned char * begin() const
uint64_t GetCheapHash() const
A cheap hash function that just returns 64 bits from the result, it can be used when the contents are...
std::string ToString() const
friend bool operator!=(const base_blob &a, const base_blob &b)
uint256(const std::vector< unsigned char > &vch)
void Unserialize(Stream &s)
dev::h256 uintToh256(const uint256 &in)
dev::u256 uintTou256(const uint256 &in)
void SetReverseHex(const char *psz)
std::string GetReverseHex() const
uint256 uint256S(const char *str)
friend bool operator<(const base_blob &a, const base_blob &b)
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Template base class for fixed-sized opaque blobs.
uint256 u256Touint(const dev::u256 &in)
uint160(const base_blob< 160 > &b)
uint160(const std::vector< unsigned char > &vch)
int Compare(const base_blob &other) const
void SetHex(const char *psz)
uint256 h256Touint(const dev::h256 &in)
unsigned int size() const