input.cpp 968 B

123456789101112131415161718192021222324252627282930313233
  1. #include "input.h"
  2. #include <library/cpp/yson_pull/detail/input/stdio_file.h>
  3. #include <library/cpp/yson_pull/detail/input/stream.h>
  4. #include <util/generic/ptr.h>
  5. #include <util/stream/file.h>
  6. #include <util/stream/mem.h>
  7. using namespace NYsonPull::NInput;
  8. using namespace NYsonPull::NDetail::NInput;
  9. namespace NInput = NYsonPull::NInput;
  10. THolder<IStream> NInput::FromStdioFile(FILE* file, size_t buffer_size) {
  11. return MakeHolder<TStdioFile>(file, buffer_size);
  12. }
  13. THolder<IStream> NInput::FromPosixFd(int fd, size_t buffer_size) {
  14. return MakeHolder<TFHandle>(fd, buffer_size);
  15. }
  16. THolder<IStream> NInput::FromMemory(TStringBuf data) {
  17. return MakeHolder<TOwned<TMemoryInput>>(data);
  18. }
  19. THolder<IStream> NInput::FromInputStream(IInputStream* input, size_t buffer_size) {
  20. return MakeHolder<TOwned<TBufferedInput>>(input, buffer_size);
  21. }
  22. THolder<IStream> NInput::FromZeroCopyInput(IZeroCopyInput* input) {
  23. return MakeHolder<TZeroCopy>(input);
  24. }