aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/detail/output
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/output
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/output')
-rw-r--r--library/cpp/yson_pull/detail/output/buffered.h24
-rw-r--r--library/cpp/yson_pull/detail/output/stdio_file.h24
-rw-r--r--library/cpp/yson_pull/detail/output/stream.h92
3 files changed, 70 insertions, 70 deletions
diff --git a/library/cpp/yson_pull/detail/output/buffered.h b/library/cpp/yson_pull/detail/output/buffered.h
index 475cf34785..fbb18b5467 100644
--- a/library/cpp/yson_pull/detail/output/buffered.h
+++ b/library/cpp/yson_pull/detail/output/buffered.h
@@ -1,11 +1,11 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/yson_pull/detail/macros.h>
-
+
#include <library/cpp/yson_pull/output.h>
-
-#include <util/generic/strbuf.h>
-
+
+#include <util/generic/strbuf.h>
+
namespace NYsonPull {
namespace NDetail {
namespace NOutput {
@@ -13,29 +13,29 @@ namespace NYsonPull {
class TBuffered: public NYsonPull::NOutput::IStream {
TArrayHolder<ui8> buffer_;
size_t size_;
-
+
public:
TBuffered(size_t buffer_size)
: buffer_{new ui8[buffer_size]}
, size_{buffer_size} {
reset_buffer();
}
-
+
protected:
void do_flush_buffer(TStringBuf extra) override {
auto& buf = buffer();
if (!buf.is_empty()) {
- do_write({reinterpret_cast<const char*>(buf.begin()), buf.used()});
+ do_write({reinterpret_cast<const char*>(buf.begin()), buf.used()});
reset_buffer();
}
if (extra.size() >= buf.available()) {
do_write(extra);
- } else if (extra.size() > 0) {
+ } else if (extra.size() > 0) {
::memcpy(buf.pos(), extra.data(), extra.size());
buf.advance(extra.size());
}
}
-
+
private:
void do_write(TStringBuf data) {
// CRTP dispatch
@@ -46,6 +46,6 @@ namespace NYsonPull {
buffer().reset(buffer_.Get(), buffer_.Get() + size_);
}
};
- }
+ }
} // namespace NDetail
}
diff --git a/library/cpp/yson_pull/detail/output/stdio_file.h b/library/cpp/yson_pull/detail/output/stdio_file.h
index 03f2b40dc5..d59ea6bfb9 100644
--- a/library/cpp/yson_pull/detail/output/stdio_file.h
+++ b/library/cpp/yson_pull/detail/output/stdio_file.h
@@ -1,33 +1,33 @@
-#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 <cstdio>
-
+
+#include <cstdio>
+
namespace NYsonPull {
namespace NDetail {
namespace NOutput {
class TStdioFile: public TBuffered<TStdioFile> {
FILE* file_;
-
+
public:
TStdioFile(FILE* file, size_t buffer_size)
: TBuffered<TStdioFile>(buffer_size)
, file_(file)
{
}
-
+
void write(TStringBuf data) {
auto nwritten = ::fwrite(data.data(), 1, data.size(), file_);
- if (Y_UNLIKELY(static_cast<size_t>(nwritten) != data.size())) {
+ if (Y_UNLIKELY(static_cast<size_t>(nwritten) != data.size())) {
throw NException::TSystemError();
}
}
};
- }
+ }
} // namespace NDetail
}
diff --git a/library/cpp/yson_pull/detail/output/stream.h b/library/cpp/yson_pull/detail/output/stream.h
index d4810f3353..98ab7d9555 100644
--- a/library/cpp/yson_pull/detail/output/stream.h
+++ b/library/cpp/yson_pull/detail/output/stream.h
@@ -1,56 +1,56 @@
-#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 <util/stream/output.h>
-#include <util/stream/file.h>
-#include <util/system/file.h>
-
-namespace NYsonPull {
- namespace NDetail {
- namespace NOutput {
- class TStream: public TBuffered<TStream> {
+
+#include <util/stream/output.h>
+#include <util/stream/file.h>
+#include <util/system/file.h>
+
+namespace NYsonPull {
+ namespace NDetail {
+ namespace NOutput {
+ class TStream: public TBuffered<TStream> {
IOutputStream* Output;
-
- public:
+
+ public:
TStream(IOutputStream* output, size_t buffer_size)
- : TBuffered<TStream>(buffer_size)
- , Output(output)
- {
- }
-
- void write(TStringBuf data) {
- Output->Write(data);
- }
- };
-
+ : TBuffered<TStream>(buffer_size)
+ , Output(output)
+ {
+ }
+
+ void write(TStringBuf data) {
+ Output->Write(data);
+ }
+ };
+
template <typename TOutput>
- class TOwned: public TBuffered<TOwned<TOutput>> {
- TOutput Output;
-
- public:
+ class TOwned: public TBuffered<TOwned<TOutput>> {
+ TOutput Output;
+
+ public:
template <typename... Args>
- TOwned(size_t buffer_size, Args&&... args)
- : TBuffered<TOwned>(buffer_size)
- , Output(std::forward<Args>(args)...)
- {
- }
-
- void write(TStringBuf data) {
- Output.Write(data);
- }
- };
-
+ TOwned(size_t buffer_size, Args&&... args)
+ : TBuffered<TOwned>(buffer_size)
+ , Output(std::forward<Args>(args)...)
+ {
+ }
+
+ void write(TStringBuf data) {
+ Output.Write(data);
+ }
+ };
+
class TFHandle: public TOwned<TUnbufferedFileOutput> {
- public:
- TFHandle(int fd, size_t buffer_size)
+ public:
+ TFHandle(int fd, size_t buffer_size)
: TOwned<TUnbufferedFileOutput>(buffer_size, Duplicate(fd))
- {
- }
- };
- }
+ {
+ }
+ };
+ }
} // namespace NDetail
}