16template <
typename PtrTypeT>
62template <
typename PtrTypeT>
77 if (ptr_ == end_ || end_ ==
nullptr) {
91 if (ptr_ == end_ || end_ ==
nullptr) {
95 const size_t available =
static_cast<size_t>(end_ - ptr_);
96 if (
count > available) {
110 if (end_ !=
nullptr) {
111 const size_t available =
static_cast<size_t>(end_ - ptr_);
112 if (
count <= available) {
142template <
typename PtrTypeT>
155 if (position_ >= size_) {
159 return ptr_[position_++];
167 if (position_ >= size_) {
171 if (
count > size_ - position_) {
172 count = size_ - position_;
184 if (position_ +
count <= size_) {
231template <
typename Itr>
232struct MemoryIteratorTraits {
233 static constexpr bool is_memory =
false;
236template <
typename PtrType>
238 static constexpr bool is_memory =
true;
241template <
typename PtrType>
243 static constexpr bool is_memory =
true;
246template <
typename PtrType>
248 static constexpr bool is_memory =
true;
Multipass bounded iterator reading from [begin, end).
void skip(size_t count)
Advances by up to count bytes.
byte read()
Reads one byte at current position and advances.
void seek(uint64_t position)
Sets absolute position and clears EOS.
Status status() const
Returns kEndOfStream after EOS is observed, otherwise kOk.
MultipassGenericMemoryIterator(PtrType begin, PtrType end)
Creates multipass iterator over [begin, end).
uint64_t size() const
Returns total iterable size.
size_t read(byte *result, size_t count)
Reads up to count bytes from current position and advances.
void rewind()
Resets position to start and clears EOS.
PtrType ptr() const
Returns pointer at current position.
uint64_t position() const
Returns current position.
Bounded iterator reading from [begin, end).
PtrType ptr() const
Returns current pointer.
size_t read(byte *result, size_t count)
Reads up to count bytes when available.
byte read()
Reads one byte when available.
Status status() const
Returns kEndOfStream after EOS marker is set, otherwise kOk.
void skip(size_t count)
Skips up to count bytes.
SafeGenericMemoryIterator(PtrType begin, PtrType end)
Creates bounded iterator over [begin, end).
Infinite iterator reading from memory starting at provided address.
byte read()
Returns byte at current pointer and advances by one.
void skip(size_t count)
Advances pointer by count bytes.
Status status() const
Returns kOk unconditionally.
UnsafeGenericMemoryIterator(PtrType ptr)
Creates iterator starting at ptr.
size_t read(byte *result, size_t count)
Copies count bytes from current pointer, then advances by count.
PtrType ptr() const
Returns current pointer.
roo::basic_string_view< CharT, Traits > basic_string_view
SafeGenericMemoryIterator< const byte * > MemoryIterator
UnsafeGenericMemoryIterator< const byte * > UnsafeMemoryIterator
MultipassGenericMemoryIterator< const byte * > MultipassMemoryIterator