18#ifndef BACKENDS_TOFINO_BF_ASM_BSON_H_
19#define BACKENDS_TOFINO_BF_ASM_BSON_H_
23#include "backends/tofino/bf-asm/json.h"
30 bson_wrap(T &o) : o(o) {}
32 bson_wrap(U &o) : o(o) {}
40std::istream &operator>>(std::istream &in, bson_wrap<std::unique_ptr<obj>>
json);
41std::istream &operator>>(std::istream &in, bson_wrap<json::vector>
json);
42std::istream &operator>>(std::istream &in, bson_wrap<json::map>
json);
43inline std::istream &operator>>(std::istream &in, bson_wrap<obj *>
json) {
44 std::unique_ptr<obj> p;
46 if (in)
json.o = p.release();
54 return operator<<(out, bson_wrap<const vector>(json.o));
56inline std::ostream &operator<<(std::ostream &out,
bson_wrap<map> json) {
57 return operator<<(out, bson_wrap<const map>(json.o));
59inline std::ostream &operator<<(std::ostream &out,
bson_wrap<obj> json) {
60 return operator<<(out, bson_wrap<const obj>(json.o));
63 return out << binary(*json.o);
66 return out << binary(*json.o);
68inline std::ostream &operator<<(std::ostream &out,
bson_wrap<
const std::unique_ptr<obj>> json) {
69 return out << binary(*json.o.get());