diff options
Diffstat (limited to 'src/shared/ByteBuffer.h')
-rw-r--r-- | src/shared/ByteBuffer.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index fb2d7cfc7b9..801270fa711 100644 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -228,6 +228,12 @@ class ByteBuffer _rpos += sizeof(T); return r; }; + template<> std::string read<std::string>() + { + std::string tmp; + *this >> tmp; + return tmp; + } template <typename T> T read(size_t pos) const { ASSERT(pos + sizeof(T) <= size() || PrintPosError(false,pos,sizeof(T))); @@ -243,6 +249,32 @@ class ByteBuffer _rpos += len; } + bool readPackGUID(uint64& guid) + { + if(rpos()+1 > size()) + return false; + + guid = 0; + + uint8 guidmark=0; + (*this) >> guidmark; + + for(int i=0;i<8;i++) + { + if(guidmark & (uint8(1) << i)) + { + if(rpos()+1 > size()) + return false; + + uint8 bit; + (*this) >> bit; + guid |= (uint64(bit) << (i*8)); + } + } + + return true; + } + const uint8 *contents() const { return &_storage[0]; } size_t size() const { return _storage.size(); } |