aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/Packets/ByteBuffer.h18
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)