walk.h 922 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include "zerocopy.h"
  3. /**
  4. * Zero-copy stream that simplifies implementation of derived classes.
  5. *
  6. * Derived classes must implement `DoUnboundedNext` method.
  7. */
  8. class IWalkInput: public IZeroCopyInputFastReadTo {
  9. public:
  10. IWalkInput()
  11. : Buf_(nullptr)
  12. , Len_(0)
  13. {
  14. }
  15. protected:
  16. void DoUndo(size_t len) override;
  17. size_t DoNext(const void** ptr, size_t len) override;
  18. /**
  19. * Returns the next data chunk from this input stream. There are no
  20. * restrictions on the size of the data chunk.
  21. *
  22. * @param ptr[out] Pointer to the start of the data chunk.
  23. * @returns Size of the returned data chunk, in bytes.
  24. * Return value of zero signals end of stream.
  25. */
  26. virtual size_t DoUnboundedNext(const void** ptr) = 0;
  27. private:
  28. const void* Buf_;
  29. size_t Len_;
  30. };