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:40 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:40 +0300
commit5d50718e66d9c037dc587a0211110b7d25a66185 (patch)
treee98df59de24d2ef7c77baed9f41e4875a2fef972 /library/cpp/yson_pull/detail/output
parenta6a92afe03e02795227d2641b49819b687f088f8 (diff)
downloadydb-5d50718e66d9c037dc587a0211110b7d25a66185.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 2 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 fbb18b5467..475cf34785 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 d59ea6bfb9..03f2b40dc5 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 98ab7d9555..d4810f3353 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
}