MCPcopy Create free account
hub / github.com/ElementsProject/elements / read

Method read

src/streams.h:652–670  ·  view source on GitHub ↗

read a number of bytes

Source from the content-addressed store, hash-verified

650
651 //! read a number of bytes
652 void read(Span<std::byte> dst)
653 {
654 if (dst.size() + m_read_pos > nReadLimit) {
655 throw std::ios_base::failure("Read attempted past buffer limit");
656 }
657 while (dst.size() > 0) {
658 if (m_read_pos == nSrcPos)
659 Fill();
660 unsigned int pos = m_read_pos % vchBuf.size();
661 size_t nNow = dst.size();
662 if (nNow + pos > vchBuf.size())
663 nNow = vchBuf.size() - pos;
664 if (nNow + m_read_pos > nSrcPos)
665 nNow = nSrcPos - m_read_pos;
666 memcpy(dst.data(), &vchBuf[pos], nNow);
667 m_read_pos += nNow;
668 dst = dst.subspan(nNow);
669 }
670 }
671
672 //! return the current reading position
673 uint64_t GetPos() const {

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected