| 465 | } |
| 466 | |
| 467 | bool redis_stream::get_one_message(const redis_result& rr, |
| 468 | redis_stream_message& message) |
| 469 | { |
| 470 | size_t size; |
| 471 | const redis_result** children = rr.get_children(&size); |
| 472 | if (size == 0 || children == NULL) { |
| 473 | return false; |
| 474 | } |
| 475 | if (size != 2) { |
| 476 | return false; |
| 477 | } |
| 478 | |
| 479 | const redis_result* child = children[0]; |
| 480 | if (child->get_type() != REDIS_RESULT_STRING) { |
| 481 | return false; |
| 482 | } |
| 483 | |
| 484 | child->argv_to_string(message.id); |
| 485 | |
| 486 | child = children[1]; |
| 487 | children = child->get_children(&size); |
| 488 | if (size == 0 || children == NULL) { |
| 489 | return false; |
| 490 | } |
| 491 | |
| 492 | if (size % 2 != 0) { |
| 493 | return false; |
| 494 | } |
| 495 | |
| 496 | for (size_t i = 0; i < size;) { |
| 497 | const redis_result* name = children[i++]; |
| 498 | if (name->get_type() != REDIS_RESULT_STRING) { |
| 499 | i++; |
| 500 | continue; |
| 501 | } |
| 502 | |
| 503 | const redis_result* value = children[i++]; |
| 504 | if (value->get_type() != REDIS_RESULT_STRING) { |
| 505 | continue; |
| 506 | } |
| 507 | |
| 508 | redis_stream_field field; |
| 509 | name->argv_to_string(field.name); |
| 510 | value->argv_to_string(field.value); |
| 511 | |
| 512 | message.fields.push_back(field); |
| 513 | } |
| 514 | |
| 515 | return true; |
| 516 | } |
| 517 | |
| 518 | ////////////////////////////////////////////////////////////////////////////// |
| 519 |
nothing calls this directly
no test coverage detected