buffered.h 872 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <library/cpp/yson_pull/detail/macros.h>
  3. #include <library/cpp/yson_pull/exceptions.h>
  4. #include <library/cpp/yson_pull/input.h>
  5. #include <cstdio>
  6. #include <memory>
  7. namespace NYsonPull {
  8. namespace NDetail {
  9. namespace NInput {
  10. class TBuffered: public NYsonPull::NInput::IStream {
  11. TArrayHolder<ui8> buffer_;
  12. size_t size_;
  13. public:
  14. explicit TBuffered(size_t buffer_size)
  15. : buffer_{new ui8[buffer_size]}
  16. , size_{buffer_size} {
  17. }
  18. protected:
  19. ui8* buffer_data() const {
  20. return buffer_.Get();
  21. }
  22. size_t buffer_size() const {
  23. return size_;
  24. }
  25. };
  26. }
  27. } // namespace NDetail
  28. }