class input_stream


template <
    typename InputResource
>
class input_stream

Description

An input stream is an object that reads data from an input resource.

There are two kinds of input streams in CCL: data input streams, which read binary data from its input resource, and text input streams, which read text from its input resource.

The input_stream class template serves as the foundation for both data input streams and text input streams.

Public Aliases

using referenced_resource_type = InputResource

The type of the referenced input resource.

Public Member Functions

explicit
input_stream (
    referenced_resource_type& resource,
    std::endian endianness = std::endian::native
)
noexcept

Constructs an input stream with the given input resource and endianness.

Parameters:
  • resource:

    The input resource this stream will read from.

  • endianness:

    The endianness the data is expected to be in.

input_stream (
    const input_stream& other
)

Copy-constructs an input_stream from an existing one.

Parameters:
  • other:

    The input_stream to copy from.

input_stream&
operator = (
    const input_stream& other
)

Copy-assigns an input_stream into this one.

Parameters:
  • other:

    The input_stream to copy from.

input_stream (
    input_stream&& other
)
noexcept

Move-constructs an input_stream from an existing one.

Parameters:
  • other:

    The input_stream to move from.

input_stream&
operator = (
    input_stream&& other
)
noexcept

Move-assigns an input_stream into this one.

Parameters:
  • other:

    The input_stream to move from.

referenced_resource_type&
grab_resource ()
noexcept

Returns a non-constant reference to the referenced input resource.

const referenced_resource_type&
grab_resource ()
const noexcept

Returns a constant reference to the referenced input resource.

std::endian
get_endianness ()
const noexcept

Returns the endianness associated with this input stream.

void
set_endianness (
    std::endian new_endianness
)
noexcept

Sets the endianness associated with this input stream.

Parameters:
  • new_endianness:

    The new endianness to use with this input stream.

bool
is_at_end ()
const noexcept

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

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

Reads byte_count bytes from this stream's input 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 stream's input resource.

referenced_resource_type*
operator -> ()
const noexcept

Returns a pointer to the referenced input 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 2023.