aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/buffer.h
diff options
context:
space:
mode:
authorAlexander Fokin <apfokin@gmail.com>2022-02-10 16:45:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:38 +0300
commitbf9e69a933f89af083d895185f01ed65e4d90766 (patch)
treeb2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /util/stream/buffer.h
parent863a59a65247c24db7cb06789bc5cf79d04da32f (diff)
downloadydb-bf9e69a933f89af083d895185f01ed65e4d90766.tar.gz
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/stream/buffer.h')
-rw-r--r--util/stream/buffer.h114
1 files changed, 57 insertions, 57 deletions
diff --git a/util/stream/buffer.h b/util/stream/buffer.h
index 35d9db3018..9dc99dbe49 100644
--- a/util/stream/buffer.h
+++ b/util/stream/buffer.h
@@ -1,48 +1,48 @@
#pragma once
-#include "zerocopy.h"
+#include "zerocopy.h"
#include "zerocopy_output.h"
#include <util/generic/ptr.h>
class TBuffer;
-
-/**
- * @addtogroup Streams_Buffers
- * @{
- */
-
-/**
- * Output stream that writes into a `TBuffer`.
- */
+
+/**
+ * @addtogroup Streams_Buffers
+ * @{
+ */
+
+/**
+ * Output stream that writes into a `TBuffer`.
+ */
class TBufferOutput: public IZeroCopyOutput {
public:
class TImpl;
- /**
- * Constructs a stream that writes into an internal buffer.
- *
- * @param buflen Initial size of the internal buffer.
+ /**
+ * Constructs a stream that writes into an internal buffer.
+ *
+ * @param buflen Initial size of the internal buffer.
*/
TBufferOutput(size_t buflen = 1024);
- /**
- * Constructs a stream that writes into the provided buffer. It's up to the
- * user to make sure that the buffer doesn't get destroyed while this stream
- * is in use.
- *
- * @param buffer Buffer to write into.
+ /**
+ * Constructs a stream that writes into the provided buffer. It's up to the
+ * user to make sure that the buffer doesn't get destroyed while this stream
+ * is in use.
+ *
+ * @param buffer Buffer to write into.
*/
TBufferOutput(TBuffer& buffer);
- TBufferOutput(TBufferOutput&&) noexcept;
- TBufferOutput& operator=(TBufferOutput&&) noexcept;
+ TBufferOutput(TBufferOutput&&) noexcept;
+ TBufferOutput& operator=(TBufferOutput&&) noexcept;
~TBufferOutput() override;
- /**
- * @returns Buffer that this stream writes into.
- */
+ /**
+ * @returns Buffer that this stream writes into.
+ */
TBuffer& Buffer() const noexcept;
private:
@@ -55,65 +55,65 @@ private:
THolder<TImpl> Impl_;
};
-/**
- * Input stream that reads from an external `TBuffer`.
- */
+/**
+ * Input stream that reads from an external `TBuffer`.
+ */
class TBufferInput: public IZeroCopyInputFastReadTo {
public:
- /**
- * Constructs a stream that reads from an external buffer. It's up to the
- * user to make sure that the buffer doesn't get destroyed before this
- * stream.
- *
- * @param buffer External buffer to read from.
- */
- TBufferInput(const TBuffer& buffer);
+ /**
+ * Constructs a stream that reads from an external buffer. It's up to the
+ * user to make sure that the buffer doesn't get destroyed before this
+ * stream.
+ *
+ * @param buffer External buffer to read from.
+ */
+ TBufferInput(const TBuffer& buffer);
~TBufferInput() override;
const TBuffer& Buffer() const noexcept;
-
+
void Rewind() noexcept;
-protected:
+protected:
size_t DoNext(const void** ptr, size_t len) override;
void DoUndo(size_t len) override;
-
+
private:
const TBuffer& Buf_;
size_t Readed_;
};
-/**
- * Input/output stream that works with a `TBuffer`.
- */
+/**
+ * Input/output stream that works with a `TBuffer`.
+ */
class TBufferStream: public TBufferOutput, public TBufferInput {
public:
- /**
- * Constructs a stream that works with an internal buffer.
- *
- * @param buflen Initial size of the internal buffer.
- */
+ /**
+ * Constructs a stream that works with an internal buffer.
+ *
+ * @param buflen Initial size of the internal buffer.
+ */
inline TBufferStream(size_t buflen = 1024)
: TBufferOutput(buflen)
- , TBufferInput(TBufferOutput::Buffer())
+ , TBufferInput(TBufferOutput::Buffer())
{
}
- /**
- * Constructs a stream that works with the provided buffer.
- *
- * @param buffer Buffer to work with.
- */
+ /**
+ * Constructs a stream that works with the provided buffer.
+ *
+ * @param buffer Buffer to work with.
+ */
inline TBufferStream(TBuffer& buffer)
: TBufferOutput(buffer)
- , TBufferInput(TBufferOutput::Buffer())
+ , TBufferInput(TBufferOutput::Buffer())
{
}
~TBufferStream() override = default;
-
- using TBufferOutput::Buffer;
+
+ using TBufferOutput::Buffer;
};
-/** @} */
+/** @} */