14 #ifndef THRILL_NET_BUFFER_REF_HEADER 15 #define THRILL_NET_BUFFER_REF_HEADER 37 using Byte =
unsigned char;
53 : data_(reinterpret_cast<const
Byte*>(data)), size_(size)
58 : data_(reinterpret_cast<const
Byte*>(str.
data())),
77 {
return std::string(reinterpret_cast<const char*>(data_), size_); }
81 void* addr =
reinterpret_cast<void*
>(
const_cast<Byte*
>(
data_));
90 if (size_ != br.size_)
return false;
91 return std::equal(data_, data_ + size_, br.data_);
105 #endif // !THRILL_NET_BUFFER_REF_HEADER bool operator==(const BufferRef &br) const noexcept
Compare contents of two BufferRefs.
Buffer ToBuffer()
Explicit conversion to Buffer MOVING the memory ownership.
const void * data() const
Return a pointer to the currently kept memory area.
BufferRef(const void *data, size_t size)
Constructor, assign memory area from pointer and length.
BufferRef(const BufferBuilder &bb)
Constructor, assign memory area from BufferBuilder.
const Byte * data_
Allocated buffer pointer.
std::string ToString() const
Explicit conversion to std::string (copies memory of course).
static Buffer Acquire(void *data, size_type size)
BufferRef(const std::string &str)
Constructor, assign memory area from string, does NOT copy.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
unsigned char Byte
type used to store the bytes
BufferRef represents a reference to a memory area as pointer and valid length.
size_t size() const
Return the currently valid length in bytes.
BufferBuilder represents a dynamically growable area of memory, which can be modified by appending in...
Simple buffer of characters without initialization or growing functionality.
bool operator!=(const BufferRef &br) const noexcept
Compare contents of two BufferRefs.
size_t size_
Size of valid data.
BufferRef(const Buffer &b)
Constructor, assign memory area from net::Buffer, does NOT copy!