class opaque_container_io_resource


template <
    typename Container
>
class opaque_container_io_resource
    : public seekable_io_resource<std::int64_t>
    , public opaque_container_input_resource<Container>
    , public opaque_container_output_resource<Container>

Description

An opaque container I/O resource is an I/O resource that reads and writes from/to a container that it owns.

Public Aliases

using content_type = Container

The type of content referenced by this opaque container I/O resource.

using element_type = typename Container::value_type

The type of element of the content referenced by this opaque container I/O resource.

Public Member Functions

explicit
opaque_container_io_resource (
    std::size_t buffer_capacity = 0
)

Constructs an opaque container I/O resource with the given buffer capacity and a default-constructed content object.

Parameters:
  • initial_content:

    The content that this opaque container I/O resource will reference.

  • buffer_capacity:

    The capacity of the I/O buffer. If this is zero, the opaque container I/O resource is completely unbuffered.

explicit
opaque_container_io_resource (
    const content_type& initial_content,
    std::size_t buffer_capacity = 0
)

Constructs an opaque container I/O resource with the given initial content and buffer capacity.

Parameters:
  • initial_content:

    The content that this opaque container I/O resource will reference.

  • buffer_capacity:

    The capacity of the I/O buffer. If this is zero, the opaque container I/O resource is completely unbuffered.

explicit
opaque_container_io_resource (
    content_type&& initial_content,
    std::size_t buffer_capacity = 0
)

Constructs an opaque container I/O resource with the given initial content and buffer capacity.

Parameters:
  • initial_content:

    The content that this opaque container I/O resource will reference.

  • buffer_capacity:

    The capacity of the I/O buffer. If this is zero, the opaque container I/O resource is completely unbuffered.

opaque_container_io_resource (
    const opaque_container_io_resource& other
)

Copy-constructs an opaque_container_io_resource from an existing one.

Parameters:
  • other:

    The opaque_container_io_resource to copy from.

opaque_container_io_resource&
operator = (
    const opaque_container_io_resource& other
)

Copy-assigns an opaque_container_io_resource into this one.

Parameters:
  • other:

    The opaque_container_io_resource to copy from.

opaque_container_io_resource (
    opaque_container_io_resource&& other
)
noexcept

Move-constructs an opaque_container_io_resource from an existing one.

Parameters:
  • other:

    The opaque_container_io_resource to move from.

opaque_container_io_resource&
operator = (
    opaque_container_io_resource&& other
)
noexcept

Move-assigns an opaque_container_io_resource into this one.

Parameters:
  • other:

    The opaque_container_io_resource to move from.

bool
is_at_end ()
const noexcept override

Returns true if this opaque container I/O resource is at the end of its referenced content. Otherwise, returns false.

std::int64_t
get_position ()
const noexcept override

Returns the position this opaque container I/O resource is at, that is, the position at which read and write operations will take place next.

void
set_position (
    position_type new_position,
    position_reference pr
)
noexcept override

Sets the position of this opaque container I/O resource.

Parameters:
  • new_position:

    The new position of this seekable I/o resource.

  • pr:

    The reference that the new position is relative to.

content_type&
grab_content ()
noexcept

Returns a non-constant reference to the referenced content.

const content_type&
grab_content ()
const noexcept

Returns a constant reference to the referenced content.

Protected Member Functions

void
set_position_raw (
    std::int64_t new_position,
    position_reference pr
)
noexcept override
std::size_t
read_raw (
    std::byte* data,
    std::size_t byte_count,
    read_request rr
)
override

Reads byte_count bytes from this opaque container I/O resource and places them in the provided data array.

Parameters:
  • data:

    The array into which the read bytes will be placed.

  • byte_count:

    The number of bytes to read from this I/O resource.

  • rr:

    The kind of read request that is being issued to this I/O resource.

std::size_t
write_raw (
    const std::byte* data,
    std::size_t byte_count
)
override

Writes byte_count bytes from the data array to this opaque container output resource.

Parameters:
  • data:

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

  • byte_count:

    The number of bytes to write to this output resource.



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 2023.