aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/detail/input
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/detail/input
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/detail/input')
-rw-r--r--library/cpp/yson_pull/detail/input/buffered.h20
-rw-r--r--library/cpp/yson_pull/detail/input/stdio_file.h30
-rw-r--r--library/cpp/yson_pull/detail/input/stream.h116
3 files changed, 83 insertions, 83 deletions
diff --git a/library/cpp/yson_pull/detail/input/buffered.h b/library/cpp/yson_pull/detail/input/buffered.h
index 9b1482577f..fef577df8b 100644
--- a/library/cpp/yson_pull/detail/input/buffered.h
+++ b/library/cpp/yson_pull/detail/input/buffered.h
@@ -1,31 +1,31 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/yson_pull/detail/macros.h>
-
+
#include <library/cpp/yson_pull/exceptions.h>
#include <library/cpp/yson_pull/input.h>
-
-#include <cstdio>
-#include <memory>
-
+
+#include <cstdio>
+#include <memory>
+
namespace NYsonPull {
namespace NDetail {
namespace NInput {
class TBuffered: public NYsonPull::NInput::IStream {
TArrayHolder<ui8> buffer_;
size_t size_;
-
+
public:
explicit TBuffered(size_t buffer_size)
: buffer_{new ui8[buffer_size]}
, size_{buffer_size} {
}
-
+
protected:
ui8* buffer_data() const {
return buffer_.Get();
}
-
+
size_t buffer_size() const {
return size_;
}
diff --git a/library/cpp/yson_pull/detail/input/stdio_file.h b/library/cpp/yson_pull/detail/input/stdio_file.h
index c412b7e59b..328931d435 100644
--- a/library/cpp/yson_pull/detail/input/stdio_file.h
+++ b/library/cpp/yson_pull/detail/input/stdio_file.h
@@ -1,35 +1,35 @@
-#pragma once
-
-#include "buffered.h"
-
+#pragma once
+
+#include "buffered.h"
+
#include <library/cpp/yson_pull/detail/macros.h>
-
+
#include <library/cpp/yson_pull/exceptions.h>
#include <library/cpp/yson_pull/input.h>
-
-#include <cstdio>
-#include <memory>
-
+
+#include <cstdio>
+#include <memory>
+
namespace NYsonPull {
namespace NDetail {
namespace NInput {
class TStdioFile: public TBuffered {
FILE* file_;
-
+
public:
TStdioFile(FILE* file, size_t buffer_size)
: TBuffered(buffer_size)
, file_{file} {
}
-
+
protected:
result do_fill_buffer() override {
auto nread = ::fread(buffer_data(), 1, buffer_size(), file_);
- if (Y_UNLIKELY(nread == 0)) {
- if (ferror(file_)) {
+ if (Y_UNLIKELY(nread == 0)) {
+ if (ferror(file_)) {
throw NException::TSystemError();
}
- if (feof(file_)) {
+ if (feof(file_)) {
return result::at_end;
}
}
@@ -37,6 +37,6 @@ namespace NYsonPull {
return result::have_more_data;
}
};
- }
+ }
} // namespace NDetail
}
diff --git a/library/cpp/yson_pull/detail/input/stream.h b/library/cpp/yson_pull/detail/input/stream.h
index 791cd5a3f5..5ed993f606 100644
--- a/library/cpp/yson_pull/detail/input/stream.h
+++ b/library/cpp/yson_pull/detail/input/stream.h
@@ -1,69 +1,69 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/yson_pull/detail/macros.h>
-
+
#include <library/cpp/yson_pull/input.h>
-
-#include <util/stream/buffered.h>
-#include <util/stream/file.h>
-#include <util/stream/zerocopy.h>
-#include <util/system/file.h>
-
-namespace NYsonPull {
- namespace NDetail {
- namespace NInput {
- class TStreamBase: public NYsonPull::NInput::IStream {
- protected:
+
+#include <util/stream/buffered.h>
+#include <util/stream/file.h>
+#include <util/stream/zerocopy.h>
+#include <util/system/file.h>
+
+namespace NYsonPull {
+ namespace NDetail {
+ namespace NInput {
+ class TStreamBase: public NYsonPull::NInput::IStream {
+ protected:
result DoFillBufferFrom(IZeroCopyInput& input) {
- void* ptr = nullptr;
- size_t size = input.Next(&ptr);
- if (Y_UNLIKELY(size == 0)) {
- return result::at_end;
- }
- buffer().reset(static_cast<ui8*>(ptr), static_cast<ui8*>(ptr) + size);
- return result::have_more_data;
- }
- };
-
- class TZeroCopy: public TStreamBase {
+ void* ptr = nullptr;
+ size_t size = input.Next(&ptr);
+ if (Y_UNLIKELY(size == 0)) {
+ return result::at_end;
+ }
+ buffer().reset(static_cast<ui8*>(ptr), static_cast<ui8*>(ptr) + size);
+ return result::have_more_data;
+ }
+ };
+
+ class TZeroCopy: public TStreamBase {
IZeroCopyInput* Input;
-
- public:
+
+ public:
explicit TZeroCopy(IZeroCopyInput* input)
- : Input(input)
- {
- }
-
- protected:
- result do_fill_buffer() override {
- return DoFillBufferFrom(*Input);
- }
- };
-
+ : Input(input)
+ {
+ }
+
+ protected:
+ result do_fill_buffer() override {
+ return DoFillBufferFrom(*Input);
+ }
+ };
+
template <typename TBuffered>
- class TOwned: public TStreamBase {
- TBuffered Input;
-
- public:
+ class TOwned: public TStreamBase {
+ TBuffered Input;
+
+ public:
template <typename... Args>
- explicit TOwned(Args&&... args)
- : Input(std::forward<Args>(args)...)
- {
- }
-
- protected:
- result do_fill_buffer() override {
- return DoFillBufferFrom(Input);
- }
- };
-
+ explicit TOwned(Args&&... args)
+ : Input(std::forward<Args>(args)...)
+ {
+ }
+
+ protected:
+ result do_fill_buffer() override {
+ return DoFillBufferFrom(Input);
+ }
+ };
+
class TFHandle: public TOwned<TFileInput> {
- public:
- TFHandle(int fd, size_t buffer_size)
+ public:
+ TFHandle(int fd, size_t buffer_size)
: TOwned<TFileInput>(Duplicate(fd), buffer_size)
- {
- }
- };
- }
+ {
+ }
+ };
+ }
} // namespace NDetail
}