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

Method Write

lib/mdflib/mdflib/src/dl4block.cpp:64–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64uint64_t Dl4Block::Write(std::streambuf& buffer) {
65 const bool update = FilePosition() > 0;
66 if (update) {
67 // The DL block properties cannot be changed, but it
68 // is possible to append DL blocks
69 WriteBlockList(buffer, kIndexData);
70 return block_length_;
71 }
72 const size_t nof = block_list_.size(); // Number of DZ/DT blocks
73 block_type_ = "##DL";
74 link_list_.resize(1 + nof);
75
76 block_length_ = 24 + 8 + (nof*8) + 1 + 3 + 4;
77 const bool equal = (flags_ & Dl4Flags::EqualLength) != 0;
78 const bool time = (flags_ & Dl4Flags::TimeValues) != 0;
79 const bool angle = (flags_ & Dl4Flags::AngleValues) != 0;
80 const bool distance = (flags_ & Dl4Flags::DistanceValues) != 0;
81
82 if (equal) {
83 block_length_ += 8;
84 } else {
85 block_length_ += 8 * nof;
86 }
87 if (time) {
88 block_length_ += 8 * nof;
89 }
90 if (angle) {
91 block_length_ += 8 * nof;
92 }
93 if (distance) {
94 block_length_ += 8 * nof;
95 }
96
97 uint64_t bytes = MdfBlock::Write(buffer);
98 bytes += WriteNumber(buffer,flags_);
99 bytes += WriteBytes(buffer, 3);
100 bytes += WriteNumber(buffer, static_cast<uint32_t>(nof));
101 if (equal) {
102 bytes += WriteNumber(buffer, equal_length_);
103 } else {
104 for (size_t index = 0; index < nof; ++index) {
105 bytes += WriteNumber(buffer, Offset(index));
106 }
107 }
108
109 if (time) {
110 for (size_t index = 0; index < nof; ++index) {
111 bytes += WriteNumber(buffer, TimeValue(index));
112 }
113 }
114
115 if (angle) {
116 for (size_t index = 0; index < nof; ++index) {
117 bytes += WriteNumber(buffer, AngleValue(index));
118 }
119 }
120
121 if (distance) {

Callers

nothing calls this directly

Calls 3

WriteBytesFunction · 0.85
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected