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

Method Write

lib/mdflib/mdflib/src/cg4block.cpp:194–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194uint64_t Cg4Block::Write(std::streambuf& buffer) {
195 const bool update = FilePosition() > 0; // True if already written to file
196 const auto master = (flags_ & CgFlag::RemoteMaster) != 0;
197 const auto vlsd = (flags_ & CgFlag::VlsdChannel) != 0;
198 if (!update) {
199 block_type_ = "##CG";
200 block_length_ = 24 + (6 * 8) + 8 + 8 + 2 + 2 + 4 + 4 + 4;
201 if (master) {
202 block_length_ += 8; // Add one more link for master
203 }
204 link_list_.resize(master ? 7 : 6, 0);
205 }
206
207
208 WriteLink4List(buffer, cn_list_, kIndexCn,
209 UpdateOption::DoNotUpdateWrittenBlock);
210 WriteTx4(buffer, kIndexName, acquisition_name_);
211 WriteBlock4(buffer, si_block_, kIndexSi);
212 WriteLink4List(buffer, sr_list_, kIndexSr,
213 UpdateOption::DoNotUpdateWrittenBlock);
214 WriteMdComment(buffer, kIndexMd);
215 // ToDo: Remote master handling
216
217 uint64_t bytes = update ? MdfBlock::Update(buffer) : MdfBlock::Write(buffer);
218 if (update) {
219 // Update number of samples
220 if (nof_samples_position_ > 0) {
221 SetFilePosition(buffer, nof_samples_position_);
222 WriteNumber(buffer, nof_samples_);
223 }
224 // Update VLSD size (which is a 64-bit value, low 32-bit)
225 if (nof_data_position_ > 0) {
226 SetFilePosition(buffer, nof_data_position_);
227 WriteNumber(buffer, nof_data_bytes_);
228 }
229 // Update VLSD size (which is a 64-bit value, high 32-bit)
230 if (nof_invalid_position_ > 0) {
231 SetFilePosition(buffer, nof_invalid_position_);
232 WriteNumber(buffer, nof_invalid_bytes_);
233 }
234 bytes = block_length_;
235 } else {
236 bytes += WriteNumber(buffer, record_id_);
237 nof_samples_position_ = GetFilePosition(buffer);
238 bytes += WriteNumber(buffer, nof_samples_);
239 bytes += WriteNumber(buffer, flags_);
240 bytes += WriteNumber(buffer, path_separator_);
241 bytes += WriteBytes(buffer, 4);
242 // Save the nof data and invalid bytes in case of a VLSD group.
243 // Number data bytes is the lower 32-bit and number invalid bytes is the
244 // 32-bit higher value.
245 if (vlsd) {
246 nof_data_position_ = GetFilePosition(buffer);
247 }
248 bytes += WriteNumber(buffer, nof_data_bytes_);
249 if (vlsd) {
250 nof_invalid_position_ = GetFilePosition(buffer);
251 }

Callers

nothing calls this directly

Calls 7

SetFilePositionFunction · 0.85
GetFilePositionFunction · 0.85
WriteBytesFunction · 0.85
UpdateDataLinkMethod · 0.80
resizeMethod · 0.45
IndexMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected