Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
ByteBuffer.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef _BYTEBUFFER_H
7#define _BYTEBUFFER_H
8
9#ifndef SF_TIMEZONE
10#if _MSC_VER >= 1900
11#define SF_TIMEZONE _timezone
12#else
13#define SF_TIMEZONE timezone
14#endif
15#endif
16
17#include "ByteConverter.h"
18#include "Define.h"
19#include "Errors.h"
20#include "Platform/TimeUtils.h"
21
22#include <cmath>
23#include <cstring>
24#include <exception>
25#include <list>
26#include <map>
27#include <string>
28#include <time.h>
29#include <array>
30#include <vector>
31
32// Root of ByteBuffer exception hierarchy
33class ByteBufferException : public std::exception
34{
35public:
37
38 char const* what() const throw() { return msg_.c_str(); }
39
40protected:
41 std::string& message() throw() { return msg_; }
42
43private:
44 std::string msg_;
45};
46
48{
49public:
50 ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize);
51
53};
54
56{
57public:
58 ByteBufferSourceException(size_t pos, size_t size, size_t valueSize);
59
61};
62
66{
67public:
68 ObjectGuid() { _data.u64 = UI64LIT(0); }
69 ObjectGuid(uint64 guid) { _data.u64 = guid; }
70 ObjectGuid(ObjectGuid const& other) { _data.u64 = other._data.u64; }
71
73 {
74 ASSERT(index < sizeof(uint64));
75
76#if SKYFIRE_ENDIAN == SKYFIRE_LITTLEENDIAN
77 return _data.byte[index];
78#else
79 return _data.byte[7 - index];
80#endif
81 }
82
83 uint8 const& operator[](uint32 index) const
84 {
85 ASSERT(index < sizeof(uint64));
86
87#if SKYFIRE_ENDIAN == SKYFIRE_LITTLEENDIAN
88 return _data.byte[index];
89#else
90 return _data.byte[7 - index];
91#endif
92 }
93
94 operator uint64()
95 {
96 return _data.u64;
97 }
98
100 {
101 _data.u64 = guid;
102 return *this;
103 }
104
106 {
107 _data.u64 = other._data.u64;
108 return *this;
109 }
110
111private:
112 union
113 {
115 uint8 byte[8];
117};
118
120{
121public:
122 const static size_t DEFAULT_SIZE = 0x1000;
123
124 // constructor
126 {
127 _storage.reserve(DEFAULT_SIZE);
128 }
129
131 {
132 _storage.reserve(reserve);
133 }
134
135 // copy constructor
136 ByteBuffer(const ByteBuffer& buf) : _rpos(buf._rpos), _wpos(buf._wpos),
138 {
139 }
140 virtual ~ByteBuffer() { }
141 void clear()
142 {
143 _storage.clear();
144 _rpos = _wpos = 0;
145 }
146
147 template <typename T> void append(T value)
148 {
149 FlushBits();
150 EndianConvert(value);
151 append((uint8*)&value, sizeof(value));
152 }
153
155 {
156 if (_bitpos == 8)
157 return;
158
159 append((uint8*)&_curbitval, sizeof(uint8));
160 _curbitval = 0;
161 _bitpos = 8;
162 }
163
164 bool WriteBit(uint32 bit)
165 {
166 --_bitpos;
167 if (bit)
168 _curbitval |= (1 << (_bitpos));
169
170 if (_bitpos == 0)
171 {
172 _bitpos = 8;
173 append((uint8*)&_curbitval, sizeof(_curbitval));
174 _curbitval = 0;
175 }
176
177 return (bit != 0);
178 }
179
180 bool ReadBit()
181 {
182 ++_bitpos;
183 if (_bitpos > 7)
184 {
185 _bitpos = 0;
187 }
188
189 return ((_curbitval >> (7 - _bitpos)) & 1) != 0;
190 }
191
192 template <typename T> void WriteBits(T value, size_t bits)
193 {
194 for (int32 i = bits - 1; i >= 0; --i)
195 WriteBit((value >> i) & 1);
196 }
197
198 uint32 ReadBits(size_t bits)
199 {
200 uint32 value = 0;
201 for (int32 i = bits - 1; i >= 0; --i)
202 if (ReadBit())
203 value |= (1 << (i));
204
205 return value;
206 }
207
208 void ReadBytesSeq(ObjectGuid& guid, uint8 order[8])
209 {
210 for (uint8 i = 0; i < 8; ++i)
211 ReadByteSeq(guid[order[i]]);
212 }
213
214 // Reads a byte (if needed) in-place
216 {
217 if (b != 0)
218 b ^= read<uint8>();
219 }
220
221 void WriteBytesSeq(ObjectGuid guid, uint8 order[8])
222 {
223 for (uint8 i = 0; i < 8; ++i)
224 WriteByteSeq(guid[order[i]]);
225 }
226
228 {
229 if (b != 0)
230 append<uint8>(b ^ 1);
231 }
232
233 template <typename T> void put(size_t pos, T value)
234 {
235 EndianConvert(value);
236 put(pos, (uint8*)&value, sizeof(value));
237 }
238
239 template <typename... Offsets>
240 void ReadGuidMask(ObjectGuid& guid, Offsets... offsets)
241 {
242 uint8 const order[] = { uint8(offsets)... };
243 for (uint8 offset : order)
244 guid[offset] = ReadBit();
245 }
246
247 template <typename... Offsets>
248 void WriteGuidMask(const ObjectGuid& guid, Offsets... offsets)
249 {
250 uint8 const order[] = { uint8(offsets)... };
251 for (uint8 offset : order)
252 WriteBit(guid[offset]);
253 }
254
255 template <typename... Offsets>
256 void ReadGuidBytes(ObjectGuid& guid, Offsets... offsets)
257 {
258 uint8 const order[] = { uint8(offsets)... };
259 for (uint8 offset : order)
260 ReadByteSeq(guid[offset]);
261 }
262
263 template <typename... Offsets>
264 void WriteGuidBytes(const ObjectGuid& guid, Offsets... offsets)
265 {
266 uint8 const order[] = { uint8(offsets)... };
267 for (uint8 offset : order)
268 WriteByteSeq(guid[offset]);
269 }
270
283 template <typename T> void PutBits(size_t pos, T value, uint32 bitCount)
284 {
285 if (!bitCount)
286 throw ByteBufferSourceException((pos + bitCount) / 8, size(), 0);
287
288 if (pos + bitCount > size() * 8)
289 throw ByteBufferPositionException(false, (pos + bitCount) / 8, size(), (bitCount - 1) / 8 + 1);
290
291 for (uint32 i = 0; i < bitCount; ++i)
292 {
293 size_t wp = (pos + i) / 8;
294 size_t bit = (pos + i) % 8;
295 if ((value >> (bitCount - i - 1)) & 1)
296 _storage[wp] |= 1 << (7 - bit);
297 else
298 _storage[wp] &= ~(1 << (7 - bit));
299 }
300 }
301
303 {
304 append<uint8>(value);
305 return *this;
306 }
307
309 {
310 append<uint16>(value);
311 return *this;
312 }
313
315 {
316 append<uint32>(value);
317 return *this;
318 }
319
321 {
322 append<uint64>(value);
323 return *this;
324 }
325
326 // signed as in 2e complement
328 {
329 append<int8>(value);
330 return *this;
331 }
332
334 {
335 append<int16>(value);
336 return *this;
337 }
338
340 {
341 append<int32>(value);
342 return *this;
343 }
344
346 {
347 append<int64>(value);
348 return *this;
349 }
350
351 // floating points
352 ByteBuffer& operator<<(float value)
353 {
354 append<float>(value);
355 return *this;
356 }
357
358 ByteBuffer& operator<<(double value)
359 {
360 append<double>(value);
361 return *this;
362 }
363
364 ByteBuffer& operator<<(const std::string& value)
365 {
366 if (size_t len = value.length())
367 append((uint8 const*)value.c_str(), len);
368 append((uint8)0);
369 return *this;
370 }
371
372 ByteBuffer& operator>>(bool& value)
373 {
374 value = read<char>() > 0 ? true : false;
375 return *this;
376 }
377
379 {
380 value = read<uint8>();
381 return *this;
382 }
383
385 {
386 value = read<uint16>();
387 return *this;
388 }
389
391 {
392 value = read<uint32>();
393 return *this;
394 }
395
397 {
398 value = read<uint64>();
399 return *this;
400 }
401
402 //signed as in 2e complement
404 {
405 value = read<int8>();
406 return *this;
407 }
408
410 {
411 value = read<int16>();
412 return *this;
413 }
414
416 {
417 value = read<int32>();
418 return *this;
419 }
420
422 {
423 value = read<int64>();
424 return *this;
425 }
426
427 ByteBuffer& operator>>(float& value)
428 {
429 value = read<float>();
430 if (!std::isfinite(value))
431 throw ByteBufferException();
432 return *this;
433 }
434
435 ByteBuffer& operator>>(double& value)
436 {
437 value = read<double>();
438 if (!std::isfinite(value))
439 throw ByteBufferException();
440 return *this;
441 }
442
443 ByteBuffer& operator>>(std::string& value)
444 {
445 value.clear();
446 while (rpos() < size()) // prevent crash at wrong string format in packet
447 {
448 char c = read<char>();
449 if (c == 0)
450 break;
451 value += c;
452 }
453 return *this;
454 }
455
456 uint8& operator[](size_t const pos)
457 {
458 if (pos >= size())
459 throw ByteBufferPositionException(false, pos, 1, size());
460 return _storage[pos];
461 }
462
463 uint8 const& operator[](size_t const pos) const
464 {
465 if (pos >= size())
466 throw ByteBufferPositionException(false, pos, 1, size());
467 return _storage[pos];
468 }
469
470 size_t rpos() const { return _rpos; }
471
472 size_t rpos(size_t rpos_)
473 {
474 _rpos = rpos_;
475 return _rpos;
476 }
477
478 void rfinish()
479 {
480 _rpos = wpos();
481 }
482
483 size_t wpos() const { return _wpos; }
484
485 size_t wpos(size_t wpos_)
486 {
487 _wpos = wpos_;
488 return _wpos;
489 }
490
492 size_t bitwpos() const { return _wpos * 8 + 8 - _bitpos; }
493
494 size_t bitwpos(size_t newPos)
495 {
496 _wpos = newPos / 8;
497 _bitpos = 8 - (newPos % 8);
498 return _wpos * 8 + 8 - _bitpos;
499 }
500
501 template<typename T>
502 void read_skip() { read_skip(sizeof(T)); }
503
504 void read_skip(size_t skip)
505 {
506 if (_rpos + skip > size())
507 throw ByteBufferPositionException(false, _rpos, skip, size());
508 _rpos += skip;
509 }
510
511 template <typename T> T read()
512 {
513 T r = read<T>(_rpos);
514 _rpos += sizeof(T);
515 return r;
516 }
517
518 template <typename T> T read(size_t pos) const
519 {
520 if (pos + sizeof(T) > size())
521 throw ByteBufferPositionException(false, pos, sizeof(T), size());
522 T val = *((T const*)&_storage[pos]);
523 EndianConvert(val);
524 return val;
525 }
526
527 void read(uint8* dest, size_t len)
528 {
529 if (_rpos + len > size())
530 throw ByteBufferPositionException(false, _rpos, len, size());
531 std::memcpy(dest, &_storage[_rpos], len);
532 _rpos += len;
533 }
534
535 template<size_t Size>
536 void read(std::array<uint8, Size>& arr)
537 {
538 read(arr.data(), Size);
539 }
540
542 {
543 if (rpos() + 1 > size())
544 throw ByteBufferPositionException(false, _rpos, 1, size());
545
546 guid = 0;
547
548 uint8 guidmark = 0;
549 (*this) >> guidmark;
550
551 for (int i = 0; i < 8; ++i)
552 {
553 if (guidmark & (uint8(1) << i))
554 {
555 if (rpos() + 1 > size())
556 throw ByteBufferPositionException(false, _rpos, 1, size());
557
558 uint8 bit;
559 (*this) >> bit;
560 guid |= (uint64(bit) << (i * 8));
561 }
562 }
563 }
564
565 std::string ReadString(size_t length)
566 {
567 if (!length)
568 return std::string();
569 char* buffer = new char[length + 1]();
570 read((uint8*)buffer, length);
571 std::string retval = buffer;
572 delete[] buffer;
573 return retval;
574 }
575
578 void WriteString(std::string const& str)
579 {
580 if (size_t len = str.length())
581 append(str.c_str(), len);
582 }
583
585 {
586 uint32 packedDate = read<uint32>();
587 tm lt = tm();
588
589 lt.tm_min = packedDate & 0x3F;
590 lt.tm_hour = (packedDate >> 6) & 0x1F;
591 //lt.tm_wday = (packedDate >> 11) & 7;
592 lt.tm_mday = ((packedDate >> 14) & 0x3F) + 1;
593 lt.tm_mon = (packedDate >> 20) & 0xF;
594 lt.tm_year = ((packedDate >> 24) & 0x1F) + 100;
595
596 return uint32(mktime(&lt) + SF_TIMEZONE);
597 }
598
600 {
601 time = ReadPackedTime();
602 return *this;
603 }
604
605 uint8* contents() { return &_storage[0]; }
606
607 const uint8* contents() const { return &_storage[0]; }
608
609 size_t size() const { return _storage.size(); }
610 bool empty() const { return _storage.empty(); }
611
612 void resize(size_t newsize)
613 {
614 _storage.resize(newsize, 0);
615 _rpos = 0;
616 _wpos = size();
617 }
618
619 void reserve(size_t ressize)
620 {
621 if (ressize > size())
622 _storage.reserve(ressize);
623 }
624
625 void append(const char* src, size_t cnt)
626 {
627 return append((const uint8*)src, cnt);
628 }
629
630 template<class T> void append(const T* src, size_t cnt)
631 {
632 return append((const uint8*)src, cnt * sizeof(T));
633 }
634
635 void append(const uint8* src, size_t cnt)
636 {
637 if (!cnt)
638 throw ByteBufferSourceException(_wpos, size(), cnt);
639
640 if (!src)
641 throw ByteBufferSourceException(_wpos, size(), cnt);
642
643 ASSERT(size() < 10000000);
644
645 if (_storage.size() < _wpos + cnt)
646 _storage.resize(_wpos + cnt);
647 std::memcpy(&_storage[_wpos], src, cnt);
648 _wpos += cnt;
649 }
650
651 void append(const ByteBuffer& buffer)
652 {
653 if (buffer.wpos())
654 append(buffer.contents(), buffer.wpos());
655 }
656
657 void AppendBits(const ByteBuffer& buffer)
658 {
659 for (uint32 i = 0; i < buffer.wpos(); ++i)
660 WriteBits(*(buffer.contents() + i), 8);
661
662 WriteBits(buffer._curbitval >> buffer._bitpos, 8 - buffer._bitpos);
663 }
664
665 template<size_t Size>
666 void append(std::array<uint8, Size> const& arr)
667 {
668 append(arr.data(), Size);
669 }
670
671 // can be used in SMSG_ON_MONSTER_MOVE opcode
672 void appendPackXYZ(float x, float y, float z)
673 {
674 uint32 packed = 0;
675 packed |= ((int)(x / 0.25f) & 0x7FF);
676 packed |= ((int)(y / 0.25f) & 0x7FF) << 11;
677 packed |= ((int)(z / 0.25f) & 0x3FF) << 22;
678 *this << packed;
679 }
680
682 {
683 uint8 packGUID[8 + 1];
684 packGUID[0] = 0;
685 size_t size = 1;
686 for (uint8 i = 0; guid != 0; ++i)
687 {
688 if (guid & 0xFF)
689 {
690 packGUID[0] |= uint8(1 << i);
691 packGUID[size] = uint8(guid & 0xFF);
692 ++size;
693 }
694
695 guid >>= 8;
696 }
697 append(packGUID, size);
698 }
699
700 void AppendPackedTime(time_t time)
701 {
702 tm lt;
703 Skyfire::LocalTime(time, lt);
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);
705 }
706
707 void put(size_t pos, const uint8* src, size_t cnt)
708 {
709 if (pos + cnt > size())
710 throw ByteBufferPositionException(true, pos, cnt, size());
711
712 if (!src)
713 throw ByteBufferSourceException(_wpos, size(), cnt);
714
715 std::memcpy(&_storage[pos], src, cnt);
716 }
717
718 void print_storage() const;
719
720 void textlike() const;
721
722 void hexlike() const;
723
724protected:
727 std::vector<uint8> _storage;
728};
729
730template <typename T>
731inline ByteBuffer& operator<<(ByteBuffer& b, std::vector<T> v)
732{
733 b << (uint32)v.size();
734 for (typename std::vector<T>::iterator i = v.begin(); i != v.end(); ++i)
735 {
736 b << *i;
737 }
738 return b;
739}
740
741template <typename T>
742inline ByteBuffer& operator>>(ByteBuffer& b, std::vector<T>& v)
743{
744 uint32 vsize;
745 b >> vsize;
746 v.clear();
747 while (vsize--)
748 {
749 T t;
750 b >> t;
751 v.push_back(t);
752 }
753 return b;
754}
755
756template <typename T>
757inline ByteBuffer& operator<<(ByteBuffer& b, std::list<T> v)
758{
759 b << (uint32)v.size();
760 for (typename std::list<T>::iterator i = v.begin(); i != v.end(); ++i)
761 {
762 b << *i;
763 }
764 return b;
765}
766
767template <typename T>
768inline ByteBuffer& operator>>(ByteBuffer& b, std::list<T>& v)
769{
770 uint32 vsize;
771 b >> vsize;
772 v.clear();
773 while (vsize--)
774 {
775 T t;
776 b >> t;
777 v.push_back(t);
778 }
779 return b;
780}
781
782template <typename K, typename V>
783inline ByteBuffer& operator<<(ByteBuffer& b, std::map<K, V>& m)
784{
785 b << (uint32)m.size();
786 for (typename std::map<K, V>::iterator i = m.begin(); i != m.end(); ++i)
787 {
788 b << i->first << i->second;
789 }
790 return b;
791}
792
793template <typename K, typename V>
794inline ByteBuffer& operator>>(ByteBuffer& b, std::map<K, V>& m)
795{
796 uint32 msize;
797 b >> msize;
798 m.clear();
799 while (msize--)
800 {
801 K k;
802 V v;
803 b >> k >> v;
804 m.insert(make_pair(k, v));
805 }
806 return b;
807}
808
810template<> inline std::string ByteBuffer::read<std::string>()
811{
812 std::string tmp;
813 *this >> tmp;
814 return tmp;
815}
816
817template<>
819{
820 std::string temp;
821 *this >> temp;
822}
823
824template<>
829
830template<>
832{
833 read_skip<char*>();
834}
835
836#endif
ByteBuffer & operator>>(ByteBuffer &b, std::vector< T > &v)
Definition ByteBuffer.h:742
ByteBuffer & operator<<(ByteBuffer &b, std::vector< T > v)
Definition ByteBuffer.h:731
#define SF_TIMEZONE
Definition ByteBuffer.h:13
void EndianConvert(T &)
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::int8_t int8
Definition Define.h:75
#define UI64LIT(N)
Definition Define.h:65
std::uint64_t uint64
Definition Define.h:76
std::int64_t int64
Definition Define.h:72
std::uint16_t uint16
Definition Define.h:78
std::int16_t int16
Definition Define.h:74
#define ASSERT
Definition Errors.h:29
std::string & message()
Definition ByteBuffer.h:41
std::string msg_
Definition ByteBuffer.h:44
char const * what() const
Definition ByteBuffer.h:38
void append(std::array< uint8, Size > const &arr)
Definition ByteBuffer.h:666
void WriteGuidBytes(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:264
size_t _wpos
Definition ByteBuffer.h:725
virtual ~ByteBuffer()
Definition ByteBuffer.h:140
void read(std::array< uint8, Size > &arr)
Definition ByteBuffer.h:536
ByteBuffer & operator<<(uint32 value)
Definition ByteBuffer.h:314
void append(const uint8 *src, size_t cnt)
Definition ByteBuffer.h:635
ByteBuffer & operator>>(int64 &value)
Definition ByteBuffer.h:421
bool WriteBit(uint32 bit)
Definition ByteBuffer.h:164
void read_skip()
Definition ByteBuffer.h:502
ByteBuffer & operator<<(double value)
Definition ByteBuffer.h:358
ByteBuffer(size_t reserve)
Definition ByteBuffer.h:130
const uint8 * contents() const
Definition ByteBuffer.h:607
void appendPackXYZ(float x, float y, float z)
Definition ByteBuffer.h:672
void put(size_t pos, T value)
Definition ByteBuffer.h:233
ByteBuffer & operator>>(uint32 &value)
Definition ByteBuffer.h:390
size_t rpos() const
Definition ByteBuffer.h:470
ByteBuffer & operator<<(uint8 value)
Definition ByteBuffer.h:302
void WriteGuidMask(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:248
size_t bitwpos() const
Returns position of last written bit.
Definition ByteBuffer.h:492
std::vector< uint8 > _storage
Definition ByteBuffer.h:727
ByteBuffer & operator<<(int32 value)
Definition ByteBuffer.h:339
void reserve(size_t ressize)
Definition ByteBuffer.h:619
void WriteString(std::string const &str)
Definition ByteBuffer.h:578
ByteBuffer & operator>>(float &value)
Definition ByteBuffer.h:427
void appendPackGUID(uint64 guid)
Definition ByteBuffer.h:681
ByteBuffer & operator<<(int64 value)
Definition ByteBuffer.h:345
T read(size_t pos) const
Definition ByteBuffer.h:518
uint32 ReadBits(size_t bits)
Definition ByteBuffer.h:198
void ReadGuidBytes(ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:256
void resize(size_t newsize)
Definition ByteBuffer.h:612
void ReadByteSeq(uint8 &b)
Definition ByteBuffer.h:215
void hexlike() const
ByteBuffer & operator>>(int16 &value)
Definition ByteBuffer.h:409
void print_storage() const
void read_skip(size_t skip)
Definition ByteBuffer.h:504
ByteBuffer & operator>>(uint8 &value)
Definition ByteBuffer.h:378
void append(const ByteBuffer &buffer)
Definition ByteBuffer.h:651
void append(T value)
Definition ByteBuffer.h:147
ByteBuffer & operator<<(float value)
Definition ByteBuffer.h:352
void append(const T *src, size_t cnt)
Definition ByteBuffer.h:630
ByteBuffer & operator>>(int8 &value)
Definition ByteBuffer.h:403
ByteBuffer & operator>>(uint16 &value)
Definition ByteBuffer.h:384
void rfinish()
Definition ByteBuffer.h:478
void put(size_t pos, const uint8 *src, size_t cnt)
Definition ByteBuffer.h:707
ByteBuffer(const ByteBuffer &buf)
Definition ByteBuffer.h:136
uint8 & operator[](size_t const pos)
Definition ByteBuffer.h:456
uint8 const & operator[](size_t const pos) const
Definition ByteBuffer.h:463
std::string ReadString(size_t length)
Definition ByteBuffer.h:565
void ReadBytesSeq(ObjectGuid &guid, uint8 order[8])
Definition ByteBuffer.h:208
void PutBits(size_t pos, T value, uint32 bitCount)
Definition ByteBuffer.h:283
ByteBuffer & operator<<(uint16 value)
Definition ByteBuffer.h:308
size_t wpos() const
Definition ByteBuffer.h:483
ByteBuffer & operator<<(const std::string &value)
Definition ByteBuffer.h:364
ByteBuffer & ReadPackedTime(uint32 &time)
Definition ByteBuffer.h:599
void ReadGuidMask(ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:240
static const size_t DEFAULT_SIZE
Definition ByteBuffer.h:122
void WriteBytesSeq(ObjectGuid guid, uint8 order[8])
Definition ByteBuffer.h:221
size_t _bitpos
Definition ByteBuffer.h:725
uint8 _curbitval
Definition ByteBuffer.h:726
ByteBuffer & operator>>(std::string &value)
Definition ByteBuffer.h:443
void textlike() const
void AppendBits(const ByteBuffer &buffer)
Definition ByteBuffer.h:657
void WriteBits(T value, size_t bits)
Definition ByteBuffer.h:192
size_t rpos(size_t rpos_)
Definition ByteBuffer.h:472
void AppendPackedTime(time_t time)
Definition ByteBuffer.h:700
ByteBuffer & operator>>(int32 &value)
Definition ByteBuffer.h:415
void clear()
Definition ByteBuffer.h:141
ByteBuffer & operator<<(uint64 value)
Definition ByteBuffer.h:320
ByteBuffer & operator<<(int16 value)
Definition ByteBuffer.h:333
size_t size() const
Definition ByteBuffer.h:609
bool empty() const
Definition ByteBuffer.h:610
void WriteByteSeq(uint8 b)
Definition ByteBuffer.h:227
void FlushBits()
Definition ByteBuffer.h:154
size_t _rpos
Definition ByteBuffer.h:725
size_t bitwpos(size_t newPos)
Definition ByteBuffer.h:494
void readPackGUID(uint64 &guid)
Definition ByteBuffer.h:541
size_t wpos(size_t wpos_)
Definition ByteBuffer.h:485
ByteBuffer & operator<<(int8 value)
Definition ByteBuffer.h:327
void append(const char *src, size_t cnt)
Definition ByteBuffer.h:625
ByteBuffer & operator>>(bool &value)
Definition ByteBuffer.h:372
ByteBuffer & operator>>(double &value)
Definition ByteBuffer.h:435
uint8 * contents()
Definition ByteBuffer.h:605
uint32 ReadPackedTime()
Definition ByteBuffer.h:584
ByteBuffer & operator>>(uint64 &value)
Definition ByteBuffer.h:396
bool ReadBit()
Definition ByteBuffer.h:180
void read(uint8 *dest, size_t len)
Definition ByteBuffer.h:527
ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize)
ByteBufferSourceException(size_t pos, size_t size, size_t valueSize)
bool LocalTime(time_t const &time, tm &result)
Definition TimeUtils.h:57
uint64 u64
Definition ByteBuffer.h:114
ObjectGuid(uint64 guid)
Definition ByteBuffer.h:69
ObjectGuid & operator=(ObjectGuid const &other)
Definition ByteBuffer.h:105
ObjectGuid & operator=(uint64 guid)
Definition ByteBuffer.h:99
ObjectGuid(ObjectGuid const &other)
Definition ByteBuffer.h:70
uint8 & operator[](uint32 index)
Definition ByteBuffer.h:72
uint8 const & operator[](uint32 index) const
Definition ByteBuffer.h:83
union ObjectGuid::@026022062372240275160155022275205260116372055170 _data