45 if (!std::isfinite(value))
53 if (!std::isfinite(value))
65 char const* begin =
reinterpret_cast<char const*
>(
_storage.data()) +
_rpos;
66 char const* end =
reinterpret_cast<char const*
>(
_storage.data()) +
size();
67 char const* stringEnd = std::ranges::find(begin, end,
'\0');
71 std::string_view value(begin, stringEnd);
72 _rpos += value.length() + 1;
73 if (requireValidUtf8 && !utf8::is_valid(value.begin(), value.end()))
87 std::string_view value(
reinterpret_cast<char const*
>(&
_storage[
_rpos]), length);
89 if (requireValidUtf8 && !utf8::is_valid(value.begin(), value.end()))
102 size_t const newSize =
_wpos + cnt;
107 else if (newSize < 750)
109 else if (newSize < 6000)
124 ASSERT(src,
"Attempted to put a NULL-pointer in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", pos,
size());
125 ASSERT(cnt,
"Attempted to put a zero-sized value in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", pos,
size());
127 std::memcpy(&
_storage[pos], src, cnt);
132 ASSERT(pos + bitCount <=
size() * 8,
"Attempted to put %u bits in ByteBuffer (bitpos: " SZFMTD " size: " SZFMTD ")", bitCount, pos,
size());
133 ASSERT(bitCount,
"Attempted to put a zero bits in ByteBuffer");
135 for (
uint32 i = 0; i < bitCount; ++i)
137 std::size_t wp = (pos + i) / 8;
138 std::size_t bit = (pos + i) % 8;
139 if ((value >> (bitCount - i - 1)) & 1)
151 std::ostringstream o;
152 o <<
"STORAGE_SIZE: " <<
size();
154 o << read<uint8>(i) <<
" - ";
165 std::ostringstream o;
166 o <<
"STORAGE_SIZE: " <<
size();
170 snprintf(buf, 2,
"%c", read<uint8>(i));
184 std::ostringstream o;
185 o <<
"STORAGE_SIZE: " <<
size();
190 snprintf(buf, 4,
"%02X", read<uint8>(i));
191 if ((i == (j * 8)) && ((i != (k * 16))))
196 else if (i == (k * 16))
#define TC_LOG_TRACE(filterType__, message__,...)
ByteBufferInvalidValueException(char const *type, std::string_view value)
ByteBufferPositionException(size_t pos, size_t size, size_t valueSize)
std::vector< uint8 > _storage
void PutBits(std::size_t pos, std::size_t value, uint32 bitCount)
void print_storage() const
std::string_view ReadCString(bool requireValidUtf8=true)
std::string_view ReadString(uint32 length, bool requireValidUtf8=true)
void put(std::size_t pos, T value)
ByteBuffer & operator>>(bool &value)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
constexpr std::size_t size()