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

Method CopyDataToBuffer

lib/mdflib/mdflib/src/datablock.cpp:39–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39uint64_t DataBlock::CopyDataToBuffer(std::streambuf& buffer,
40 std::vector<uint8_t> &dest,
41 uint64_t &buffer_index) const {
42 SetFilePosition(buffer, DataPosition());
43 const uint64_t data_size = DataSize();
44 if (data_size == 0) {
45 return 0;
46 }
47 if (dest.size() < (buffer_index + data_size)) {
48 throw std::runtime_error("Buffer overflow detected.");
49 }
50
51 const uint64_t reads = buffer.sgetn(
52 reinterpret_cast<char*>(dest.data()) + buffer_index,
53 static_cast<std::streamsize>(data_size));
54 buffer_index += reads;
55 return reads;
56}
57
58bool DataBlock::Data(const std::vector<uint8_t> &data) {
59 data_ = data;

Callers

nothing calls this directly

Calls 3

SetFilePositionFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected