2021-10-20 20:31:14 +02:00
|
|
|
#include "CustomPacketWrite.h"
|
2021-10-17 08:58:46 +02:00
|
|
|
|
2021-10-20 20:35:46 +02:00
|
|
|
CustomPacketWrite::CustomPacketWrite(
|
2021-10-23 12:09:38 +02:00
|
|
|
opcode_t opcode
|
|
|
|
|
, chunkSize_t chunkSize
|
|
|
|
|
, totalSize_t size
|
2021-10-20 17:22:11 +02:00
|
|
|
)
|
2021-10-23 12:09:38 +02:00
|
|
|
: CustomPacketBase(opcode, chunkSize, size)
|
2021-10-17 08:58:46 +02:00
|
|
|
{}
|
|
|
|
|
|
2021-10-20 20:35:46 +02:00
|
|
|
CustomPacketWrite::CustomPacketWrite()
|
2021-10-23 12:09:38 +02:00
|
|
|
: CustomPacketBase()
|
2021-10-17 08:58:46 +02:00
|
|
|
{}
|
|
|
|
|
|
2021-10-20 20:35:46 +02:00
|
|
|
CustomPacketWrite* CustomPacketWrite::operator->() { return this; }
|
2021-10-17 08:58:46 +02:00
|
|
|
|
2021-11-17 10:36:36 +01:00
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteString(std::string const& str)
|
|
|
|
|
{
|
|
|
|
|
return WriteString(str, str.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteString(const char* str)
|
|
|
|
|
{
|
|
|
|
|
return WriteString(str, strlen(str));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-20 20:35:46 +02:00
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteString(
|
2021-10-23 12:09:38 +02:00
|
|
|
std::string const& str
|
|
|
|
|
, totalSize_t length
|
2021-10-17 08:58:46 +02:00
|
|
|
) {
|
2021-10-23 12:09:38 +02:00
|
|
|
return WriteString(str.c_str(), length);
|
2021-10-17 08:58:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-20 20:35:46 +02:00
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteString(
|
2021-10-23 12:09:38 +02:00
|
|
|
const char* chr
|
|
|
|
|
, totalSize_t length
|
2021-10-17 08:58:46 +02:00
|
|
|
) {
|
2021-10-23 12:09:38 +02:00
|
|
|
Write<totalSize_t>(length);
|
|
|
|
|
WriteBytes(length, chr);
|
|
|
|
|
return this;
|
2021-10-17 08:58:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-20 20:35:46 +02:00
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteStringNullTerm(
|
2021-10-23 12:09:38 +02:00
|
|
|
std::string const& str
|
|
|
|
|
, totalSize_t length
|
2021-10-17 08:58:46 +02:00
|
|
|
) {
|
2021-10-23 12:09:38 +02:00
|
|
|
return WriteStringNullTerm(str.c_str(), length);
|
2021-10-17 08:58:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-20 20:35:46 +02:00
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteStringNullTerm(
|
2021-10-23 12:09:38 +02:00
|
|
|
const char* chr
|
|
|
|
|
, totalSize_t length
|
2021-10-17 08:58:46 +02:00
|
|
|
) {
|
2021-10-23 12:09:38 +02:00
|
|
|
WriteBytes(length, chr);
|
|
|
|
|
Write<uint8_t>(0);
|
|
|
|
|
return this;
|
2021-10-17 08:58:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-17 10:36:36 +01:00
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteStringNullTerm(
|
|
|
|
|
std::string const& str
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
return WriteStringNullTerm(str, str.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteStringNullTerm(
|
|
|
|
|
const char* chr
|
|
|
|
|
)
|
2021-10-17 08:58:46 +02:00
|
|
|
{
|
2021-11-17 10:36:36 +01:00
|
|
|
return WriteStringNullTerm(chr, strlen(chr));
|
2021-10-17 08:58:46 +02:00
|
|
|
}
|
2021-10-20 06:28:55 +02:00
|
|
|
|
2021-10-22 06:31:08 +02:00
|
|
|
CustomPacketWrite* CustomPacketWrite::WriteBytes(totalSize_t size, char const* bytes)
|
2021-10-20 06:28:55 +02:00
|
|
|
{
|
2021-10-23 12:09:38 +02:00
|
|
|
CustomPacketBase::WriteBytes(size, bytes);
|
|
|
|
|
return this;
|
2021-10-20 06:28:55 +02:00
|
|
|
}
|