27 :
ByteBufferException(
Trinity::StringFormat(
"Attempted to get value with size: {} in ByteBuffer (pos: {} size: {})", valueSize, pos, size))
39 if (!std::isfinite(value))
47 if (!std::isfinite(value))
59 char const* begin =
reinterpret_cast<char const*
>(
_storage.data()) +
_rpos;
60 char const* end =
reinterpret_cast<char const*
>(
_storage.data()) +
size();
61 char const* stringEnd = std::ranges::find(begin, end,
'\0');
65 std::string_view value(begin, stringEnd);
66 _rpos += value.length() + 1;
67 if (requireValidUtf8 && !utf8::is_valid(value.begin(), value.end()))
81 std::string_view value(
reinterpret_cast<char const*
>(&
_storage[
_rpos]), length);
83 if (requireValidUtf8 && !utf8::is_valid(value.begin(), value.end()))
96 size_t const newSize =
_wpos + cnt;
101 else if (newSize < 750)
103 else if (newSize < 6000)
118 ASSERT(src,
"Attempted to put a NULL-pointer in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", pos,
size());
119 ASSERT(cnt,
"Attempted to put a zero-sized value in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", pos,
size());
121 std::memcpy(&
_storage[pos], src, cnt);
126 ASSERT(pos + bitCount <=
size() * 8,
"Attempted to put %u bits in ByteBuffer (bitpos: " SZFMTD " size: " SZFMTD ")", bitCount, pos,
size());
127 ASSERT(bitCount,
"Attempted to put a zero bits in ByteBuffer");
129 for (
uint32 i = 0; i < bitCount; ++i)
131 std::size_t wp = (pos + i) / 8;
132 std::size_t bit = (pos + i) % 8;
133 if ((value >> (bitCount - i - 1)) & 1)
146 std::ostringstream o;
159 std::ostringstream o;
172 std::ostringstream o;
173 o.setf(std::ios_base::hex, std::ios_base::basefield);
178 char const* sep =
" | ";
179 for (
uint32 j = 0; j < 2; ++j)
181 for (
uint32 k = 0; k < 8; ++k)
#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
void OnInvalidPosition(size_t pos, size_t valueSize) const
std::string_view ReadCString(bool requireValidUtf8=true)
ByteBuffer & operator>>(bool &)=delete
std::string_view ReadString(uint32 length, bool requireValidUtf8=true)
void put(std::size_t pos, T value)