@@ -163,7 +163,7 @@ uint32_t ReadOnlyBinaryStream::getUnsignedVarInt() noexcept {
163163 }
164164
165165 byte = static_cast <uint8_t >(mBufferView [mReadPointer ++]);
166- value |= (byte & 0x7F ) << shift;
166+ value |= static_cast < uint32_t > (byte & 0x7F ) << shift;
167167 shift += 7 ;
168168
169169 } while (byte & 0x80 );
@@ -218,17 +218,17 @@ int32_t ReadOnlyBinaryStream::getSignedBigEndianInt() noexcept {
218218
219219void ReadOnlyBinaryStream::getString (std::string& outString) {
220220 uint32_t length = getUnsignedVarInt ();
221- getRawBytes (outString, length);
221+ getRawBytes (outString, static_cast < size_t >( length) );
222222}
223223
224224void ReadOnlyBinaryStream::getShortString (std::string& outString) {
225225 short length = getSignedShort ();
226- getRawBytes (outString, length);
226+ getRawBytes (outString, static_cast < size_t >( length) );
227227}
228228
229229void ReadOnlyBinaryStream::getLongString (std::string& outString) {
230230 int length = getSignedInt ();
231- getRawBytes (outString, length);
231+ getRawBytes (outString, static_cast < size_t >( length) );
232232}
233233
234234std::string ReadOnlyBinaryStream::getString () {
@@ -249,14 +249,35 @@ std::string ReadOnlyBinaryStream::getLongString() {
249249 return result;
250250}
251251
252+ std::string_view ReadOnlyBinaryStream::getStringView () {
253+ auto length = static_cast <size_t >(getUnsignedVarInt ());
254+ auto result = mBufferView .substr (mReadPointer , length);
255+ mReadPointer += length;
256+ return result;
257+ }
258+
259+ std::string_view ReadOnlyBinaryStream::getShortStringView () {
260+ auto length = static_cast <size_t >(getSignedShort ());
261+ auto result = mBufferView .substr (mReadPointer , length);
262+ mReadPointer += length;
263+ return result;
264+ }
265+
266+ std::string_view ReadOnlyBinaryStream::getLongStringView () {
267+ auto length = static_cast <size_t >(getSignedInt ());
268+ auto result = mBufferView .substr (mReadPointer , length);
269+ mReadPointer += length;
270+ return result;
271+ }
272+
252273uint32_t ReadOnlyBinaryStream::getUnsignedInt24 () noexcept {
253274 if (mReadPointer + 3 > mBufferView .size ()) {
254275 mHasOverflowed = true ;
255276 return 0 ;
256277 }
257278 uint32_t value = 0 ;
258279 if (mBigEndian ) {
259- value = static_cast <uint8_t >(mBufferView [mReadPointer ++]) << 16 ;
280+ value = static_cast <uint32_t >( static_cast < uint8_t >(mBufferView [mReadPointer ++]) << 16 ) ;
260281 value |= static_cast <uint32_t >(static_cast <uint8_t >(mBufferView [mReadPointer ++])) << 8 ;
261282 value |= static_cast <uint32_t >(static_cast <uint8_t >(mBufferView [mReadPointer ++]));
262283 } else {
0 commit comments