diff options
| author | albert <[email protected]> | 2022-02-10 16:48:14 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:48:14 +0300 | 
| commit | 9f25ef3232c288ca664ceee6c376cf64e4349a2e (patch) | |
| tree | b192eaf3150845f7302fafd460a972b0439d6fe5 /util/stream | |
| parent | 6a1e535429145ec1ecfbc5f1efd3c95323261fb5 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/stream')
| -rw-r--r-- | util/stream/format.h | 10 | ||||
| -rw-r--r-- | util/stream/mem.cpp | 4 | ||||
| -rw-r--r-- | util/stream/mem.h | 154 | ||||
| -rw-r--r-- | util/stream/output.h | 4 | 
4 files changed, 86 insertions, 86 deletions
| diff --git a/util/stream/format.h b/util/stream/format.h index b033208a1b0..c17431f0528 100644 --- a/util/stream/format.h +++ b/util/stream/format.h @@ -114,7 +114,7 @@ namespace NFormatPrivate {          if (str[0] == '-') {              stream << '-';              str.Skip(1); -        } +        }           if (value.Flags & HF_ADDX) {              if (Base == 16) { @@ -130,7 +130,7 @@ namespace NFormatPrivate {          stream << str;          return stream; -    } +    }       template <typename Char, size_t Base>      struct TBaseText { @@ -275,11 +275,11 @@ static constexpr ::NFormatPrivate::TUnsignedBaseNumber<T, 16> Hex(const T& value   * @param value                         Value to output.   * @param flags                         Output flags.   */ -template <typename T> +template <typename T>   static constexpr ::NFormatPrivate::TBaseNumber<T, 16> SHex(const T& value, const ENumberFormat flags = HF_FULL | HF_ADDX) noexcept {      return {value, flags}; -} - +}  +   /**   * Output manipulator similar to `std::setbase(2)`.   * diff --git a/util/stream/mem.cpp b/util/stream/mem.cpp index 22a3339e274..a91c90a3058 100644 --- a/util/stream/mem.cpp +++ b/util/stream/mem.cpp @@ -52,11 +52,11 @@ void TMemoryOutput::DoUndo(size_t len) {  }  void TMemoryOutput::DoWrite(const void* buf, size_t len) { -    char* end = Buf_ + len; +    char* end = Buf_ + len;       Y_ENSURE(end <= End_, TStringBuf("memory output stream exhausted"));      memcpy(Buf_, buf, len); -    Buf_ = end; +    Buf_ = end;   }  void TMemoryOutput::DoWriteC(char c) { diff --git a/util/stream/mem.h b/util/stream/mem.h index 18a5d467729..038b1bf4c18 100644 --- a/util/stream/mem.h +++ b/util/stream/mem.h @@ -3,8 +3,8 @@  #include "zerocopy.h"  #include "zerocopy_output.h" -#include <util/generic/strbuf.h> - +#include <util/generic/strbuf.h>  +   /**   * @addtogroup Streams_Memory   * @{ @@ -14,7 +14,7 @@   * Input stream that reads data from a memory block.   */  class TMemoryInput: public IZeroCopyInputFastReadTo { -public: +public:       TMemoryInput() noexcept;      /** @@ -57,31 +57,31 @@ public:       * @param len                       Size of the new memory block.       */      void Reset(const void* buf, size_t len) noexcept { -        Buf_ = (const char*)buf; -        Len_ = len; -    } +        Buf_ = (const char*)buf;  +        Len_ = len;  +    }       /**       * @returns                         Whether there is more data in the stream.       */      bool Exhausted() const noexcept { -        return !Avail(); -    } +        return !Avail();  +    }       /**       * @returns                         Number of bytes available in the stream.       */      size_t Avail() const noexcept { -        return Len_; -    } +        return Len_;  +    }       /**       * @returns                         Current read position in the memory block       *                                  used by this stream.       */      const char* Buf() const noexcept { -        return Buf_; -    } +        return Buf_;  +    }       /**       * Initializes this stream with a next chunk extracted from the given zero @@ -94,22 +94,22 @@ public:          if (!Len_) {              Reset(nullptr, 0);          } -    } +    }  -private: +private:       size_t DoNext(const void** ptr, size_t len) override;      void DoUndo(size_t len) override; -private: -    const char* Buf_; -    size_t Len_; +private:  +    const char* Buf_;  +    size_t Len_;   };  /**   * Output stream that writes data to a memory block.   */  class TMemoryOutput: public IZeroCopyOutput { -public: +public:       /**       * Constructs a stream that writes to the provided memory block. It's up       * to the user to make sure that the memory block doesn't get freed while @@ -138,50 +138,50 @@ public:       */      inline void Reset(void* buf, size_t len) noexcept {          Buf_ = static_cast<char*>(buf); -        End_ = Buf_ + len; -    } +        End_ = Buf_ + len;  +    }       /**       * @returns                         Whether there is more space in the       *                                  stream for writing.       */      inline bool Exhausted() const noexcept { -        return !Avail(); -    } +        return !Avail();  +    }       /**       * @returns                         Number of bytes available for writing       *                                  in the stream.       */      inline size_t Avail() const noexcept { -        return End_ - Buf_; -    } +        return End_ - Buf_;  +    }       /**       * @returns                         Current write position in the memory block       *                                  used by this stream.       */      inline char* Buf() const noexcept { -        return Buf_; -    } +        return Buf_;  +    }       /**       * @returns                         Pointer to the end of the memory block       *                                  used by this stream.       */ -    char* End() const { -        return End_; -    } - -private: +    char* End() const {  +        return End_;  +    }  +  +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; -protected: -    char* Buf_; -    char* End_; +protected:  +    char* Buf_;  +    char* End_;   };  /** @@ -191,65 +191,65 @@ protected:   * @see TMemoryOutput   */  class TMemoryWriteBuffer: public TMemoryOutput { -public: -    TMemoryWriteBuffer(void* buf, size_t len) -        : TMemoryOutput(buf, len) -        , Beg_(Buf_) +public:  +    TMemoryWriteBuffer(void* buf, size_t len)  +        : TMemoryOutput(buf, len)  +        , Beg_(Buf_)       {      } - -    void Reset(void* buf, size_t len) { -        TMemoryOutput::Reset(buf, len); -        Beg_ = Buf_; -    } - -    size_t Len() const { -        return Buf() - Beg(); -    } - -    size_t Empty() const { -        return Buf() == Beg(); -    } - +  +    void Reset(void* buf, size_t len) {  +        TMemoryOutput::Reset(buf, len);  +        Beg_ = Buf_;  +    }  +  +    size_t Len() const {  +        return Buf() - Beg();  +    }  +  +    size_t Empty() const {  +        return Buf() == Beg();  +    }  +       /**       * @returns                         Data that has been written into this       *                                  stream as a string.       */ -    TStringBuf Str() const { -        return TStringBuf(Beg(), Buf()); -    } - -    char* Beg() const { -        return Beg_; -    } - +    TStringBuf Str() const {  +        return TStringBuf(Beg(), Buf());  +    }  +  +    char* Beg() const {  +        return Beg_;  +    }  +       /**       * @param ptr                       New write position for this stream.       *                                  Must be inside the memory block that       *                                  this stream uses.       */ -    void SetPos(char* ptr) { +    void SetPos(char* ptr) {           Y_ASSERT(Beg_ <= ptr); -        SetPosImpl(ptr); -    } - +        SetPosImpl(ptr);  +    }  +       /**       * @param pos                       New write position for this stream,       *                                  relative to the beginning of the memory       *                                  block that this stream uses.       */ -    void SetPos(size_t pos) { -        SetPosImpl(Beg_ + pos); -    } - -protected: -    void SetPosImpl(char* ptr) { +    void SetPos(size_t pos) {  +        SetPosImpl(Beg_ + pos);  +    }  +  +protected:  +    void SetPosImpl(char* ptr) {           Y_ASSERT(End_ >= ptr); -        Buf_ = ptr; -    } - -protected: -    char* Beg_; -}; - +        Buf_ = ptr;  +    }  +  +protected:  +    char* Beg_;  +};  +   /** @} */ diff --git a/util/stream/output.h b/util/stream/output.h index 00eef50b958..8a2f2091161 100644 --- a/util/stream/output.h +++ b/util/stream/output.h @@ -82,7 +82,7 @@ public:      inline void Write(const TStringBuf st) {          Write(st.data(), st.size());      } - +       /**       * Writes several data blocks into this stream.       * @@ -191,7 +191,7 @@ void Out(IOutputStream& out, typename TTypeTraits<T>::TFuncParam value);  #define Y_DECLARE_OUT_SPEC(MODIF, T, stream, value) \      template <>                                     \      MODIF void Out<T>(IOutputStream & stream, TTypeTraits<T>::TFuncParam value) - +   template <>  inline void Out<const char*>(IOutputStream& o, const char* t) {      if (t) { | 
