14 #ifndef THRILL_NET_BUFFER_READER_HEADER 15 #define THRILL_NET_BUFFER_READER_HEADER 73 return cursor_ + size <=
size_;
78 return cursor_ ==
size_;
87 return data_ ==
nullptr;
105 throw std::underflow_error(
"BufferReader underrun");
126 Byte* coutdata =
reinterpret_cast<Byte*
>(outdata);
127 std::copy(
data_ + cursor_,
data_ + cursor_ + datalen, coutdata);
138 reinterpret_cast<const char*>(
data_ + cursor_), datalen);
145 template <
typename Type>
149 "You only want to Get() trivially copyable types as raw values.");
154 cursor_ +=
sizeof(
Type);
161 return Get<uint8_t>();
166 template <
typename Type>
190 #endif // !THRILL_NET_BUFFER_READER_HEADER
void CheckAvailable(size_t n) const
bool IsNull() const
Indicates if the reader was initialized with a nullptr and size 0.
BufferReader & Read(void *outdata, size_t datalen)
std::string Read(size_t datalen)
const void * data() const
Return a pointer to the currently kept memory area.
size_t cursor() const
Return the current read cursor.
size_t cursor_
Current read cursor.
Byte GetByte()
Fetch a single byte from the buffer, advancing the cursor.
BufferReader(const std::string &str)
Constructor, assign memory area from string, does NOT copy.
BufferReader represents a BufferRef with an additional cursor with which the memory can be read incre...
const Byte * data_
Allocated buffer pointer.
BufferReader(const BufferRef &br)
Constructor, assign memory area from BinaryBuilder.
std::is_trivially_copyable< T > is_trivially_copyable
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
BufferReader(const void *data, size_t n)
Constructor, assign memory area from pointer and length.
unsigned char Byte
type used to store the bytes
BufferRef represents a reference to a memory area as pointer and valid length.
bool empty() const
Return true if the cursor is at the end of the buffer.
size_t size() const
Return the currently valid length in bytes.
BufferReader & Rewind()
Reset the read cursor.
bool available(size_t size) const
Return the number of bytes still available at the cursor.
size_t size_
Size of valid data.
BufferReader & Skip(size_t n)
Advance the cursor given number of bytes without reading them.