diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2020-08-28 00:11:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-28 00:11:16 +0200 |
| commit | 534a2388b7c662c8796aabb1ec8cb424879799b6 (patch) | |
| tree | df01a59b06bbb376dfeb95f2d538ab43b082e20d /src/server/shared/Packets | |
| parent | 7478c2c65aea853a2086c9c7ecc56c14ad6ee338 (diff) | |
Core/Common: Tokenizer -> Trinity::Tokenize (PR: #25327)
Diffstat (limited to 'src/server/shared/Packets')
| -rw-r--r-- | src/server/shared/Packets/ByteBuffer.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 149545d10d6..50c3c6a24f5 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -203,20 +203,22 @@ class TC_SHARED_API ByteBuffer return *this; } - ByteBuffer &operator<<(const std::string &value) + ByteBuffer &operator<<(std::string_view value) { if (size_t len = value.length()) - append((uint8 const*)value.c_str(), len); - append((uint8)0); + append(reinterpret_cast<uint8 const*>(value.data()), len); + append(static_cast<uint8>(0)); return *this; } - ByteBuffer &operator<<(const char *str) + ByteBuffer& operator<<(std::string const& str) { - if (size_t len = (str ? strlen(str) : 0)) - append((uint8 const*)str, len); - append((uint8)0); - return *this; + return operator<<(std::string_view(str)); + } + + ByteBuffer &operator<<(char const* str) + { + return operator<<(std::string_view(str ? str : "")); } ByteBuffer &operator>>(bool &value) |
