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

Method Write

lib/mdflib/mdflib/src/ch4block.cpp:67–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67uint64_t Ch4Block::Write(std::streambuf& buffer) { // NOLINT
68 const auto update = FilePosition() > 0;
69 if (update) {
70 WriteLink4List(buffer, ch_list_, kIndexCh,
71 UpdateOption::DoNotUpdateWrittenBlock);
72 return block_length_;
73 }
74 nof_elements_ = static_cast<uint32_t>(element_list_.size());
75 block_type_ = "##CH";
76 block_length_ = 24 + ((4 + (nof_elements_ * 3)) * 8) + 8 + 1 + 3;
77 link_list_.resize(4 + (nof_elements_ * 3), 0);
78
79 for (size_t index_n = 0; index_n < nof_elements_; ++index_n) {
80 const auto index = 4 + (index_n * 3);
81 const auto &element = element_list_[index_n];
82 link_list_[index] =
83 element.data_group != nullptr ? element.data_group->Index() : 0;
84 link_list_[index + 1] =
85 element.channel_group != nullptr ? element.channel_group->Index() : 0;
86 link_list_[index + 2] =
87 element.channel != nullptr ? element.channel->Index() : 0;
88 }
89 WriteTx4(buffer, kIndexTx, name_);
90 WriteMdComment(buffer, kIndexMd);
91 WriteLink4List(buffer, ch_list_, kIndexCh,
92 UpdateOption::DoNotUpdateWrittenBlock);
93
94 uint64_t bytes = MdfBlock::Write(buffer);
95 bytes += WriteNumber(buffer, nof_elements_);
96 bytes += WriteNumber(buffer, type_);
97 bytes += WriteBytes(buffer, 3);
98 UpdateBlockSize(buffer, bytes);
99
100 return bytes;
101}
102
103MdfBlock *Ch4Block::Find(int64_t index) const { // NOLINT
104 for (auto &ch : ch_list_) {

Callers

nothing calls this directly

Calls 4

WriteBytesFunction · 0.85
sizeMethod · 0.45
resizeMethod · 0.45
IndexMethod · 0.45

Tested by

no test coverage detected