From eeb63b8901a9c049f1bb594abb9ce9b4a9c47620 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 11 Jan 2021 16:39:43 +0000 Subject: zlib -> libdeflate (#5085) + Use libdeflate + Use std::byte * Fix passing temporary to string_view + Emulate make_unique_for_overwrite --- src/ByteBuffer.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ByteBuffer.h') diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h index 1116de08c..cbf215f38 100644 --- a/src/ByteBuffer.h +++ b/src/ByteBuffer.h @@ -11,6 +11,8 @@ + + // fwd: class cUUID; @@ -87,6 +89,7 @@ public: // Write the specified datatype; return true if successfully written bool WriteBEInt8 (Int8 a_Value); + bool WriteBEInt8 (std::byte a_Value); bool WriteBEInt16 (Int16 a_Value); bool WriteBEInt32 (Int32 a_Value); bool WriteBEInt64 (Int64 a_Value); @@ -111,13 +114,13 @@ public: bool WriteBuf(const void * a_Buffer, size_t a_Count); /** Reads a_Count bytes into a_String; returns true if successful */ - bool ReadString(AString & a_String, size_t a_Count); + bool ReadSome(ContiguousByteBuffer & a_String, size_t a_Count); /** Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer */ bool SkipRead(size_t a_Count); /** Reads all available data into a_Data */ - void ReadAll(AString & a_Data); + void ReadAll(ContiguousByteBuffer & a_Data); /** Reads the specified number of bytes and writes it into the destinatio bytebuffer. Returns true on success. */ bool ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes); @@ -129,7 +132,7 @@ public: void ResetRead(void); /** Re-reads the data that has been read since the last commit to the current readpos. Used by ProtoProxy to duplicate communication */ - void ReadAgain(AString & a_Out); + void ReadAgain(ContiguousByteBuffer & a_Out); /** Checks if the internal state is valid (read and write positions in the correct bounds) using ASSERTs */ void CheckValid(void) const; @@ -138,7 +141,8 @@ public: static size_t GetVarIntSize(UInt32 a_Value); protected: - char * m_Buffer; + + std::byte * m_Buffer; size_t m_BufferSize; // Total size of the ringbuffer size_t m_DataStart; // Where the data starts in the ringbuffer @@ -154,7 +158,3 @@ protected: /** Advances the m_ReadPos by a_Count bytes */ void AdvanceReadPos(size_t a_Count); } ; - - - - -- cgit v1.2.3