sources/network/bytestream.h

changeset 191
2e6cbacafdc7
parent 190
90bf9049e5eb
equal deleted inserted replaced
190:90bf9049e5eb 191:2e6cbacafdc7
54 }; 54 };
55 55
56 class Bytestream 56 class Bytestream
57 { 57 {
58 public: 58 public:
59 Bytestream(ByteArray& data); 59 Bytestream(std::vector<unsigned char>& data);
60 60
61 int bytesLeft() const; 61 int bytesLeft() const;
62 ByteArray::iterator getCurrentIterator(); 62 std::vector<unsigned char>::iterator getCurrentIterator();
63 int position() const; 63 int position() const;
64 ByteArray readBuffer(int length); 64 std::vector<unsigned char> readBuffer(int length);
65 int8_t readByte(); 65 int8_t readByte();
66 int32_t readLong(); 66 int32_t readLong();
67 int16_t readShort(); 67 int16_t readShort();
68 std::string readString(); 68 std::string readString();
69 float readFloat(); 69 float readFloat();
70 void rewind(); 70 void rewind();
71 void seek(int position); 71 void seek(int position);
72 void write(const unsigned char* val, unsigned int length); 72 void write(const unsigned char* val, unsigned int length);
73 void writeBuffer(const ByteArray& other); 73 void writeBuffer(const std::vector<unsigned char>& other);
74 void writeByte(int8_t value); 74 void writeByte(int8_t value);
75 void writeDouble(double val); 75 void writeDouble(double val);
76 void writeFloat(float value); 76 void writeFloat(float value);
77 void writeLong(int32_t value); 77 void writeLong(int32_t value);
78 void writeShort(int16_t value); 78 void writeShort(int16_t value);
79 void writeString(const std::string& string); 79 void writeString(const std::string& string);
80 80
81 private: 81 private:
82 ByteArray& m_data; 82 std::vector<unsigned char>& m_data;
83 int m_position; 83 int m_position;
84 84
85 int8_t read(); 85 int8_t read();
86 void ensureReadSpace(int bytes); 86 void ensureReadSpace(int bytes);
87 }; 87 };

mercurial