aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/buffer.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/buffer.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/buffer.h')
-rw-r--r--library/cpp/yson_pull/buffer.h36
1 files changed, 18 insertions, 18 deletions
diff --git a/library/cpp/yson_pull/buffer.h b/library/cpp/yson_pull/buffer.h
index 04c9220ef3..1ab75c6bc5 100644
--- a/library/cpp/yson_pull/buffer.h
+++ b/library/cpp/yson_pull/buffer.h
@@ -1,11 +1,11 @@
-#pragma once
-
-#include <util/system/types.h>
-#include <util/system/yassert.h>
-
-#include <cstddef>
-
-namespace NYsonPull {
+#pragma once
+
+#include <util/system/types.h>
+#include <util/system/yassert.h>
+
+#include <cstddef>
+
+namespace NYsonPull {
//! \brief A non-owning buffer model.
//!
//! Represents a \p pos pointer moving between \p begin and \p end.
@@ -14,7 +14,7 @@ namespace NYsonPull {
T* begin_ = nullptr;
T* pos_ = nullptr;
T* end_ = nullptr;
-
+
public:
T* begin() const noexcept {
return begin_;
@@ -25,49 +25,49 @@ namespace NYsonPull {
T* end() const noexcept {
return end_;
}
-
+
//! \brief Amount of data after current position.
size_t available() const noexcept {
return end_ - pos_;
}
-
+
//! \brief Amount of data before current position.
size_t used() const noexcept {
return pos_ - begin_;
}
-
+
//! \brief Move current position \p nbytes forward.
void advance(size_t nbytes) noexcept {
Y_ASSERT(pos_ + nbytes <= end_);
pos_ += nbytes;
}
-
+
//! \brief Reset buffer pointers.
void reset(T* new_begin, T* new_end, T* new_pos) {
begin_ = new_begin;
pos_ = new_pos;
end_ = new_end;
}
-
+
//! \brief Reset buffer to beginning
void reset(T* new_begin, T* new_end) {
reset(new_begin, new_end, new_begin);
}
};
-
+
class output_buffer: public buffer<ui8> {
public:
//! \brief An output buffer is empty when there is no data written to it.
bool is_empty() const noexcept {
return pos() == begin();
}
-
+
//! \brief An output buffer is full when there is no space to write more data to it.
bool is_full() const noexcept {
return pos() == end();
}
};
-
+
class input_buffer: public buffer<const ui8> {
public:
//! An input stream is empty when there is no data to read in it.
@@ -75,5 +75,5 @@ namespace NYsonPull {
return pos() == end();
}
};
-
+
}