13#include <boost/asio/buffer.hpp>
20#ifdef LIBCARLA_INCLUDED_FROM_UE4
22#include "Containers/Array.h"
171 boost::asio::const_buffer
cbuffer() const noexcept {
176 boost::asio::const_buffer
buffer() const noexcept {
181 boost::asio::mutable_buffer
buffer() noexcept {
202 return (std::numeric_limits<size_type>::max)();
255 _data = std::make_unique<value_type[]>(
size);
273 std::unique_ptr<value_type[]>
data = std::move(
_data);
274 uint64_t old_size =
size;
283 std::unique_ptr<value_type[]>
pop() noexcept {
286 return std::move(
_data);
304 template <
typename T>
322 template <
typename T>
323 typename std::enable_if<boost::asio::is_const_buffer_sequence<T>::value>::type
325 reset(boost::asio::buffer_size(source) + offset);
328 boost::asio::buffer_copy(
buffer() + offset, source);
333 template <
typename T>
334 typename std::enable_if<!boost::asio::is_const_buffer_sequence<T>::value>::type
336 copy_from(offset, boost::asio::buffer(source));
339#ifdef LIBCARLA_INCLUDED_FROM_UE4
341 template <
typename T>
345 reinterpret_cast<const value_type *
>(source.GetData()),
346 sizeof(T) * source.Num());
372 std::unique_ptr<value_type[]>
_data =
nullptr;
#define DEBUG_ASSERT(predicate)
Creating a constant view from an existing buffer
std::unique_ptr< value_type[]> _data
Buffer & operator=(const Buffer &)=delete
const_iterator begin() const noexcept
const value_type * data() const noexcept
Direct access to the allocated memory or nullptr if no memory is allocated.
static constexpr size_type max_size() noexcept
std::enable_if<!boost::asio::is_const_buffer_sequence< T >::value >::type copy_from(size_type offset, const T &source)
Copy source into this buffer leaving at the front an offset of offset bytes uninitialized.
void reset(size_type size)
Reset the size of this buffer.
size_type size() const noexcept
const_iterator cend() const noexcept
Buffer()=default
Create an empty buffer.
void copy_from(size_type offset, const Buffer &rhs)
Copy source into this buffer leaving at the front an offset of offset bytes uninitialized.
std::unique_ptr< value_type[]> pop() noexcept
Release the contents of this buffer and set its size and capacity to zero.
value_type & operator[](size_t i)
Access the byte at position i.
void copy_from(const T &source)
Copy source into this buffer. Allocates memory if necessary.
void resize(uint64_t size)
Resize the buffer, a new block of size size is allocated if the capacity is not enough and the data i...
boost::asio::const_buffer buffer() const noexcept
Make a boost::asio::buffer from this buffer.
Buffer(size_type size)
Create a buffer with size bytes allocated.
size_type capacity() const noexcept
Buffer & operator=(Buffer &&rhs) noexcept
void copy_from(const value_type *data, size_type size)
Copy size bytes of the memory pointed by data into this buffer.
std::weak_ptr< BufferPool > _parent_pool
boost::asio::mutable_buffer buffer() noexcept
Make a boost::asio::buffer from this buffer.
std::enable_if< boost::asio::is_const_buffer_sequence< T >::value >::type copy_from(size_type offset, const T &source)
Copy source into this buffer leaving at the front an offset of offset bytes uninitialized.
bool empty() const noexcept
Buffer(const value_type *data, size_type size)
Buffer(const T &source)
Copy source into this buffer. Allocates the necessary memory.
const value_type * const_iterator
void copy_from(size_type offset, const value_type *data, size_type size)
Copy size bytes of the memory pointed by data into this buffer, leaving at the front an offset of off...
Buffer(const value_type *data, uint64_t size)
Create a buffer with size bytes allocated.
iterator begin() noexcept
const_iterator cbegin() const noexcept
const_iterator end() const noexcept
value_type * data() noexcept
Direct access to the allocated memory or nullptr if no memory is allocated.
Buffer(Buffer &&rhs) noexcept
boost::asio::const_buffer cbuffer() const noexcept
Make a boost::asio::buffer from this buffer.
void reset(uint64_t size)
Reset the size of this buffer.
void clear() noexcept
Clear the contents of this buffer and set its size and capacity to zero.
Buffer(uint64_t size)
Create a buffer with size bytes allocated.
Buffer(const Buffer &)=delete
const value_type & operator[](size_t i) const
Access the byte at position i.
This file contains definitions of common data structures used in traffic manager.
void throw_exception(const std::exception &e)
static void log_debug(Args &&... args)