refactor DataBuffer
All checks were successful
Linux arm64 / Build (push) Successful in 16s

This commit is contained in:
2025-08-01 12:44:05 +02:00
parent c5b3281be7
commit b8dafa4eb1
8 changed files with 301 additions and 273 deletions

View File

@@ -61,29 +61,6 @@ class DataBuffer {
std::memcpy(&m_Buffer[end_pos], &a_Data, size);
}
/**
* \brief Append data to the buffer (converted to big endian)
*/
template <typename T>
DataBuffer& operator<<(T a_Data) {
SwapBytes(a_Data);
Append(a_Data);
return *this;
}
/**
* \brief Append a string to the buffer
* \warning Don't use it for binary data !
* \param str The string to append
*/
DataBuffer& operator<<(const std::string& str);
/**
* \brief Append data to the buffer from another const buffer
* \param data The buffer to append
*/
DataBuffer& operator<<(const DataBuffer& data);
/**
* \brief Read data into a_Data
* \warning No endian checks
@@ -95,29 +72,6 @@ class DataBuffer {
m_ReadOffset += sizeof(T);
}
/**
* \brief Read some data from the buffer and assign to desired variable
*/
template <typename T>
DataBuffer& operator>>(T& a_Data) {
Read(a_Data);
SwapBytes(a_Data);
return *this;
}
/**
* \brief Read some data from the buffer and assign to the new buffer
* \param data The buffer to assign
*/
DataBuffer& operator>>(DataBuffer& data);
/**
* \brief Read a string from the buffer
* \param str The string to assign in the new buffer
* \warning Don't use it for binary data !
*/
DataBuffer& operator>>(std::string& str);
/**
* \brief Write some data to the buffer
* \param buffer The buffer to write
@@ -169,7 +123,6 @@ class DataBuffer {
m_Buffer.reserve(amount);
}
/**
* \brief Clear the buffer
*/
@@ -251,6 +204,8 @@ class DataBuffer {
return m_Buffer == other.m_Buffer;
}
void insert(iterator a_DestBegin, const_iterator a_SrcBegin, const_iterator a_SrcEnd);
iterator begin();
iterator end();
const_iterator begin() const;
@@ -258,10 +213,9 @@ class DataBuffer {
};
/**
* \brief Operator << to write a DataBuffer to an ostream
* \brief Append data to the buffer from another const buffer
* \param data The buffer to append
*/
std::ostream& operator<<(std::ostream& os, const DataBuffer& buffer);
DataBuffer& operator<<(DataBuffer& a_Buffer, const DataBuffer& data);
} // namespace sp
#include "DataBuffer.inl"