Core/Packets: moved chat packet building function to packet builder class

This commit is contained in:
joschiwald
2014-12-23 00:06:36 +01:00
parent bf8eff8545
commit 6c6e4d4328
27 changed files with 249 additions and 232 deletions

View File

@@ -26,8 +26,7 @@ ByteBuffer::ByteBuffer(MessageBuffer&& buffer) : _rpos(0), _wpos(0), _bitpos(Ini
{
}
ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos,
size_t size, size_t valueSize)
ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize)
{
std::ostringstream ss;
@@ -38,8 +37,7 @@ ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos,
message().assign(ss.str());
}
ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size,
size_t valueSize)
ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size, size_t valueSize)
{
std::ostringstream ss;

View File

@@ -86,13 +86,22 @@ class ByteBuffer
}
ByteBuffer(ByteBuffer&& buf) : _rpos(buf._rpos), _wpos(buf._wpos),
_bitpos(buf._bitpos), _curbitval(buf._curbitval), _storage(std::move(buf._storage)) { }
_bitpos(buf._bitpos), _curbitval(buf._curbitval), _storage(buf.Move()) { }
ByteBuffer(ByteBuffer const& right) : _rpos(right._rpos), _wpos(right._wpos),
_bitpos(right._bitpos), _curbitval(right._curbitval), _storage(right._storage) { }
ByteBuffer(MessageBuffer&& buffer);
std::vector<uint8>&& Move()
{
_rpos = 0;
_wpos = 0;
_bitpos = InitialBitPos;
_curbitval = 0;
return std::move(_storage);
}
ByteBuffer& operator=(ByteBuffer const& right)
{
if (this != &right)
@@ -107,12 +116,29 @@ class ByteBuffer
return *this;
}
ByteBuffer& operator=(ByteBuffer&& right)
{
if (this != &right)
{
_rpos = right._rpos;
_wpos = right._wpos;
_bitpos = right._bitpos;
_curbitval = right._curbitval;
_storage = right.Move();
}
return *this;
}
virtual ~ByteBuffer() { }
void clear()
{
_rpos = 0;
_wpos = 0;
_bitpos = InitialBitPos;
_curbitval = 0;
_storage.clear();
_rpos = _wpos = 0;
}
template <typename T> void append(T value)