MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / WriteSample

Method WriteSample

lib/mdflib/mdflib/src/cg4block.cpp:489–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

487}
488
489void Cg4Block::WriteSample(std::streambuf& buffer, uint8_t record_id_size,
490 const std::vector<uint8_t> &source) {
491 switch (record_id_size) {
492 case 0:
493 // No Record ID to store
494 break;
495
496 case 1: {
497 const auto id = static_cast<uint8_t>(RecordId());
498 WriteNumber(buffer, id);
499 break;
500 }
501
502 case 2: {
503 const auto id = static_cast<uint16_t>(RecordId());
504 WriteNumber(buffer, id);
505 break;
506 }
507
508 case 4: {
509 const auto id = static_cast<uint32_t>(RecordId());
510 WriteNumber(buffer, id);
511 break;
512 }
513
514 default: {
515 const auto id = RecordId();
516 WriteNumber(buffer, id);
517 break;
518 }
519
520 }
521 const uint64_t bytes = buffer.sputn(
522 reinterpret_cast<const char*>(source.data()),
523 static_cast<std::streamsize>(source.size()));
524 if (bytes != source.size()) {
525 MDF_ERROR() << "Failed to write a sample data. Written : "
526 << bytes << "(" << source.size() << ")";
527 }
528 IncrementSample(); // Increment internal sample counter
529 NofSamples(Sample());
530}
531
532void Cg4Block::WriteCompressedSample(std::vector<uint8_t>& dest,
533 uint8_t record_id_size,

Callers 2

SaveQueueMethod · 0.80
SaveQueueMethod · 0.80

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected