diff options
| author | Shauren <shauren.trinity@gmail.com> | 2014-07-27 20:59:22 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2014-07-27 20:59:22 +0200 |
| commit | 2cba07d6a1e319fec6d763daa69af3e29ba837c4 (patch) | |
| tree | 990d4a22193c066fa9aa20a7c33b4330e9a60086 /src/server/shared/Packets/ByteBuffer.h | |
| parent | 55eafa247d91e24bd59a369daa05b05d20334791 (diff) | |
| parent | e502e01f5d16964e67685c956e204ae41b756d26 (diff) | |
Merge branch 'master' of https://github.com/TrinityCore/TrinityCore into 4.3.4
Conflicts:
README.md
src/server/game/Entities/Object/Object.cpp
src/server/game/Entities/Object/Updates/UpdateData.h
src/server/game/Server/WorldPacket.h
src/server/game/Server/WorldSession.cpp
src/server/game/Server/WorldSession.h
src/server/game/Server/WorldSocket.cpp
src/server/game/Server/WorldSocket.h
src/server/shared/Packets/ByteBuffer.h
Diffstat (limited to 'src/server/shared/Packets/ByteBuffer.h')
| -rw-r--r-- | src/server/shared/Packets/ByteBuffer.h | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index ba4894fc32e..520c1a85fc2 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -32,6 +32,7 @@ #include <cstring> #include <time.h> #include <math.h> +#include <boost/asio/buffer.hpp> // Root of ByteBuffer exception hierarchy class ByteBufferException : public std::exception @@ -80,12 +81,30 @@ class ByteBuffer _storage.reserve(reserve); } - // copy constructor - ByteBuffer(const ByteBuffer &buf) : _rpos(buf._rpos), _wpos(buf._wpos), - _bitpos(buf._bitpos), _curbitval(buf._curbitval), _storage(buf._storage) + ByteBuffer(ByteBuffer&& buf) : _rpos(buf._rpos), _wpos(buf._wpos), + _bitpos(buf._bitpos), _curbitval(buf._curbitval), _storage(std::move(buf._storage)) { } + ByteBuffer(ByteBuffer const& right) : _rpos(right._rpos), _wpos(right._wpos), + _bitpos(right._bitpos), _curbitval(right._curbitval), _storage(right._storage) + { + } + + ByteBuffer& operator=(ByteBuffer const& right) + { + if (this != &right) + { + _rpos = right._rpos; + _wpos = right._wpos; + _bitpos = right._bitpos; + _curbitval = right._curbitval; + _storage = right._storage; + } + + return *this; + } + virtual ~ByteBuffer() { } void clear() @@ -510,18 +529,18 @@ class ByteBuffer return *this; } - uint8 * contents() + uint8* contents() { if (_storage.empty()) throw ByteBufferException(); - return &_storage[0]; + return _storage.data(); } - const uint8 *contents() const + uint8 const* contents() const { if (_storage.empty()) throw ByteBufferException(); - return &_storage[0]; + return _storage.data(); } size_t size() const { return _storage.size(); } @@ -737,5 +756,15 @@ inline void ByteBuffer::read_skip<std::string>() read_skip<char*>(); } -#endif +namespace boost +{ + namespace asio + { + inline const_buffers_1 buffer(ByteBuffer const& packet) + { + return buffer(packet.contents(), packet.size()); + } + } +} +#endif |
