diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-08-28 00:11:16 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-02-04 00:27:14 +0100 |
commit | 9f97fdd31a3b9a06b6acfa1101d105e43687e824 (patch) | |
tree | 027f81c18e7733fa3554cf1dd704a0900d254725 /src/server/shared/Packets/ByteBuffer.h | |
parent | 6e45c371c4098942e0085a71577a07b17725ee93 (diff) |
Core/Common: Tokenizer -> Trinity::Tokenize (PR: #25327)
(cherry picked from commit 534a2388b7c662c8796aabb1ec8cb424879799b6)
Diffstat (limited to 'src/server/shared/Packets/ByteBuffer.h')
-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 32f6bcbaee9..40c3782806d 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -300,20 +300,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) |