| 554 | } |
| 555 | |
| 556 | bool Serializer::write_parameter_id(const unsigned id, const size_t size, const bool must_understand) |
| 557 | { |
| 558 | if (static_cast<ACE_CDR::ULong>(id) > MEMBER_ID_MAX) { |
| 559 | return false; |
| 560 | } |
| 561 | |
| 562 | const Encoding::XcdrVersion xcdr = encoding().xcdr_version(); |
| 563 | if (xcdr == Encoding::XCDR_VERSION_1) { |
| 564 | if (!align_w(xcdr1_pid_alignment)) { |
| 565 | return false; |
| 566 | } |
| 567 | |
| 568 | // Determine if we need to use a short or long PID |
| 569 | const bool long_pid = id > (1 << 14) || size > (1 << 16); |
| 570 | |
| 571 | // Write the short part of the PID |
| 572 | /* |
| 573 | * TODO(iguessthislldo): Control when to use "must understand" and "impl |
| 574 | * extension"? |
| 575 | * |
| 576 | * The XTypes CDR rules seem to imply they're alway here but that doesn't |
| 577 | * sound quite right. |
| 578 | * |
| 579 | * Also see TODOs above and the TODO below. |
| 580 | */ |
| 581 | const ACE_CDR::UShort pid_id = |
| 582 | pid_impl_extension + pid_must_understand + |
| 583 | (long_pid ? pid_extended : static_cast<ACE_CDR::UShort>(id)); |
| 584 | if (!(*this << pid_id)) { |
| 585 | return false; |
| 586 | } |
| 587 | const ACE_CDR::UShort pid_size = long_pid ? 8 : ACE_CDR::UShort(size); |
| 588 | if (!(*this << pid_size)) { |
| 589 | return false; |
| 590 | } |
| 591 | |
| 592 | // If PID is long, write the extended/long part. |
| 593 | if (long_pid && ( |
| 594 | !(*this << static_cast<ACE_CDR::ULong>(id)) || |
| 595 | !(*this << static_cast<ACE_CDR::ULong>(size)))) { |
| 596 | return false; |
| 597 | } |
| 598 | |
| 599 | reset_alignment(); |
| 600 | } else if (xcdr == Encoding::XCDR_VERSION_2) { |
| 601 | // Compute Length Code, write EM Header and NEXTINT |
| 602 | const ACE_CDR::ULong lc = (size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : size == 8 ? 3 : 4); |
| 603 | const ACE_CDR::ULong emheader = (lc << 28) | id | (must_understand ? emheader_must_understand : 0); |
| 604 | if (!(*this << emheader)) { |
| 605 | return false; |
| 606 | } |
| 607 | if (lc == 4) { |
| 608 | return *this << ACE_CDR::ULong(size); |
| 609 | } |
| 610 | } |
| 611 | return true; |
| 612 | } |
| 613 |
no outgoing calls
no test coverage detected