3 #ifndef _XDRPP_MESSAGE_H_HEADER_INCLUDED_ 4 #define _XDRPP_MESSAGE_H_HEADER_INCLUDED_ 1 17 using msg_ptr = std::unique_ptr<message_t>;
25 const std::size_t size_;
26 alignas(std::uint32_t)
char buf_[4];
27 message_t(std::size_t size) : size_(size) {}
29 std::size_t size()
const {
return size_; }
30 char *data() {
return buf_ + 4; }
31 const char *data()
const {
return buf_ + 4; }
32 const uint32_t word(std::ptrdiff_t i)
const {
33 return reinterpret_cast<const uint32_t *
>(data())[i];
37 char *
end() {
return buf_ + 4 + size_; }
38 const char *
end()
const {
return buf_ + 4 + size_; }
42 const char *
raw_data()
const {
return buf_; }
44 std::size_t
raw_size()
const {
return size_ + 4; }
47 static msg_ptr
alloc(std::size_t size);
52 #endif // !_XDRPP_MESSAGE_H_HEADER_INCLUDED_ static msg_ptr alloc(std::size_t size)
Allocate a new buffer.
char * end()
End of the buffer (one past last byte).
Most of the xdrpp library is encapsulated in the xdr namespace.
Message buffer, with room at beginning for 4-byte length.
Low-level byteswap and miscellaneous OS compatibility routines.
char * raw_data()
4-byte buffer to store size in network byte order, followed by data.
std::size_t raw_size() const
Size of 4-byte length plus data.