33 std::ostringstream ss;
35 ss <<
"Attempted to get value with size: "
36 << valueSize <<
" in ByteBuffer (pos: " << pos <<
" size: " <<
size
49 value = read<float>();
50 if (!std::isfinite(value))
57 value = read<double>();
58 if (!std::isfinite(value))
68 char c = read<char>();
73 if (requireValidUtf8 && !utf8::is_valid(value.begin(), value.end()))
87 std::string 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,
"%2X", read<uint8>(i));
191 if ((i == (j * 8)) && ((i != (k * 16))))
196 else if (i == (k * 16))
#define TC_LOG_TRACE(filterType__,...)
std::string & message() noexcept
ByteBufferInvalidValueException(char const *type, char const *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 ReadCString(bool requireValidUtf8=true)
void put(std::size_t pos, T value)
ByteBuffer & operator>>(bool &value)
std::string ReadString(uint32 length, bool requireValidUtf8=true)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
constexpr std::size_t size()