stream.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <util/stream/walk.h>
  3. #include <util/stream/input.h>
  4. #include <util/stream/output.h>
  5. #include <util/stream/zerocopy.h>
  6. #include <util/generic/buffer.h>
  7. namespace NBlockCodecs {
  8. struct ICodec;
  9. class TCodedOutput: public IOutputStream {
  10. public:
  11. TCodedOutput(IOutputStream* out, const ICodec* c, size_t bufLen);
  12. ~TCodedOutput() override;
  13. private:
  14. void DoWrite(const void* buf, size_t len) override;
  15. void DoFlush() override;
  16. void DoFinish() override;
  17. bool FlushImpl();
  18. private:
  19. const ICodec* C_;
  20. TBuffer D_;
  21. TBuffer O_;
  22. IOutputStream* S_;
  23. };
  24. class TDecodedInput: public IWalkInput {
  25. public:
  26. TDecodedInput(IInputStream* in);
  27. TDecodedInput(IInputStream* in, const ICodec* codec);
  28. ~TDecodedInput() override;
  29. private:
  30. size_t DoUnboundedNext(const void** ptr) override;
  31. private:
  32. TBuffer D_;
  33. IInputStream* S_;
  34. const ICodec* C_;
  35. };
  36. }