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

Method ReadData

lib/mdflib/mdflib/src/sr4block.cpp:122–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122void Sr4Block::ReadData(std::streambuf& buffer) const {
123 const uint64_t count = DataSize();
124 if (block_list_.empty() || count == 0) {
125 data_list_.clear();
126 return;
127 }
128 try {
129 data_list_.resize(static_cast<size_t>(count), 0);
130 } catch (const std::exception& ) {
131 // No room in memory for the block.
132 data_list_.clear();
133 return;
134 }
135
136 // The block list should only contain one block.
137 // A SD block is uncompressed data block
138 uint64_t index = 0;
139 for (const auto &block : block_list_) {
140 const auto *list = dynamic_cast<const DataListBlock *>(block.get());
141 const auto *data = dynamic_cast<const DataBlock *>(block.get());
142 if (list != nullptr) {
143 list->CopyDataToBuffer( buffer, data_list_, index);
144 } else if (block != nullptr) {
145 data->CopyDataToBuffer(buffer, data_list_, index);
146 }
147 }
148}
149
150void Sr4Block::ClearData() {
151 DataListBlock::ClearData();

Callers

nothing calls this directly

Calls 5

emptyMethod · 0.80
clearMethod · 0.45
resizeMethod · 0.45
getMethod · 0.45
CopyDataToBufferMethod · 0.45

Tested by

no test coverage detected