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

Method Write

lib/mdflib/mdflib/src/ev4block.cpp:170–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170uint64_t Ev4Block::Write(std::streambuf& buffer) {
171 const bool update =
172 FilePosition() > 0; // Write or update the values inside the block
173 if (update) {
174 return block_length_;
175 }
176 length_m_ = static_cast<uint32_t>(scope_list_.size());
177 length_n_ = static_cast<uint16_t>(attachment_list_.size());
178
179 const auto group = !group_name_.empty();
180 if (group) {
181 flags_ |= 0x02;
182 }
183 block_type_ = "##EV";
184 block_length_ =
185 24 + ((5 + length_m_ + length_n_) * 8) + 5 + 3 + 4 + 2 + 2 + 8 + 8;
186 if (group) {
187 block_size_ += 8;
188 }
189 link_list_.resize(5 + length_m_ + length_n_ + (group ? 1 : 0), 0);
190 link_list_[kIndexParent] =
191 parent_event_ != nullptr ? parent_event_->Index() : 0;
192 link_list_[kIndexRange] = range_event_ != nullptr ? range_event_->Index() : 0;
193 for (size_t index_m = 0; index_m < length_m_; ++index_m) {
194 const auto index = 5 + index_m;
195 const auto *block = reinterpret_cast<const MdfBlock *>(scope_list_[index_m]);
196 link_list_[index] = block != nullptr ? block->FilePosition() : 0;
197 }
198 for (size_t index_n = 0; index_n < length_n_; ++index_n) {
199 const auto index = 5 + length_m_ + index_n;
200 const auto *block = attachment_list_[index_n];
201 link_list_[index] = block != nullptr ? block->Index() : 0;
202 }
203 WriteTx4(buffer, kIndexName, name_);
204 if (group) {
205 WriteTx4(buffer, link_list_.size() - 1, group_name_);
206 }
207 WriteMdComment(buffer, kIndexMd);
208
209 uint64_t bytes = MdfBlock::Write(buffer);
210 bytes += WriteNumber(buffer, type_);
211 bytes += WriteNumber(buffer, sync_type_);
212 bytes += WriteNumber(buffer, range_type_);
213 bytes += WriteNumber(buffer, cause_);
214 bytes += WriteNumber(buffer, flags_);
215 bytes += WriteBytes(buffer, 3);
216 bytes += WriteNumber(buffer, length_m_);
217 bytes += WriteNumber(buffer, length_n_);
218 bytes += WriteNumber(buffer, creator_index_);
219 bytes += WriteNumber(buffer, sync_base_value_);
220 bytes += WriteNumber(buffer, sync_factor_);
221 UpdateBlockSize(buffer, bytes);
222
223 return bytes;
224}
225
226int64_t Ev4Block::Index() const { return FilePosition(); }
227

Callers

nothing calls this directly

Calls 6

WriteBytesFunction · 0.85
emptyMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
IndexMethod · 0.45
FilePositionMethod · 0.45

Tested by

no test coverage detected