Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ByteBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ class ByteBuffer
{
return read<double>();
}
std::string getString(uint32_t len)
{
if (buffer_.empty() || position_ + len > limit_)
return std::string();

std::string result(reinterpret_cast<const char*>(buffer_.data()) + position_, len);
position_ += len;
return result;
}
std::string getString(uint32_t index, uint32_t len) const
{
if (buffer_.empty() || index + len > limit_)
return std::string();

return std::string(reinterpret_cast<const char*>(buffer_.data()) + index, len);
}
double getDouble(uint32_t index) const
{
return read<double>(index);
Expand Down