190:90bf9049e5eb | 191:2e6cbacafdc7 |
---|---|
34 | 34 |
35 /*! | 35 /*! |
36 * \brief Constructs a byte cursor. The cursor is placed to the beginning of the stream. | 36 * \brief Constructs a byte cursor. The cursor is placed to the beginning of the stream. |
37 * \param data | 37 * \param data |
38 */ | 38 */ |
39 Bytestream::Bytestream(ByteArray& data) : | 39 Bytestream::Bytestream(std::vector<unsigned char>& data) : |
40 m_data(data), | 40 m_data(data), |
41 m_position(0) {} | 41 m_position(0) {} |
42 | 42 |
43 /*! | 43 /*! |
44 * \brief Ensures that the specified amount of bytes can be read. Raises IOError if this is not the case. | 44 * \brief Ensures that the specified amount of bytes can be read. Raises IOError if this is not the case. |
64 } | 64 } |
65 | 65 |
66 /*! | 66 /*! |
67 * \returns an iterator to the current data position. | 67 * \returns an iterator to the current data position. |
68 */ | 68 */ |
69 ByteArray::iterator Bytestream::getCurrentIterator() | 69 std::vector<unsigned char>::iterator Bytestream::getCurrentIterator() |
70 { | 70 { |
71 return m_data.begin() + m_position; | 71 return m_data.begin() + m_position; |
72 } | 72 } |
73 | 73 |
74 /*! | 74 /*! |
143 /*! | 143 /*! |
144 * \brief Reads in a buffer of the specified length. | 144 * \brief Reads in a buffer of the specified length. |
145 * \param length Amount of bytes to read. | 145 * \param length Amount of bytes to read. |
146 * \returns the read buffer. | 146 * \returns the read buffer. |
147 */ | 147 */ |
148 ByteArray Bytestream::readBuffer(int length) | 148 std::vector<unsigned char> Bytestream::readBuffer(int length) |
149 { | 149 { |
150 ensureReadSpace(length); | 150 ensureReadSpace(length); |
151 ByteArray result(length); | 151 std::vector<unsigned char> result(length); |
152 memcpy(result.data(), m_data.data() + m_position, length); | 152 memcpy(result.data(), m_data.data() + m_position, length); |
153 m_position += length; | 153 m_position += length; |
154 return result; | 154 return result; |
155 } | 155 } |
156 | 156 |