Fri, 22 Jul 2016 17:52:23 +0300
Added the ByteArray typedef for Vector<unsigned char>
--- a/sources/list.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/list.h Fri Jul 22 17:52:23 2016 +0300 @@ -399,4 +399,6 @@ } }; +typedef Vector<unsigned char> ByteArray; + END_ZFC_NAMESPACE
--- a/sources/mystring.cpp Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/mystring.cpp Fri Jul 22 17:52:23 2016 +0300 @@ -565,7 +565,7 @@ * \param bytes Bytes to use for construction * \returns the resulting string. */ -String String::fromBytes(const Vector<unsigned char>& bytes) +String String::fromBytes(const ByteArray& bytes) { return String(reinterpret_cast<const Vector<char>&>(bytes)); }
--- a/sources/mystring.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/mystring.h Fri Jul 22 17:52:23 2016 +0300 @@ -108,7 +108,7 @@ static String fromNumber(unsigned int a); static String fromNumber(unsigned long int a); static String fromNumber(double a); - static String fromBytes(const Vector<unsigned char>& bytes); + static String fromBytes(const ByteArray& bytes); String operator+(const String& data) const; String operator+(const char* data) const;
--- a/sources/network/bytestream.cpp Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/bytestream.cpp Fri Jul 22 17:52:23 2016 +0300 @@ -36,7 +36,7 @@ * \brief Constructs a byte cursor. The cursor is placed to the beginning of the stream. * \param data */ -Bytestream::Bytestream(Vector<unsigned char>& data) : +Bytestream::Bytestream(ByteArray& data) : m_data(data), m_position(0) {} @@ -66,7 +66,7 @@ /*! * \returns an iterator to the current data position. */ -Vector<unsigned char>::Iterator Bytestream::getCurrentIterator() +ByteArray::Iterator Bytestream::getCurrentIterator() { return m_data.begin() + m_position; } @@ -129,7 +129,7 @@ */ String Bytestream::readString() { - Vector<unsigned char>::Iterator stringEndIterator; + ByteArray::Iterator stringEndIterator; // Where's the end of the string? for (stringEndIterator = getCurrentIterator(); *stringEndIterator != '\0'; ++stringEndIterator) @@ -158,10 +158,10 @@ * \param length Amount of bytes to read. * \returns the read buffer. */ -Vector<unsigned char> Bytestream::readBuffer(int length) +ByteArray Bytestream::readBuffer(int length) { ensureReadSpace(length); - Vector<unsigned char> result(length); + ByteArray result(length); memcpy(result.data(), m_data.data() + m_position, length); m_position += length; return result;
--- a/sources/network/bytestream.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/bytestream.h Fri Jul 22 17:52:23 2016 +0300 @@ -57,12 +57,12 @@ class Bytestream { public: - Bytestream(Vector<unsigned char>& data); + Bytestream(ByteArray& data); int bytesLeft() const; - Vector<unsigned char>::Iterator getCurrentIterator(); + ByteArray::Iterator getCurrentIterator(); int position() const; - Vector<unsigned char> readBuffer(int length); + ByteArray readBuffer(int length); int8_t readByte(); int32_t readLong(); int16_t readShort(); @@ -71,7 +71,7 @@ void rewind(); void seek(int position); void write(const unsigned char* val, unsigned int length); - void writeBuffer(const Vector<unsigned char>& other); + void writeBuffer(const ByteArray& other); void writeByte(int8_t value); void writeDouble(double val); void writeFloat(float value); @@ -80,7 +80,7 @@ void writeString(const String& string); private: - Vector<unsigned char>& m_data; + ByteArray& m_data; int m_position; int8_t read();
--- a/sources/network/rconsession.cpp Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/rconsession.cpp Fri Jul 22 17:52:23 2016 +0300 @@ -79,7 +79,7 @@ // ------------------------------------------------------------------------------------------------- // -void RCONSession::send(const Vector<unsigned char>& packet) +void RCONSession::send(const ByteArray& packet) { m_socket.send(m_address, packet); } @@ -283,7 +283,7 @@ void RCONSession::sendPassword() { m_interface->print("Authenticating...\n"); - Vector<unsigned char> message; + ByteArray message; Bytestream stream(message); stream.writeByte(CLRC_PASSWORD); stream.writeString((m_salt + m_password).md5()); @@ -322,7 +322,7 @@ if (m_state != RCON_CONNECTED or commandString.isEmpty()) return false; - Vector<unsigned char> message; + ByteArray message; Bytestream stream(message); stream.writeByte(CLRC_COMMAND); stream.writeString(commandString); @@ -365,7 +365,7 @@ { if (m_serverProtocol >= 4) { - Vector<unsigned char> message; + ByteArray message; Bytestream stream(message); stream.writeByte(CLRC_TABCOMPLETE); stream.writeString(part);
--- a/sources/network/rconsession.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/rconsession.h Fri Jul 22 17:52:23 2016 +0300 @@ -107,7 +107,7 @@ bool isActive() const; void processServerUpdates(Bytestream& packet); void requestTabCompletion(const String& part); - void send(const Vector<unsigned char>& packet); + void send(const ByteArray& packet); bool sendCommand(const String& commandString); void sendHello(); void sendPassword();
--- a/sources/network/udpsocket.cpp Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/udpsocket.cpp Fri Jul 22 17:52:23 2016 +0300 @@ -135,13 +135,13 @@ decodedPacket, length, &decodedLength); datagram.address.host = ntohl (claddr.sin_addr.s_addr); datagram.address.port = ntohs (claddr.sin_port); - datagram.message = Vector<unsigned char>(decodedPacket, decodedLength); + datagram.message = ByteArray(decodedPacket, decodedLength); return true; } // ------------------------------------------------------------------------------------------------- // -bool UDPSocket::send (const IPAddress& address, const Vector<unsigned char>& data) +bool UDPSocket::send (const IPAddress& address, const ByteArray& data) { int encodedlength = sizeof HuffmanBuffer; HUFFMAN_Encode (data.data(), reinterpret_cast<unsigned char*> (HuffmanBuffer), data.size(), &encodedlength);
--- a/sources/network/udpsocket.h Fri Jul 22 17:50:00 2016 +0300 +++ b/sources/network/udpsocket.h Fri Jul 22 17:52:23 2016 +0300 @@ -38,7 +38,7 @@ struct Datagram { - Vector<unsigned char> message; + ByteArray message; IPAddress address; }; @@ -52,7 +52,7 @@ bool bind (unsigned short port); bool read (Datagram& datagram); - bool send (const IPAddress& address, const Vector<unsigned char>& data); + bool send (const IPAddress& address, const ByteArray& data); bool set_blocking (bool a); const String& error_string() const { return m_error; } int file_descriptor() const { return m_socket; }