class text_input_stream


template <
    typename InputResource
>
class text_input_stream
    : public input_stream<InputResource>

Description

A text input stream is an object that allows you to read text from an input resource.

Public Aliases

using referenced_resource_type = InputResource

The type of the referenced input resource.

Public Member Functions

text_input_stream (
    referenced_resource_type& resource,
    encoding_form source_encoding_form,
    std::endian endianness = std::endian::big
)
noexcept

Constructs a text input stream from the given input resource and with the given encoding form and endianness. The text input stream will hold a non-owning reference to the resource, which is expected to stay valid when using the text input stream.

Parameters:
  • resource:

    The input resource to read from.

  • source_encoding_form:

    The encoding form that the text is expected to be in.

  • endianness:

    The endianness that the text is expected to be in.

text_input_stream (
    const text_input_stream& other
)

Copy-constructs a text_input_stream from an existing one.

Parameters:
  • other:

    The text_input_stream to copy from.

text_input_stream&
operator = (
    const text_input_stream& other
)

Copy-assigns a text_input_stream into this one.

Parameters:
  • other:

    The text_input_stream to copy from.

text_input_stream (
    text_input_stream&& other
)
noexcept

Move-constructs a text_input_stream from an existing one.

Parameters:
  • other:

    The text_input_stream to move from.

text_input_stream&
operator = (
    text_input_stream&& other
)
noexcept

Move-assigns a text_input_stream into this one.

Parameters:
  • other:

    The text_input_stream to move from.

encoding_form
get_encoding_form ()
const noexcept

Returns the encoding form associated with this text input stream.

void
set_encoding_form (
    encoding_form new_source_encoding_form
)
noexcept

Sets the encoding form associated with this text input stream.

Parameters:
  • new_source_encoding_form:

    The new encoding form to use with this text input stream.

char32_t
read_bom ()

Reads a code point in the current encoding form, and if it is a valid BOM (byte order mark) then the endianness of this text input stream is adjusted accordingly. Returns the read code point.

template <
    writable_raii_text_object TargetString
>
void
append_line (
    TargetString& target
)

Reads a line and appends it to the given string object.

Parameters:
  • target:

    The object to append the read line to.

template <
    writable_raii_text_object TargetString
>
void
read_line (
    TargetString& target
)

Reads a line and assigns it to the given string object.

Parameters:
  • target:

    The object to assign the read line to.

template <
    writable_raii_text_object TargetString
>
void
append_all (
    TargetString& target
)

Reads all remaining text and appends it to the given string object.

Parameters:
  • target:

    The object to append the read text to.

template <
    writable_raii_text_object TargetString
>
void
read_all (
    TargetString& target
)

Reads all remaining text and assigns it to the given string object.

Parameters:
  • target:

    The object to assign the read text to.



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.