class output_stream


template <
    typename OutputResource
>
class output_stream

Public Aliases

using wrapped_resource_type = OutputResource

The type of the wrapped output resource.

Public Member Functions

explicit
output_stream (
    wrapped_resource_type& resource,
    std::endian endianness = std::endian::native,
    flush_strategy fs = flush_strategy::manual
)
noexcept

Constructs an output stream with the given output resource, endianness and flush strategy.

Parameters:
  • resource:

    The output resource this stream will write to.

  • endianness:

    The endianness to write the data in.

  • fs:

    The flush strategy to use.

wrapped_resource_type&
grab_resource ()
noexcept

Returns a non-constant reference to the wrapped output resource.

const wrapped_resource_type&
grab_resource ()
const noexcept

Returns a constant reference to the wrapped output resource.

std::endian
get_endianness ()
const noexcept

Returns the endianness associated with this output stream.

void
set_endianness (
    std::endian new_endianness
)
noexcept

Sets the endianness associated with this output stream.

Parameters:
  • new_endianness:

    The new endianness to use with this output stream.

flush_strategy
get_flush_strategy ()
const noexcept

Returns the flush strategy associated with this output stream.

void
set_flush_strategy (
    flush_strategy new_flush_strategy
)
noexcept

Sets the flush strategy associated with this output stream.

Parameters:
  • new_flush_strategy:

    The new flush strategy to use with this output stream.

bool
is_at_end ()
const noexcept

Tells whether this stream's output resource is at its end.

std::size_t
write (
    const std::byte* data,
    std::size_t byte_count
)

Writes byte_count bytes from the data array to this stream's output resource.

Parameters:
  • data:

    The array of bytes that will be written to this stream's output resource.

  • byte_count:

    The number of bytes to write to this stream's output resource.

std::size_t
reverse_write (
    std::byte* data,
    std::size_t byte_count
)

Reverses the order of the bytes in the data array and then writes them to this stream's output resource.

Parameters:
  • data:

    The bytes that will be reversed and written to this stream's output resource.

  • byte_count:

    The number of bytes to reverse and write to this stream's output resource.

void
flush ()

Flushes the stream's output resource, ensuring that any data that has previously been requested to be written out actually gets written out.

wrapped_resource_type*
operator -> ()
const noexcept

Returns a pointer to the wrapped output resource, enabling use of the arrow operator.



Copyright © 2022-2025 Daniel T. McGinnis

CCL was first published in 2022, and is still actively maintained.

This website was first published in 2022, and is still actively maintained.

This specific web page was first published in 2022.