aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/buffer.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/stream/buffer.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/stream/buffer.h')
-rw-r--r--util/stream/buffer.h82
1 files changed, 41 insertions, 41 deletions
diff --git a/util/stream/buffer.h b/util/stream/buffer.h
index 9dc99dbe49..0b3b94bb0a 100644
--- a/util/stream/buffer.h
+++ b/util/stream/buffer.h
@@ -1,11 +1,11 @@
#pragma once
-
+
#include "zerocopy.h"
#include "zerocopy_output.h"
-
+
#include <util/generic/ptr.h>
-
-class TBuffer;
+
+class TBuffer;
/**
* @addtogroup Streams_Buffers
@@ -16,25 +16,25 @@ class TBuffer;
* Output stream that writes into a `TBuffer`.
*/
class TBufferOutput: public IZeroCopyOutput {
-public:
- class TImpl;
-
+public:
+ class TImpl;
+
/**
* Constructs a stream that writes into an internal buffer.
*
* @param buflen Initial size of the internal buffer.
- */
- TBufferOutput(size_t buflen = 1024);
-
+ */
+ 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.
- */
- TBufferOutput(TBuffer& buffer);
-
+ */
+ TBufferOutput(TBuffer& buffer);
+
TBufferOutput(TBufferOutput&&) noexcept;
TBufferOutput& operator=(TBufferOutput&&) noexcept;
@@ -44,22 +44,22 @@ public:
* @returns Buffer that this stream writes into.
*/
TBuffer& Buffer() const noexcept;
-
-private:
+
+private:
size_t DoNext(void** ptr) override;
void DoUndo(size_t len) override;
void DoWrite(const void* buf, size_t len) override;
void DoWriteC(char c) override;
-
-private:
- THolder<TImpl> Impl_;
+
+private:
+ THolder<TImpl> Impl_;
};
/**
* Input stream that reads from an external `TBuffer`.
*/
class TBufferInput: public IZeroCopyInputFastReadTo {
-public:
+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
@@ -68,52 +68,52 @@ public:
* @param buffer External buffer to read from.
*/
TBufferInput(const TBuffer& buffer);
-
+
~TBufferInput() override;
-
+
const TBuffer& Buffer() const noexcept;
void Rewind() noexcept;
-
+
protected:
size_t DoNext(const void** ptr, size_t len) override;
void DoUndo(size_t len) override;
-private:
- const TBuffer& Buf_;
- size_t Readed_;
-};
-
+private:
+ const TBuffer& Buf_;
+ size_t Readed_;
+};
+
/**
* Input/output stream that works with a `TBuffer`.
*/
-class TBufferStream: public TBufferOutput, public TBufferInput {
-public:
+class TBufferStream: public TBufferOutput, public TBufferInput {
+public:
/**
* 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)
+ inline TBufferStream(size_t buflen = 1024)
+ : TBufferOutput(buflen)
, TBufferInput(TBufferOutput::Buffer())
- {
- }
-
+ {
+ }
+
/**
* Constructs a stream that works with the provided buffer.
*
* @param buffer Buffer to work with.
*/
- inline TBufferStream(TBuffer& buffer)
- : TBufferOutput(buffer)
+ inline TBufferStream(TBuffer& buffer)
+ : TBufferOutput(buffer)
, TBufferInput(TBufferOutput::Buffer())
- {
- }
-
+ {
+ }
+
~TBufferStream() override = default;
using TBufferOutput::Buffer;
-};
-
+};
+
/** @} */