From 38efe73154f30200fafb2631b17106bc6935ae05 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 2 Sep 2012 19:38:37 +0000 Subject: Added writing support to cByteBuffer (will be used by ProtoProxy) git-svn-id: http://mc-server.googlecode.com/svn/trunk@825 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/ByteBuffer.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source/ByteBuffer.h') diff --git a/source/ByteBuffer.h b/source/ByteBuffer.h index 68dc48cd9..c0ffed43c 100644 --- a/source/ByteBuffer.h +++ b/source/ByteBuffer.h @@ -45,6 +45,9 @@ public: /// Returns true if the specified amount of bytes are available for reading bool CanReadBytes(int a_Count) const; + /// Returns true if the specified amount of bytes are available for writing + bool CanWriteBytes(int a_Count) const; + // Read the specified datatype and advance the read pointer; return true if successfully read: bool ReadChar (char & a_Value); bool ReadByte (unsigned char & a_Value); @@ -56,13 +59,27 @@ public: bool ReadBool (bool & a_Value); bool ReadBEUTF16String16(AString & a_Value); - /// Reads a_Count bytes into a_Buffer; return true if successful + // Write the specified datatype; return true if successfully written + bool WriteChar (char a_Value); + bool WriteByte (unsigned char a_Value); + bool WriteBEShort (short a_Value); + bool WriteBEInt (int a_Value); + bool WriteBEInt64 (Int64 a_Value); + bool WriteBEFloat (float a_Value); + bool WriteBEDouble (double a_Value); + bool WriteBool (bool a_Value); + bool WriteBEUTF16String16(const AString & a_Value); + + /// Reads a_Count bytes into a_Buffer; returns true if successful bool ReadBuf(void * a_Buffer, int a_Count); - /// Reads a_Count bytes into a_String; return true if successful + /// Writes a_Count bytes into a_Buffer; returns true if successful + bool WriteBuf(const void * a_Buffer, int a_Count); + + /// Reads a_Count bytes into a_String; returns true if successful bool ReadString(AString & a_String, int a_Count); - /// Reads 2 * a_NumChars bytes and interprets it as a UTF16 string, converting it into UTF8 string a_String + /// Reads 2 * a_NumChars bytes and interprets it as a UTF16-BE string, converting it into UTF8 string a_String bool ReadUTF16String(AString & a_String, int a_NumChars); /// Skips reading by a_Count bytes; returns false if not enough bytes in the ringbuffer -- cgit v1.2.3