Bitcoin Core 28.99.0
P2P Digital Currency
|
Template base class for fixed-sized opaque blobs. More...
#include <uint256.h>
Public Member Functions | |
constexpr | base_blob () |
constexpr | base_blob (uint8_t v) |
constexpr | base_blob (Span< const unsigned char > vch) |
consteval | base_blob (std::string_view hex_str) |
constexpr bool | IsNull () const |
constexpr void | SetNull () |
constexpr int | Compare (const base_blob &other) const |
Lexicographic ordering. More... | |
constexpr const unsigned char * | data () const |
constexpr unsigned char * | data () |
constexpr unsigned char * | begin () |
constexpr unsigned char * | end () |
constexpr const unsigned char * | begin () const |
constexpr const unsigned char * | end () const |
constexpr uint64_t | GetUint64 (int pos) const |
template<typename Stream > | |
void | Serialize (Stream &s) const |
template<typename Stream > | |
void | Unserialize (Stream &s) |
Hex representation | |
The hex representation used by GetHex(), ToString(), FromHex() and SetHexDeprecated() is unusual, since it shows bytes of the base_blob in reverse order. For example, a 4-byte blob {0x12, 0x34, 0x56, 0x78} is represented as "78563412" instead of the more typical "12345678" representation that would be shown in a hex editor or used by typical byte-array / hex conversion functions like python's bytes.hex() and bytes.fromhex(). The nice thing about the reverse-byte representation, even though it is unusual, is that if a blob contains an arithmetic number in little endian format (with least significant bytes first, and most significant bytes last), the GetHex() output will match the way the number would normally be written in base-16 (with most significant digits first and least significant digits last). This means, for example, that ArithToUint256(num).GetHex() can be used to display an arith_uint256 num value as a number, because ArithToUint256() converts the number to a blob in little-endian format, so the arith_uint256 class doesn't need to have its own number parsing and formatting functions. | |
std::string | GetHex () const |
void | SetHexDeprecated (std::string_view str) |
Unlike FromHex this accepts any invalid input, thus it is fragile and deprecated! More... | |
std::string | ToString () const |
Static Public Member Functions | |
static constexpr unsigned int | size () |
Protected Attributes | |
std::array< uint8_t, WIDTH > | m_data |
Static Protected Attributes | |
static constexpr int | WIDTH = BITS / 8 |
Friends | |
constexpr bool | operator== (const base_blob &a, const base_blob &b) |
constexpr bool | operator!= (const base_blob &a, const base_blob &b) |
constexpr bool | operator< (const base_blob &a, const base_blob &b) |
Template base class for fixed-sized opaque blobs.
|
inlineconstexpr |
|
inlineexplicitconstexpr |
|
inlineexplicitconstexpr |
|
explicit |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Lexicographic ordering.
Definition at line 64 of file uint256.h.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
std::string base_blob< BITS >::GetHex |
Definition at line 11 of file uint256.cpp.
|
inlineconstexpr |
|
inlineconstexpr |
|
inline |
void base_blob< BITS >::SetHexDeprecated | ( | std::string_view | str | ) |
Unlike FromHex this accepts any invalid input, thus it is fragile and deprecated!
Definition at line 21 of file uint256.cpp.
|
inlineconstexpr |
|
inlinestaticconstexpr |
std::string base_blob< BITS >::ToString |
Definition at line 47 of file uint256.cpp.
|
inline |
|
staticconstexprprotected |