|
LuciadCPillar 2025.0.07
|
Represents an implicitly shared buffer of bytes, ie. More...
#include <luciad/containers/ByteBuffer.h>
Public Types | |
| using | const_iterator = const std::byte * |
| using | iterator = std::byte * |
Public Member Functions | |
| ByteBuffer () | |
| Creates an empty ByteBuffer. More... | |
| ByteBuffer (ByteBuffer &&) noexcept=default | |
| Creates a new ByteBuffer that is backed by the same shared data as the given ByteBuffer. More... | |
| ByteBuffer (const ByteBuffer &)=default | |
| Creates a new ByteBuffer that is backed by the same shared data as the given ByteBuffer. More... | |
| template<size_t S> | |
| ByteBuffer (const std::array< std::byte, S > &values) | |
| Creates a ByteBuffer with a copy of the given values. More... | |
| ByteBuffer (const std::byte *data, size_t size) | |
| Creates a ByteBuffer with a copy of the given values. More... | |
| template<unsigned Size> | |
| ByteBuffer (const std::byte(&data)[Size]) | |
| Creates a ByteBuffer from an array. More... | |
| ByteBuffer (size_t size) | |
| Creates a ByteBuffer with the given size. More... | |
| template<typename Deleter > | |
| ByteBuffer (std::byte *data, size_t length, Deleter deleter) | |
| Creates a ByteBuffer that wraps the given raw pointer. More... | |
| ByteBuffer (std::initializer_list< std::byte > values) | |
| Creates a ByteBuffer containing the given values. More... | |
| ~ByteBuffer ()=default | |
| std::byte & | at (size_t idx) |
| Retrieve a byte in the buffer after performing a range check. More... | |
| const std::byte & | at (size_t idx) const |
| Retrieve a byte in the buffer after performing a range check. More... | |
| std::byte * | data () |
| Returns the underlying byte array. More... | |
| const std::byte * | data () const |
| Returns the underlying byte array. More... | |
| bool | empty () const |
| Checks whether the buffer is empty. More... | |
| ByteBuffer & | operator= (ByteBuffer &&) noexcept=default |
| Move: the new ByteBuffer is backed by the same shared data. More... | |
| ByteBuffer & | operator= (const ByteBuffer &)=default |
| Shallow copy: the new ByteBuffer is backed by the same shared data. More... | |
| std::byte & | operator[] (size_t idx) |
| const std::byte & | operator[] (size_t idx) const |
| Retrieve a byte in the buffer. More... | |
| size_t | size () const |
| Gets the size of the buffer. More... | |
| ByteBuffer | subrange (size_t offset, size_t length) const |
| Creates a sub-buffer on the same shared data. More... | |
Represents an implicitly shared buffer of bytes, ie.
ByteBuffer copies (i.e. the copy constructor or assignment operator) result in shallow copies.
| using luciad::ByteBuffer::const_iterator = const std::byte* |
| using luciad::ByteBuffer::iterator = std::byte* |
|
default |
| luciad::ByteBuffer::ByteBuffer | ( | ) |
Creates an empty ByteBuffer.
|
explicit |
Creates a ByteBuffer with the given size.
| size | the size of the buffer in bytes. |
| luciad::ByteBuffer::ByteBuffer | ( | const std::byte * | data, |
| size_t | size | ||
| ) |
Creates a ByteBuffer with a copy of the given values.
| data | the array from which the values will be copied. |
| size | the size of the array to copy. |
|
inlineexplicit |
Creates a ByteBuffer with a copy of the given values.
| values | the array from which the values will be copied. |
| luciad::ByteBuffer::ByteBuffer | ( | std::initializer_list< std::byte > | values | ) |
Creates a ByteBuffer containing the given values.
| values | the initial values contained by this ByteBuffer. |
|
inlineexplicit |
Creates a ByteBuffer from an array.
Makes a copy of the original data.
| data | raw array from which to construct the ByteBuffer. |
|
default |
Creates a new ByteBuffer that is backed by the same shared data as the given ByteBuffer.
|
defaultnoexcept |
Creates a new ByteBuffer that is backed by the same shared data as the given ByteBuffer.
|
inline |
Creates a ByteBuffer that wraps the given raw pointer.
| data | raw pointer to the first byte of the array to use for this ByteBuffer. |
| length | the length of the array in T. |
| deleter | the Deleter that is used to free the raw pointer when the data is no longer used. |
| std::byte & luciad::ByteBuffer::at | ( | size_t | idx | ) |
Retrieve a byte in the buffer after performing a range check.
| idx | the index of the byte to retrieve. |
| const std::byte & luciad::ByteBuffer::at | ( | size_t | idx | ) | const |
Retrieve a byte in the buffer after performing a range check.
| idx | the index of the byte to retrieve |
| std::byte * luciad::ByteBuffer::data | ( | ) |
Returns the underlying byte array.
| const std::byte * luciad::ByteBuffer::data | ( | ) | const |
Returns the underlying byte array.
| bool luciad::ByteBuffer::empty | ( | ) | const |
Checks whether the buffer is empty.
|
defaultnoexcept |
Move: the new ByteBuffer is backed by the same shared data.
|
default |
Shallow copy: the new ByteBuffer is backed by the same shared data.
| std::byte & luciad::ByteBuffer::operator[] | ( | size_t | idx | ) |
| const std::byte & luciad::ByteBuffer::operator[] | ( | size_t | idx | ) | const |
Retrieve a byte in the buffer.
No range check is performed.
| idx | the index of the byte to retrieve. |
| size_t luciad::ByteBuffer::size | ( | ) | const |
Gets the size of the buffer.
| ByteBuffer luciad::ByteBuffer::subrange | ( | size_t | offset, |
| size_t | length | ||
| ) | const |
Creates a sub-buffer on the same shared data.
No data is copied.
| offset | the index of the first byte in the sub-buffer. |
| length | the number of bytes in the sub-buffer. |