|
xentara-utils v2.0.6
The Xentara Utility Library
|
A device that writes data to a memory region. More...
#include <xentara/utils/io/MemoryOutputDevice.hpp>
Inheritance diagram for xentara::utils::io::MemoryOutputDevice< Element >:Public Types | |
| using | value_type = Element |
| The element type. | |
| using | reference = value_type & |
| A reference to an element. | |
| using | const_reference = const value_type & |
| A const reference to an element. | |
| using | pointer = value_type * |
| A pointer to an element. | |
| using | const_pointer = const value_type * |
| A const pointer to an element. | |
| using | const_iterator = core::ContiguousIterator< const_pointer, MemoryOutputDevice > |
| A const iterator. | |
| using | iterator = const_iterator |
| An iterator. | |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| A const iterator for iterating in reverse order. | |
| using | reverse_iterator = const_reverse_iterator |
| An iterator for iterating in reverse order. | |
Public Types inherited from xentara::utils::io::MemoryOutputDeviceBase | |
| using | size_type = std::size_t |
| The type used for sizes. | |
| using | difference_type = std::ptrdiff_t |
| The type used for distances. | |
Public Member Functions | |
Constructors | |
| template<memory::MemoryIterator Iterator> requires std::is_same_v<std::remove_volatile_t<std::iter_value_t<Iterator>>, Element> | |
| MemoryOutputDevice (Iterator begin, Iterator end) | |
| Constructs a stream that writes to a memory region defined by a pair of iterators. | |
| template<memory::MemoryIterator Iterator> requires std::is_same_v<std::remove_volatile_t<std::iter_value_t<Iterator>>, Element> | |
| MemoryOutputDevice (Iterator begin, std::iter_difference_t< Iterator > size) | |
| Constructs a stream that writes to a memory region defined by an iterator and a size. | |
| template<memory::MemoryRegion Region> requires std::is_same_v<std::remove_volatile_t<std::ranges::range_value_t<Region>>, Element> | |
| MemoryOutputDevice (Region ®ion) | |
| Constructs a stream that writes to a memory region. | |
Access to the written data | |
| auto | at (size_type index) const -> const_reference |
| Accesses the element at a certain index. | |
| auto | operator[] (size_type index) const noexcept -> const_reference |
| Subscript operator. | |
| auto | front () const noexcept -> const_reference |
| Returns the first element. | |
| auto | back () const noexcept -> const_reference |
| Returns the last element. | |
| auto | data () const noexcept -> const value_type * |
| Raw access to the data. | |
| template<typename CharTraits = std::char_traits<Element>> requires std::same_as<Element, char> || std::same_as<Element, char8_t> | |
| operator std::basic_string_view< Element, CharTraits > () const | |
| Returns the data written so far as a string view. | |
Iterators | |
| auto | begin () const noexcept -> const_iterator |
| Creates a begin iterator. | |
| auto | cbegin () const noexcept -> const_iterator |
| Creates a begin iterator. | |
| auto | end () const noexcept -> const_iterator |
| Creates an end iterator. | |
| auto | cend () const noexcept -> const_iterator |
| Creates an end iterator. | |
| auto | rbegin () const noexcept -> const_reverse_iterator |
| Creates a reverse begin iterator. | |
| auto | crbegin () const noexcept -> const_reverse_iterator |
| Creates a reverse begin iterator. | |
| auto | rend () const noexcept -> const_reverse_iterator |
| Creates a reverse end iterator. | |
| auto | crend () const noexcept -> const_reverse_iterator |
| Creates a reverse end iterator. | |
Public Member Functions inherited from xentara::utils::io::MemoryOutputDeviceBase | |
| auto | empty () const noexcept -> bool |
| Determines whether the data is empty. | |
| auto | size () const noexcept -> size_type |
| Gets the size of the data. | |
| auto | capacity () const noexcept -> size_type |
| Gets the capacity of the data. | |
| auto | truncate () -> void |
| Truncates the data at the current position. | |
| auto | clear () -> void |
| Clears all written data and resets the write position to the beginning. | |
Public Member Functions inherited from xentara::utils::io::OutputDevice | |
| virtual | ~OutputDevice () noexcept(false)=0 |
| Virtual, throwing destructor. | |
| template<std::ranges::contiguous_range Data> requires std::same_as<std::remove_cv_t<std::ranges::range_value_t<Data>>, std::byte> | |
| auto | write (const Data &data) -> void |
| Writes a block of data. | |
| auto | writeByte (std::byte byte) -> void |
| Write a single byte. | |
| template<std::ranges::contiguous_range Data> requires std::same_as<std::remove_cv_t<std::ranges::range_value_t<Data>>, std::byte> | |
| auto | writeChunk (const Data &data) -> std::ranges::range_size_t< Data > |
| Writes a single chunk of data contained in an iterator range. | |
| template<std::ranges::contiguous_range Data> requires std::same_as<std::remove_cv_t<std::ranges::range_value_t<Data>>, std::byte> | |
| auto | tryWrite (const Data &data) -> std::ranges::range_size_t< Data > |
| Write as much of a data block as is possible without blocking. | |
| auto | tryWriteByte (std::byte byte) -> bool |
| Write a single byte, if this can be done without blocking. | |
| template<std::contiguous_iterator Iterator, std::sized_sentinel_for< Iterator > Sentinel> requires std::same_as<std::remove_cv_t<std::iter_value_t<Iterator>>, std::byte> | |
| auto | write (Iterator first, Sentinel last) -> void |
| Writes the data contained in an iterator range. | |
| template<std::contiguous_iterator Iterator, std::sized_sentinel_for< Iterator > Sentinel> requires std::same_as<std::remove_cv_t<std::iter_value_t<Iterator>>, std::byte> | |
| auto | writeChunk (Iterator first, Sentinel last) -> Iterator |
| Writes a single chunk of data from an an iterator range. | |
| template<std::contiguous_iterator Iterator, std::sized_sentinel_for< Iterator > Sentinel> requires std::same_as<std::iter_value_t<Iterator>, std::byte> | |
| auto | tryWrite (Iterator first, Sentinel last) -> Iterator |
| Write as much of the data contained in an iterator range as is possible without blocking. | |
| auto | write (const std::byte *data, std::size_t size) -> void |
| Write a block of data. | |
| auto | writeChunk (const std::byte *data, std::size_t size) -> std::size_t |
| Writes a single chunk of data. | |
| auto | tryWrite (const std::byte *data, std::size_t size) -> std::size_t |
| Write as much of a data block as is possible without blocking. | |
| auto | writePosition () const -> std::optional< std::size_t > |
| Gets the current write position within the device. | |
| auto | setWritePosition (std::size_t position) -> std::optional< std::size_t > |
| Sets the current write position within the device. | |
| auto | moveWritePosition (std::ptrdiff_t offset, std::ios_base::seekdir origin=std::ios_base::cur) -> std::optional< std::size_t > |
| Advances or retreats the current write position within the device. | |
| auto | waitUntilWritable (std::chrono::nanoseconds timeout) -> bool |
| Waits for the device to be able to accept more write data within a certain time. | |
| auto | writeTimeout () const noexcept -> std::chrono::nanoseconds |
| Returns the write timeout for communication devices. | |
Public Member Functions inherited from xentara::utils::io::DeviceBase | |
| virtual | ~DeviceBase () noexcept(false)=0 |
| Virtual, throwing destructor. | |
| auto | deviceDescription () const -> std::string |
| Get a description of the device. | |
Additional Inherited Members | |
Protected Member Functions inherited from xentara::utils::io::OutputDevice | |
| virtual auto | doWrite (const std::byte *data, std::size_t size) -> std::size_t=0 |
| Called by the framework to write data up to a maximum size. | |
| virtual auto | doWaitUntilWritable (std::optional< std::chrono::nanoseconds > timeout) -> bool |
| Called by the framework to wait for the device to be able to accept more write data with an optional timeout. | |
| virtual auto | doWaitUntilWritableAndWrite (const std::byte *data, std::size_t size, std::chrono::nanoseconds timeout) -> std::size_t |
| Called by the framework to wait for the device to be able to accept more write data, and then write to it. | |
| virtual auto | doGetWriteTimeout () const noexcept -> std::chrono::nanoseconds |
| Called by the framework to get the write timeout. | |
| virtual auto | doGetWritePosition () const -> std::optional< std::size_t > |
| Called by the framework to get the current write position within the device. | |
| virtual auto | doSetWritePosition (std::size_t position) -> std::optional< std::size_t > |
| Called by the framework to set the current write position within the device. | |
| virtual auto | doMoveWritePosition (std::ptrdiff_t offset, std::ios_base::seekdir origin=std::ios_base::cur) -> std::optional< std::size_t > |
| Called by the framework to advance or retreat the current write position within the device. | |
Protected Member Functions inherited from xentara::utils::io::DeviceBase | |
| virtual auto | doGetDeviceDescription () const -> std::string=0 |
| Called by the framework to get a description of the device. | |
A device that writes data to a memory region.
| Element | The type for the elements. Must be std::byte, or another trivial type that is the same size as std::byte. Common types include char, unsigned char, and char8_t. |
| using xentara::utils::io::MemoryOutputDevice< Element >::const_iterator = core::ContiguousIterator<const_pointer, MemoryOutputDevice> |
A const iterator.
| using xentara::utils::io::MemoryOutputDevice< Element >::const_pointer = const value_type * |
A const pointer to an element.
| using xentara::utils::io::MemoryOutputDevice< Element >::const_reference = const value_type & |
A const reference to an element.
| using xentara::utils::io::MemoryOutputDevice< Element >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
A const iterator for iterating in reverse order.
| using xentara::utils::io::MemoryOutputDevice< Element >::iterator = const_iterator |
An iterator.
| using xentara::utils::io::MemoryOutputDevice< Element >::pointer = value_type * |
A pointer to an element.
| using xentara::utils::io::MemoryOutputDevice< Element >::reference = value_type & |
A reference to an element.
| using xentara::utils::io::MemoryOutputDevice< Element >::reverse_iterator = const_reverse_iterator |
An iterator for iterating in reverse order.
| using xentara::utils::io::MemoryOutputDevice< Element >::value_type = Element |
The element type.
| xentara::utils::io::MemoryOutputDevice< Element >::MemoryOutputDevice | ( | Iterator | begin, |
| Iterator | end | ||
| ) |
Constructs a stream that writes to a memory region defined by a pair of iterators.
| begin | An iterator that points at the beginning of the memory region |
| end | An iterator that points at the end of the memory region |
| xentara::utils::io::MemoryOutputDevice< Element >::MemoryOutputDevice | ( | Iterator | begin, |
| std::iter_difference_t< Iterator > | size | ||
| ) |
Constructs a stream that writes to a memory region defined by an iterator and a size.
| begin | An iterator that points at the beginning of the memory region |
| size | The size of the memory region |
| xentara::utils::io::MemoryOutputDevice< Element >::MemoryOutputDevice | ( | Region & | region | ) |
Constructs a stream that writes to a memory region.
| region | The memory region |
| auto xentara::utils::io::MemoryOutputDevice< Element >::at | ( | size_type | index | ) | const -> const_reference |
Accesses the element at a certain index.
| index | The index |
| std::out_of_range | index is out of range |
|
noexcept |
Returns the last element.
|
noexcept |
Creates a begin iterator.
|
noexcept |
Creates a begin iterator.
|
noexcept |
Creates an end iterator.
|
noexcept |
Creates a reverse begin iterator.
|
noexcept |
Creates a reverse end iterator.
|
noexcept |
Raw access to the data.
|
noexcept |
Creates an end iterator.
|
noexcept |
Returns the first element.
| xentara::utils::io::MemoryOutputDevice< Element >::operator std::basic_string_view< Element, CharTraits > | ( | ) | const |
Returns the data written so far as a string view.
char and char8_t.
|
noexcept |
Subscript operator.
Returns a reference to the element at a certain index
| index | The index |
|
noexcept |
Creates a reverse begin iterator.
|
noexcept |
Creates a reverse end iterator.