Inline some methods of BinaryReader/BinaryWriter

This commit is contained in:
Marius Kittler 2018-10-04 18:05:32 +02:00 committed by Martchus
parent a7926951cb
commit 73ddc55702
4 changed files with 36 additions and 39 deletions

View File

@ -111,17 +111,6 @@ void BinaryReader::bufferVariableLengthInteger()
*(m_buffer + (maxPrefixLength - prefixLength)) ^= mask;
}
/*!
* \brief Reads a length prefixed string from the current stream.
* \remarks Reads the length prefix from the stream and then a string of the denoted length.
* Advances the current position of the stream by the denoted length of the string plus the prefix length.
* \todo Make inline in v5.
*/
string BinaryReader::readLengthPrefixedString()
{
return readString(readVariableLengthUIntBE());
}
/*!
* \brief Reads a string from the current stream of the given \a length from the stream and advances the current position of the stream by \a length byte.
*/

View File

@ -544,6 +544,16 @@ inline bool BinaryReader::readBool()
return readByte() != 0;
}
/*!
* \brief Reads a length prefixed string from the current stream.
* \remarks Reads the length prefix from the stream and then a string of the denoted length.
* Advances the current position of the stream by the denoted length of the string plus the prefix length.
*/
inline std::string BinaryReader::readLengthPrefixedString()
{
return readString(readVariableLengthUIntBE());
}
/*!
* \brief Reads a 32-bit big endian synchsafe integer from the current stream and advances the current position of the stream by four bytes.
* \remarks Synchsafe integers appear in ID3 tags that are attached to an MP3 file.

View File

@ -89,31 +89,3 @@ void BinaryWriter::writeVariableLengthInteger(uint64 value, void (*getBytes)(uin
}
m_stream->write(m_buffer + 8 - prefixLength, prefixLength);
}
/*!
* \brief Writes the length of a string and the string itself to the current stream.
*
* Advances the current position of the stream by the length of the string plus the size of the length prefix.
*
* \throws Throws ConversionException if the string size exceeds the maximum.
* \todo Make inline in v5.
*/
void BinaryWriter::writeLengthPrefixedString(const string &value)
{
writeVariableLengthUIntBE(value.size());
m_stream->write(value.data(), static_cast<streamsize>(value.size()));
}
/*!
* \brief Writes the length of a string and the string itself to the current stream.
*
* Advances the current position of the stream by the length of the string plus the size of the length prefix.
*
* \throws Throws ConversionException if the string size exceeds the maximum.
* \todo Make inline in v5.
*/
void BinaryWriter::writeLengthPrefixedCString(const char *value, size_t size)
{
writeVariableLengthUIntBE(size);
m_stream->write(value, static_cast<streamsize>(size));
}

View File

@ -513,6 +513,32 @@ inline void BinaryWriter::writeTerminatedString(const std::string &value)
m_stream->write(value.c_str(), value.length() + 1);
}
/*!
* \brief Writes the length of a string and the string itself to the current stream.
*
* Advances the current position of the stream by the length of the string plus the size of the length prefix.
*
* \throws Throws ConversionException if the string size exceeds the maximum.
*/
inline void BinaryWriter::writeLengthPrefixedString(const std::string &value)
{
writeVariableLengthUIntBE(value.size());
m_stream->write(value.data(), static_cast<std::streamsize>(value.size()));
}
/*!
* \brief Writes the length of a string and the string itself to the current stream.
*
* Advances the current position of the stream by the length of the string plus the size of the length prefix.
*
* \throws Throws ConversionException if the string size exceeds the maximum.
*/
inline void BinaryWriter::writeLengthPrefixedCString(const char *value, std::size_t size)
{
writeVariableLengthUIntBE(size);
m_stream->write(value, static_cast<std::streamsize>(size));
}
/*!
* \brief Writes a 32-bit big endian synchsafe integer to the current stream and advances the current position of the stream by four bytes.
* \remarks Synchsafe integers appear in ID3 tags that are attached to an MP3 file.