From 8a927419c2d55bab03fd7f260b27c84ededa27d9 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Mon, 20 Apr 2020 03:48:49 +0300 Subject: [PATCH] Return the length of the written string. Since they can be dynamically generated through a formatted string. --- module/Library/Utils/Buffer.cpp | 8 ++++++-- module/Library/Utils/Buffer.hpp | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/module/Library/Utils/Buffer.cpp b/module/Library/Utils/Buffer.cpp index 40518774..97680fa6 100644 --- a/module/Library/Utils/Buffer.cpp +++ b/module/Library/Utils/Buffer.cpp @@ -40,7 +40,7 @@ void SqBuffer::WriteUint64(const ULongInt & val) } // ------------------------------------------------------------------------------------------------ -void SqBuffer::WriteRawString(StackStrF & val) +SQInteger SqBuffer::WriteRawString(StackStrF & val) { // Validate the managed buffer reference Validate(); @@ -53,10 +53,12 @@ void SqBuffer::WriteRawString(StackStrF & val) Buffer::SzType length = ConvTo< Buffer::SzType >::From(val.mLen); // Write the the string contents m_Buffer->AppendS(val.mPtr, length); + // Return the length of the written string + return val.mLen; } // ------------------------------------------------------------------------------------------------ -void SqBuffer::WriteClientString(StackStrF & val) +SQInteger SqBuffer::WriteClientString(StackStrF & val) { // Validate the managed buffer reference Validate(); @@ -76,6 +78,8 @@ void SqBuffer::WriteClientString(StackStrF & val) // Write the size and then the string contents m_Buffer->Push< Uint16 >(size); m_Buffer->AppendS(val.mPtr, length); + // Return the length of the written string + return val.mLen; } // ------------------------------------------------------------------------------------------------ diff --git a/module/Library/Utils/Buffer.hpp b/module/Library/Utils/Buffer.hpp index 72ae9113..a0ba408e 100644 --- a/module/Library/Utils/Buffer.hpp +++ b/module/Library/Utils/Buffer.hpp @@ -583,12 +583,12 @@ public: /* -------------------------------------------------------------------------------------------- * Write a raw string to the buffer. */ - void WriteRawString(StackStrF & val); + SQInteger WriteRawString(StackStrF & val); /* -------------------------------------------------------------------------------------------- * Write a client encoded string to the buffer. */ - void WriteClientString(StackStrF & val); + SQInteger WriteClientString(StackStrF & val); /* -------------------------------------------------------------------------------------------- * Write a AABB to the buffer.