--- a/sources/network/bytestream.h Wed Jan 27 12:41:50 2021 +0200 +++ b/sources/network/bytestream.h Wed Jan 27 19:48:41 2021 +0200 @@ -1,5 +1,5 @@ /* - Copyright 2014 - 2016 Teemu Piippo + Copyright 2014 - 2021 Teemu Piippo All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,11 +30,10 @@ #pragma once #include <stdexcept> +#include <string> #include "../main.h" BEGIN_ZFC_NAMESPACE -class String; - enum { MAX_NETWORK_STRING = 0x800 @@ -42,45 +41,45 @@ class IOError : public std::exception { - String m_message; + std::string m_message; public: - IOError(String message) : + IOError(std::string message) : m_message(message) {} const char* what() const throw() { - return m_message; + return m_message.data(); } }; class Bytestream { public: - Bytestream(ByteArray& data); + Bytestream(std::vector<unsigned char>& data); int bytesLeft() const; - ByteArray::Iterator getCurrentIterator(); + std::vector<unsigned char>::iterator getCurrentIterator(); int position() const; - ByteArray readBuffer(int length); + std::vector<unsigned char> readBuffer(int length); int8_t readByte(); int32_t readLong(); int16_t readShort(); - String readString(); + std::string readString(); float readFloat(); void rewind(); void seek(int position); void write(const unsigned char* val, unsigned int length); - void writeBuffer(const ByteArray& other); + void writeBuffer(const std::vector<unsigned char>& other); void writeByte(int8_t value); void writeDouble(double val); void writeFloat(float value); void writeLong(int32_t value); void writeShort(int16_t value); - void writeString(const String& string); + void writeString(const std::string& string); private: - ByteArray& m_data; + std::vector<unsigned char>& m_data; int m_position; int8_t read();