MCPcopy Create free account
hub / github.com/apache/qpid-proton / mixed_containers

Function mixed_containers

cpp/examples/encode_decode.cpp:114–134  ·  view source on GitHub ↗

Containers with mixed types use value to represent arbitrary AMQP types.

Source from the content-addressed store, hash-verified

112
113// Containers with mixed types use value to represent arbitrary AMQP types.
114static void mixed_containers() {
115 std::cout << std::endl << "== List and map of mixed type values." << std::endl;
116 proton::value v;
117
118 std::vector<proton::value> l;
119 l.push_back(proton::value(42));
120 l.push_back(proton::value(std::string("foo")));
121 // By default, a sequence of proton::value is treated as an AMQP list.
122 v = l;
123 print(v);
124 std::vector<proton::value> l2 = proton::get<std::vector<proton::value> >(v);
125 std::cout << l2 << std::endl;
126
127 std::map<proton::value, proton::value> m;
128 m[proton::value("five")] = proton::value(5);
129 m[proton::value(4)] = proton::value("four"); v = m;
130 print(v);
131 typedef std::map<proton::value, proton::value> value_map;
132 value_map m2(proton::get<value_map>(v));
133 std::cout << m2 << std::endl;
134}
135
136// Insert using stream operators (see print_next for example of extracting with stream ops.)
137static void insert_stream_operators() {

Callers 1

mainFunction · 0.85

Calls 2

printFunction · 0.85
valueFunction · 0.50

Tested by

no test coverage detected