68 template <
typename Index,
typename GetBufferedRange,
typename ReadFromReservoir,
typename FillReservoir>
70 GetBufferedRange&& getBufferedRange,
71 ReadFromReservoir&& readFromReservoir,
72 FillReservoir&& fillReservoir)
76 const auto bufferedRange = getBufferedRange();
78 if (bufferedRange.contains (rangeToRead.
getStart()))
81 readFromReservoir (rangeToReadInBuffer);
82 rangeToRead.
setStart (rangeToReadInBuffer.getEnd());
86 fillReservoir (rangeToRead.
getStart());
88 const auto newRange = getBufferedRange();
90 if (newRange.isEmpty() || ! newRange.contains (rangeToRead.
getStart()))
A general-purpose range object, that simply represents any linear range with a start and end point.
constexpr ValueType getStart() const noexcept
Returns the start of the range.
constexpr bool isEmpty() const noexcept
Returns true if the range has a length of zero.
constexpr Range getIntersectionWith(Range other) const noexcept
Returns the range that is the intersection of the two ranges, or an empty range with an undefined sta...
void setStart(const ValueType newStart) noexcept
Changes the start position of the range, leaving the end position unchanged.
Helper functions for managing buffered readers.
static Range< Index > doBufferedRead(Range< Index > rangeToRead, GetBufferedRange &&getBufferedRange, ReadFromReservoir &&readFromReservoir, FillReservoir &&fillReservoir)
Attempts to read the requested range from some kind of input stream, with intermediate buffering in a...