Decode one COBS frame, without its zero delimiter.
- Returns
- false when the frame is malformed. out may then hold a partial result.
Definition at line 489 of file Framing.hpp.
490 {
491 size_t index = 0;
492 while (index < frame.size()) {
493 const size_t code = frame[index++];
494 if (code == 0) {
495 return false;
496 }
497 const size_t run = code - 1;
498 if (index +
run > frame.size()) {
499 return false;
500 }
501 for (
size_t i = 0; i <
run; ++i) {
502 if (frame[index + i] == 0) {
503 return false;
504 }
505 }
506 out.insert(out.end(), frame.begin() + static_cast<std::ptrdiff_t>(index),
507 frame.begin() +
static_cast<std::ptrdiff_t
>(index +
run));
509 if (code != 0xFF && index < frame.size()) {
510 out.push_back(0);
511 }
512 }
513 return true;
514 }
References run().
Referenced by MayaFlux::Transitive::Protocol::CobsFramer::push().