6 #ifndef KAGOME_COMMON_BUFFERVIEW 7 #define KAGOME_COMMON_BUFFERVIEW 15 template <
size_t MaxSize>
22 using Span = gsl::span<const uint8_t>;
26 using Span::operator=;
36 Span::cbegin(), Span::cend(), other.cbegin(), other.cend());
41 const std::array<typename Span::value_type, N> &other)
const noexcept {
43 Span::cbegin(), Span::cend(), other.cbegin(), other.cend());
47 return std::lexicographical_compare(
48 cbegin(), cend(), other.cbegin(), other.cend());
53 const std::array<typename Span::value_type, N> &other)
const noexcept {
54 return std::lexicographical_compare(
55 Span::cbegin(), Span::cend(), other.cbegin(), other.cend());
60 return os << view.
toHex();
68 char presentation =
's';
71 constexpr
auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
73 auto it = ctx.begin(), end = ctx.end();
74 if (it != end && (*it ==
's' || *it ==
'l')) {
79 if (it != end && *it !=
'}') {
80 throw format_error(
"invalid format");
89 template <
typename FormatContext>
91 -> decltype(ctx.out()) {
95 return format_to(ctx.out(),
"<empty>");
98 if (presentation ==
's' && view.size() > 5) {
103 htobe16(*reinterpret_cast<const uint16_t *>(view.data())),
105 htobe16(*reinterpret_cast<const uint16_t *>(view.data() + view.size()
106 -
sizeof(uint16_t))));
109 return format_to(ctx.out(),
"0x{}", view.toHex());
113 #endif // KAGOME_COMMON_BUFFERVIEW
std::ostream & operator<<(std::ostream &os, const Blob< N > &blob)
std::string hex_lower(const gsl::span< const uint8_t > bytes) noexcept
Converts bytes to hex representation.
bool operator<(const std::array< typename Span::value_type, N > &other) const noexcept
common::BufferView BufferView
bool operator<(const BufferView &other) const noexcept
BufferView(const Span &other) noexcept
gsl::span< const uint8_t > Span
bool operator==(const Span &other) const noexcept
bool operator==(const std::array< typename Span::value_type, N > &other) const noexcept
std::string toHex() const