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

Method GetNextByte

lib/mdflib/mdflib/src/readcache.cpp:351–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351bool ReadCache::GetNextByte(uint8_t &input) {
352 if ( file_index_ < data_size_) {
353 if (file_buffer_.empty()) {
354 // Read direct from the file
355 input = buffer_.sbumpc();
356 } else {
357 // Read from buffer in case of DZ block
358 input = file_buffer_[file_index_];
359 }
360 ++file_index_;
361 ++data_count_;
362 return true;
363 }
364
365 if (block_index_ >= block_list_.size()) {
366 return false;
367 }
368
369 auto* current_block = block_list_[block_index_];
370 ++block_index_;
371 if (current_block == nullptr) {
372 return false;
373 }
374 file_index_ = 0;
375 data_size_ = current_block->DataSize();
376 if (current_block->BlockType() == "DZ") {
377 // Need a temp buffer in between
378 try {
379 file_buffer_.resize(static_cast<size_t>(data_size_) );
380 } catch (const std::exception&) {
381 return false;
382 }
383
384 uint64_t temp_index = 0;
385 current_block->CopyDataToBuffer(buffer_,file_buffer_, temp_index);
386 } else {
387 // Read from the file directly
388 SetFilePosition(buffer_, current_block->DataPosition());
389 file_buffer_.clear(); // Indicate that we read from the file directly
390 }
391 // Read in the data form file to
392 if (file_index_ >= data_size_) {
393 return false;
394 }
395 if (file_buffer_.empty()) {
396 input = buffer_.sbumpc();
397 } else {
398 input = file_buffer_[file_index_];
399 }
400 ++file_index_;
401 ++data_count_;
402 return true;
403}
404
405uint64_t ReadCache::ParseRecordId() {
406 if (dg4_block_ == nullptr) {

Callers

nothing calls this directly

Calls 9

SetFilePositionFunction · 0.85
emptyMethod · 0.80
DataPositionMethod · 0.80
sizeMethod · 0.45
DataSizeMethod · 0.45
BlockTypeMethod · 0.45
resizeMethod · 0.45
CopyDataToBufferMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected