11#define SF_TIMEZONE _timezone
13#define SF_TIMEZONE timezone
38 char const*
what()
const throw() {
return msg_.c_str(); }
76#if SKYFIRE_ENDIAN == SKYFIRE_LITTLEENDIAN
77 return _data.byte[index];
79 return _data.byte[7 - index];
87#if SKYFIRE_ENDIAN == SKYFIRE_LITTLEENDIAN
88 return _data.byte[index];
90 return _data.byte[7 - index];
147 template <
typename T>
void append(T value)
192 template <
typename T>
void WriteBits(T value,
size_t bits)
194 for (
int32 i = bits - 1; i >= 0; --i)
201 for (
int32 i = bits - 1; i >= 0; --i)
210 for (
uint8 i = 0; i < 8; ++i)
223 for (
uint8 i = 0; i < 8; ++i)
233 template <
typename T>
void put(
size_t pos, T value)
236 put(pos, (
uint8*)&value,
sizeof(value));
239 template <
typename... Offsets>
243 for (
uint8 offset : order)
247 template <
typename... Offsets>
251 for (
uint8 offset : order)
255 template <
typename... Offsets>
259 for (
uint8 offset : order)
263 template <
typename... Offsets>
267 for (
uint8 offset : order)
288 if (pos + bitCount >
size() * 8)
291 for (
uint32 i = 0; i < bitCount; ++i)
293 size_t wp = (pos + i) / 8;
294 size_t bit = (pos + i) % 8;
295 if ((value >> (bitCount - i - 1)) & 1)
366 if (
size_t len = value.length())
430 if (!std::isfinite(value))
438 if (!std::isfinite(value))
518 template <
typename T> T
read(
size_t pos)
const
520 if (pos +
sizeof(T) >
size())
522 T val = *((T
const*)&
_storage[pos]);
535 template<
size_t Size>
536 void read(std::array<uint8, Size>& arr)
538 read(arr.data(), Size);
551 for (
int i = 0; i < 8; ++i)
553 if (guidmark & (
uint8(1) << i))
560 guid |= (
uint64(bit) << (i * 8));
568 return std::string();
569 char* buffer =
new char[length + 1]();
571 std::string retval = buffer;
580 if (
size_t len = str.length())
589 lt.tm_min = packedDate & 0x3F;
590 lt.tm_hour = (packedDate >> 6) & 0x1F;
592 lt.tm_mday = ((packedDate >> 14) & 0x3F) + 1;
593 lt.tm_mon = (packedDate >> 20) & 0xF;
594 lt.tm_year = ((packedDate >> 24) & 0x1F) + 100;
621 if (ressize >
size())
630 template<
class T>
void append(
const T* src,
size_t cnt)
665 template<
size_t Size>
666 void append(std::array<uint8, Size>
const& arr)
675 packed |= ((int)(x / 0.25f) & 0x7FF);
676 packed |= ((int)(y / 0.25f) & 0x7FF) << 11;
677 packed |= ((int)(z / 0.25f) & 0x3FF) << 22;
683 uint8 packGUID[8 + 1];
686 for (
uint8 i = 0; guid != 0; ++i)
690 packGUID[0] |=
uint8(1 << i);
704 append<uint32>((lt.tm_year - 100) << 24 | lt.tm_mon << 20 | (lt.tm_mday - 1) << 14 | lt.tm_wday << 11 | lt.tm_hour << 6 | lt.tm_min);
709 if (pos + cnt >
size())
715 std::memcpy(&
_storage[pos], src, cnt);
734 for (
typename std::vector<T>::iterator i = v.begin(); i != v.end(); ++i)
760 for (
typename std::list<T>::iterator i = v.begin(); i != v.end(); ++i)
782template <
typename K,
typename V>
786 for (
typename std::map<K, V>::iterator i = m.begin(); i != m.end(); ++i)
788 b << i->first << i->second;
793template <
typename K,
typename V>
804 m.insert(make_pair(k, v));
ByteBuffer & operator>>(ByteBuffer &b, std::vector< T > &v)
ByteBuffer & operator<<(ByteBuffer &b, std::vector< T > v)
char const * what() const
void append(std::array< uint8, Size > const &arr)
void WriteGuidBytes(const ObjectGuid &guid, Offsets... offsets)
void read(std::array< uint8, Size > &arr)
ByteBuffer & operator<<(uint32 value)
void append(const uint8 *src, size_t cnt)
ByteBuffer & operator>>(int64 &value)
bool WriteBit(uint32 bit)
ByteBuffer & operator<<(double value)
ByteBuffer(size_t reserve)
const uint8 * contents() const
void appendPackXYZ(float x, float y, float z)
void put(size_t pos, T value)
ByteBuffer & operator>>(uint32 &value)
ByteBuffer & operator<<(uint8 value)
void WriteGuidMask(const ObjectGuid &guid, Offsets... offsets)
size_t bitwpos() const
Returns position of last written bit.
std::vector< uint8 > _storage
ByteBuffer & operator<<(int32 value)
void reserve(size_t ressize)
void WriteString(std::string const &str)
ByteBuffer & operator>>(float &value)
void appendPackGUID(uint64 guid)
ByteBuffer & operator<<(int64 value)
uint32 ReadBits(size_t bits)
void ReadGuidBytes(ObjectGuid &guid, Offsets... offsets)
void resize(size_t newsize)
void ReadByteSeq(uint8 &b)
ByteBuffer & operator>>(int16 &value)
void print_storage() const
void read_skip(size_t skip)
ByteBuffer & operator>>(uint8 &value)
void append(const ByteBuffer &buffer)
ByteBuffer & operator<<(float value)
void append(const T *src, size_t cnt)
ByteBuffer & operator>>(int8 &value)
ByteBuffer & operator>>(uint16 &value)
void put(size_t pos, const uint8 *src, size_t cnt)
ByteBuffer(const ByteBuffer &buf)
uint8 & operator[](size_t const pos)
uint8 const & operator[](size_t const pos) const
std::string ReadString(size_t length)
void ReadBytesSeq(ObjectGuid &guid, uint8 order[8])
void PutBits(size_t pos, T value, uint32 bitCount)
ByteBuffer & operator<<(uint16 value)
ByteBuffer & operator<<(const std::string &value)
ByteBuffer & ReadPackedTime(uint32 &time)
void ReadGuidMask(ObjectGuid &guid, Offsets... offsets)
static const size_t DEFAULT_SIZE
void WriteBytesSeq(ObjectGuid guid, uint8 order[8])
ByteBuffer & operator>>(std::string &value)
void AppendBits(const ByteBuffer &buffer)
void WriteBits(T value, size_t bits)
size_t rpos(size_t rpos_)
void AppendPackedTime(time_t time)
ByteBuffer & operator>>(int32 &value)
ByteBuffer & operator<<(uint64 value)
ByteBuffer & operator<<(int16 value)
void WriteByteSeq(uint8 b)
size_t bitwpos(size_t newPos)
void readPackGUID(uint64 &guid)
size_t wpos(size_t wpos_)
ByteBuffer & operator<<(int8 value)
void append(const char *src, size_t cnt)
ByteBuffer & operator>>(bool &value)
ByteBuffer & operator>>(double &value)
ByteBuffer & operator>>(uint64 &value)
void read(uint8 *dest, size_t len)
~ByteBufferPositionException()
ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize)
~ByteBufferSourceException()
ByteBufferSourceException(size_t pos, size_t size, size_t valueSize)
bool LocalTime(time_t const &time, tm &result)
ObjectGuid & operator=(ObjectGuid const &other)
ObjectGuid & operator=(uint64 guid)
ObjectGuid(ObjectGuid const &other)
uint8 & operator[](uint32 index)
uint8 const & operator[](uint32 index) const
union ObjectGuid::@026022062372240275160155022275205260116372055170 _data