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

Function print_next

cpp/examples/encode_decode.cpp:181–240  ·  view source on GitHub ↗

print_next prints the next value from values by recursively descending into complex values. NOTE this is for example purposes only: There is a built in ostream operator<< for values.

Source from the content-addressed store, hash-verified

179//
180//
181static void print_next(proton::codec::decoder& d) {
182 proton::type_id type = d.next_type();
183 proton::codec::start s;
184 switch (type) {
185 case proton::ARRAY: {
186 d >> s;
187 std::cout << "array<" << s.element;
188 if (s.is_described) {
189 std::cout << ", descriptor=";
190 print_next(d);
191 }
192 std::cout << ">[";
193 for (size_t i = 0; i < s.size; ++i) {
194 if (i) std::cout << ", ";
195 print_next(d);
196 }
197 std::cout << "]";
198 d >> proton::codec::finish();
199 break;
200 }
201 case proton::LIST: {
202 d >> s;
203 std::cout << "list[";
204 for (size_t i = 0; i < s.size; ++i) {
205 if (i) std::cout << ", ";
206 print_next(d);
207 }
208 std::cout << "]";
209 d >> proton::codec::finish();
210 break;
211 }
212 case proton::MAP: {
213 d >> s;
214 std::cout << "map{";
215 for (size_t i = 0; i < s.size/2; ++i) {
216 if (i) std::cout << ", ";
217 print_next(d);
218 std::cout << ":"; // key:value
219 print_next(d);
220 }
221 std::cout << "}";
222 d >> proton::codec::finish();
223 break;
224 }
225 case proton::DESCRIBED: {
226 d >> s;
227 std::cout << "described(";
228 print_next(d); // Descriptor
229 print_next(d); // value
230 d >> proton::codec::finish();
231 break;
232 }
233 default:
234 // A simple type. We could continue the switch for all AMQP types but
235 // we will take a short cut and extract to another value and print that.
236 proton::value v2;
237 d >> v2;
238 std::cout << type << "(" << v2 << ")";

Callers 1

printFunction · 0.85

Calls 2

finishClass · 0.85
next_typeMethod · 0.80

Tested by

no test coverage detected