diff options
author | Mikhail Borisov <borisov.mikhail@gmail.com> | 2022-02-10 16:45:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:39 +0300 |
commit | a6a92afe03e02795227d2641b49819b687f088f8 (patch) | |
tree | f6984a1d27d5a7ec88a6fdd6e20cd5b7693b6ece /library/cpp/yson_pull/detail/byte_reader.h | |
parent | c6dc8b8bd530985bc4cce0137e9a5de32f1087cb (diff) | |
download | ydb-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/byte_reader.h')
-rw-r--r-- | library/cpp/yson_pull/detail/byte_reader.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/library/cpp/yson_pull/detail/byte_reader.h b/library/cpp/yson_pull/detail/byte_reader.h index 7cea50d323..36ffe8446b 100644 --- a/library/cpp/yson_pull/detail/byte_reader.h +++ b/library/cpp/yson_pull/detail/byte_reader.h @@ -1,29 +1,29 @@ -#pragma once - -#include "cescape.h" -#include "fail.h" -#include "stream_counter.h" - +#pragma once + +#include "cescape.h" +#include "fail.h" +#include "stream_counter.h" + #include <library/cpp/yson_pull/input.h> - + namespace NYsonPull { namespace NDetail { template <class StreamCounter> class byte_reader { NYsonPull::NInput::IStream& stream_; StreamCounter stream_counter_; - + public: byte_reader(NYsonPull::NInput::IStream& stream) : stream_(stream) { } - + // const-ness added to prevent direct stream mutation const NYsonPull::NInput::IStream& stream() { return stream_; } - + template <typename... Args> ATTRIBUTE(noinline, cold) void fail[[noreturn]](const char* msg, Args&&... args) { @@ -32,23 +32,23 @@ namespace NYsonPull { msg, std::forward<Args>(args)...); } - + template <bool AllowFinish> void fill_buffer() { stream_.fill_buffer(); - + if (!AllowFinish) { auto& buf = stream_.buffer(); - if (Y_UNLIKELY(buf.is_empty() && stream_.at_end())) { + if (Y_UNLIKELY(buf.is_empty() && stream_.at_end())) { fail("Premature end of stream"); } } } - + void fill_buffer() { return fill_buffer<true>(); - } - + } + template <bool AllowFinish> ui8 get_byte() { fill_buffer<AllowFinish>(); @@ -57,11 +57,11 @@ namespace NYsonPull { ? *buf.pos() : ui8{'\0'}; } - + ui8 get_byte() { return get_byte<true>(); } - + void advance(size_t bytes) { auto& buf = stream_.buffer(); stream_counter_.update( @@ -70,5 +70,5 @@ namespace NYsonPull { buf.advance(bytes); } }; - } + } } |