2#include "barretenberg/serialize/msgpack.hpp"
3#include "barretenberg/serialize/msgpack_apply.hpp"
21template <
typename T>
void _msgpack_stream_write(std::ostream& os,
const std::shared_ptr<T>& field)
23 using namespace serialize;
29inline void _msgpack_stream_write(std::ostream& os,
const auto& field)
31 using namespace serialize;
37inline void _msgpack_stream_write_key_value_pairs(std::ostream& os)
45inline void _msgpack_stream_write_key_value_pairs(std::ostream& os,
46 const std::string& key,
51 _msgpack_stream_write(os, value);
53 _msgpack_stream_write_key_value_pairs(os, rest...);
60inline void _msgpack_stream_write_key_value_pairs(std::ostream& os,
61 const std::string& key,
66 _msgpack_stream_write(os, value);
68 _msgpack_stream_write_key_value_pairs(os, rest...);
79template <msgpack_concepts::HasMsgPack T> std::ostream& operator<<(std::ostream& os,
const T& obj)
83 const_cast<T&
>(obj).msgpack([&](
auto&... key_value_pairs) {
85 serialize::_msgpack_stream_write_key_value_pairs(os, key_value_pairs...);
90inline std::ostream& operator<<(std::ostream& os, std::vector<uint8_t>
const& arr)
92 std::ios_base::fmtflags f(os.flags());
93 os <<
"[" << std::hex << std::setfill(
'0');
94 for (
auto byte : arr) {
95 os << ' ' << std::setw(2) << +static_cast<unsigned char>(
byte);
102template <std::
integral T,
typename A>
inline std::ostream& operator<<(std::ostream& os, std::vector<T, A>
const& arr)
105 for (
auto element : arr) {
106 os <<
' ' << element;
112template <
typename T,
typename A>
113 requires(!std::integral<T>)
114inline std::ostream&
operator<<(std::ostream& os, std::vector<T, A>
const& arr)
117 for (
auto element : arr) {
118 os <<
' ' << element <<
'\n';
124template <
size_t S>
inline std::ostream& operator<<(std::ostream& os, std::array<uint8_t, S>
const& arr)
126 std::ios_base::fmtflags f(os.flags());
127 os <<
"[" << std::hex << std::setfill(
'0');
128 for (
auto byte : arr) {
129 os << ' ' << std::setw(2) << +static_cast<unsigned char>(
byte);
136template <
typename T,
size_t S>
inline std::ostream& operator<<(std::ostream& os, std::array<T, S>
const& arr)
138 std::ios_base::fmtflags f(os.flags());
139 os <<
"[" << std::hex << std::setfill(
'0');
140 for (
auto element : arr) {
141 os <<
' ' << element;
148template <
typename T,
typename U>
inline std::ostream& operator<<(std::ostream& os, std::pair<T, U>
const& pair)
150 os <<
"(" << pair.first <<
", " << pair.second <<
")";
154template <
typename T>
inline std::ostream& operator<<(std::ostream& os, std::optional<T>
const& opt)
156 return opt ? os << *opt : os <<
"std::nullopt";
159template <
typename T,
typename U>
inline std::ostream& operator<<(std::ostream& os, std::map<T, U>
const& map)
162 for (
const auto& elem : map) {
163 os <<
" " << elem.first <<
": " << elem.second <<
"\n";
Definition: concepts.hpp:8