| 254 | } |
| 255 | |
| 256 | uint64_t Cn3Block::Write(std::streambuf& buffer) { |
| 257 | int64_t long_name_link = 0; |
| 258 | int64_t display_name_link = 0; |
| 259 | |
| 260 | const bool update = |
| 261 | FilePosition() > 0; // Write or update the values inside the block |
| 262 | if (!update) { |
| 263 | block_type_ = "CN"; |
| 264 | block_size_ = |
| 265 | (2 + 2) + (5 * 4) + 2 + 32 + 128 + 3 * 2 + 2 + 3 * 8 + 2 * 4 + 2; |
| 266 | link_list_.resize(5, 0); |
| 267 | |
| 268 | if (!long_name_.empty()) { |
| 269 | Tx3Block tx(long_name_); |
| 270 | tx.Init(*this); |
| 271 | tx.Write(buffer); |
| 272 | long_name_link = tx.FilePosition(); |
| 273 | } |
| 274 | |
| 275 | if (!display_name_.empty()) { |
| 276 | Tx3Block tx(display_name_); |
| 277 | tx.Init(*this); |
| 278 | tx.Write(buffer); |
| 279 | display_name_link = tx.FilePosition(); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | uint64_t bytes = update ? block_size_ : MdfBlock::Write(buffer); |
| 284 | if (!update) { |
| 285 | bytes += WriteNumber(buffer, channel_type_); |
| 286 | bytes += WriteStr(buffer, short_name_, 32); |
| 287 | bytes += WriteStr(buffer, description_, 128); |
| 288 | bytes += WriteNumber(buffer, start_offset_); |
| 289 | bytes += WriteNumber(buffer, nof_bits_); |
| 290 | bytes += WriteNumber(buffer, signal_type_); |
| 291 | bytes += WriteBool(buffer, range_valid_); |
| 292 | bytes += WriteNumber(buffer, min_); |
| 293 | bytes += WriteNumber(buffer, max_); |
| 294 | bytes += WriteNumber(buffer, sample_rate_); |
| 295 | bytes += WriteNumber(buffer, static_cast<uint32_t>(long_name_link)); |
| 296 | bytes += WriteNumber(buffer, static_cast<uint32_t>(display_name_link)); |
| 297 | bytes += WriteNumber(buffer, byte_offset_); |
| 298 | } |
| 299 | |
| 300 | if (cc_block_ && Link(kIndexCc) <= 0) { |
| 301 | cc_block_->Write(buffer); |
| 302 | UpdateLink(buffer, kIndexCc, cc_block_->FilePosition()); |
| 303 | } |
| 304 | |
| 305 | if (ce_block_ && Link(kIndexCe) <= 0) { |
| 306 | ce_block_->Write(buffer); |
| 307 | UpdateLink(buffer, kIndexCe, ce_block_->FilePosition()); |
| 308 | } |
| 309 | |
| 310 | if (cd_block_ && Link(kIndexCd) <= 0) { |
| 311 | cd_block_->Write(buffer); |
| 312 | UpdateLink(buffer, kIndexCd, cd_block_->FilePosition()); |
| 313 | } |
nothing calls this directly
no test coverage detected