aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/input.h
diff options
context:
space:
mode:
authorMikhail Borisov <borisov.mikhail@gmail.com>2022-02-10 16:45:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:39 +0300
commita6a92afe03e02795227d2641b49819b687f088f8 (patch)
treef6984a1d27d5a7ec88a6fdd6e20cd5b7693b6ece /library/cpp/yson_pull/input.h
parentc6dc8b8bd530985bc4cce0137e9a5de32f1087cb (diff)
downloadydb-a6a92afe03e02795227d2641b49819b687f088f8.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson_pull/input.h')
-rw-r--r--library/cpp/yson_pull/input.h54
1 files changed, 27 insertions, 27 deletions
diff --git a/library/cpp/yson_pull/input.h b/library/cpp/yson_pull/input.h
index 2cdfae857e..f060c29535 100644
--- a/library/cpp/yson_pull/input.h
+++ b/library/cpp/yson_pull/input.h
@@ -1,18 +1,18 @@
-#pragma once
-
-#include "buffer.h"
-
-#include <util/generic/ptr.h>
-#include <util/generic/strbuf.h>
-#include <util/system/types.h>
-#include <util/system/yassert.h>
-
-#include <cstddef>
-#include <memory>
-
+#pragma once
+
+#include "buffer.h"
+
+#include <util/generic/ptr.h>
+#include <util/generic/strbuf.h>
+#include <util/system/types.h>
+#include <util/system/yassert.h>
+
+#include <cstddef>
+#include <memory>
+
class IInputStream;
class IZeroCopyInput;
-
+
namespace NYsonPull {
namespace NInput {
//! \brief Input stream adaptor interface.
@@ -21,33 +21,33 @@ namespace NYsonPull {
class IStream {
input_buffer buffer_;
bool at_end_ = false;
-
+
public:
virtual ~IStream() = default;
-
+
bool at_end() const {
return at_end_;
}
-
+
input_buffer& buffer() noexcept {
return buffer_;
}
const input_buffer& buffer() const noexcept {
return buffer_;
}
-
+
void fill_buffer() {
while (buffer_.is_empty() && !at_end()) {
at_end_ = do_fill_buffer() == result::at_end;
}
}
-
+
protected:
enum class result {
have_more_data, //! May continue reading
at_end, //! Reached end of stream
};
-
+
//! \brief Read next chunk of data.
//!
//! The implementation is to discard the buffer contents
@@ -57,25 +57,25 @@ namespace NYsonPull {
//! Read is assumed to always succeed unless it throws an exception.
virtual result do_fill_buffer() = 0;
};
-
+
//! \brief Read data from a contiguous memory block (i.e. a string)
//!
//! Does not take ownership on memory.
- THolder<IStream> FromMemory(TStringBuf data);
-
+ THolder<IStream> FromMemory(TStringBuf data);
+
//! \brief Read data from C FILE* object.
//!
//! Does not take ownership on file object.
//! Data is buffered internally regardless of file buffering.
- THolder<IStream> FromStdioFile(FILE* file, size_t buffer_size = 65536);
-
+ THolder<IStream> FromStdioFile(FILE* file, size_t buffer_size = 65536);
+
//! \brief Read data from POSIX file descriptor.
//!
//! Does not take ownership on streambuf.
- THolder<IStream> FromPosixFd(int fd, size_t buffer_size = 65536);
-
+ THolder<IStream> FromPosixFd(int fd, size_t buffer_size = 65536);
+
THolder<IStream> FromZeroCopyInput(IZeroCopyInput* input);
-
+
THolder<IStream> FromInputStream(IInputStream* input, size_t buffer_size = 65536);
}
}