xtd 0.2.0
Loading...
Searching...
No Matches
xtd::io::stream_reader Class Reference
Inheritance diagram for xtd::io::stream_reader:
xtd::io::text_reader xtd::object

Definition

Implements a xtd::io::text_reader that reads characters from a byte stream.

stream_reader(const xtd::string &path)
Initializes a new instance of the stream_reader class for the specified file name.
Represents a reader that can read a sequential series of characters.
Definition text_reader.hpp:38
#define core_export_
Define shared library export.
Definition core_export.hpp:13
Inheritance
xtd::io::text_readerxtd::io::stream_reader
Header
#include <xtd/io/stream_reader>
Namespace
xtd::io
Library
xtd.core
Examples
test_forms.cpp.

Public Constructors

 stream_reader (const xtd::string &path)
 Initializes a new instance of the stream_reader class for the specified file name.
 
 stream_reader (std::istream &stream)
 Initializes a new instance of the stream_reader class for the specified stream.
 

Public Properties

auto base_stream () const -> std::optional< xtd::ref< std::istream > >
 Returns the underlying stream.
 
auto end_of_stream () const -> bool
 Gets a value that indicates whether the current stream position is at the end of the stream.
 

Public Methods

auto close () -> void override
 Closes the stream_reader object and the underlying stream, and releases any system resources associated with the reader.
 
auto peek () const -> xtd::int32 override
 Reads the next character without changing the state of the reader or the character source. Returns the next available character without actually reading it from the input stream.
 
auto read () -> xtd::int32 override
 Reads the next character from the input stream and advances the character position by one character.
 

Additional Inherited Members

virtual auto read (xtd::span< char > &buffer) -> xtd::size
 Reads the characters from the current reader and writes the data to the specified buffer.
 
virtual auto read (xtd::array< char > &buffer, xtd::size index, xtd::size count) -> xtd::size
 Reads a specified maximum number of characters from the current text reader and writes the data to a buffer, beginning at the specified index.
 
virtual auto read_block (xtd::span< char > &buffer) -> xtd::size
 Reads the characters from the current stream and writes the data to a buffer.
 
virtual auto read_block (xtd::array< char > &buffer, xtd::size index, xtd::size count) -> xtd::size
 Reads a specified maximum number of characters from the current text reader and writes the data to a buffer, beginning at the specified index.
 
virtual auto read_line () -> xtd::string
 Reads a line of characters from the current stream and returns the data as a string.
 
virtual auto read_to_end () -> xtd::string
 Reads all characters from the current position to the end of the text_reader and returns them as one string.
 
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual xtd::size get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<class object_t>
xtd::unique_ptr_object< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
virtual xtd::string to_string () const
 Returns a xtd::string that represents the current object.
 
static null_text_readernull () noexcept
 Provides a text_reader with no data to read from.
 
static auto synchronised (text_reader &reader) noexcept -> synchronized_text_reader
 Creates a thread-safe (synchronized) wrapper around the specified text_reader object.
 
template<class object_a_t, class object_b_t>
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<class object_a_t, class object_b_t>
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 
 text_reader ()=default
 Initializes a new instance of the xtd::io::text_reader class.
 

Constructor & Destructor Documentation

◆ stream_reader() [1/2]

xtd::io::stream_reader::stream_reader ( const xtd::string & path)
explicit

Initializes a new instance of the stream_reader class for the specified file name.

Parameters
pathThe complete file path to be read.
Exceptions
xtd::argument_exceptionpath is a zero-length string, contains only white space, or contains one or more invalid characters as defined by xtd::io::path::invalid_path_chars.

◆ stream_reader() [2/2]

xtd::io::stream_reader::stream_reader ( std::istream & stream)
explicit

Initializes a new instance of the stream_reader class for the specified stream.

Parameters
streamThe stream to be read.

Member Function Documentation

◆ base_stream()

auto xtd::io::stream_reader::base_stream ( ) const -> std::optional< xtd::ref< std::istream > >
nodiscard

Returns the underlying stream.

Returns
The underlying stream.

◆ end_of_stream()

auto xtd::io::stream_reader::end_of_stream ( ) const -> bool
nodiscard

Gets a value that indicates whether the current stream position is at the end of the stream.

Returns
true if the current stream position is at the end of the stream; otherwise false.
Examples
test_forms.cpp.

◆ close()

auto xtd::io::stream_reader::close ( ) -> void
overridevirtual

Closes the stream_reader object and the underlying stream, and releases any system resources associated with the reader.

Reimplemented from xtd::io::text_reader.

◆ peek()

auto xtd::io::stream_reader::peek ( ) const -> xtd::int32
nodiscardoverridevirtual

Reads the next character without changing the state of the reader or the character source. Returns the next available character without actually reading it from the input stream.

Returns
An integer representing the next character to be read, or EOF if no more characters are available or the stream does not support seeking.

Reimplemented from xtd::io::text_reader.

◆ read()

auto xtd::io::stream_reader::read ( ) -> xtd::int32
nodiscardoverridevirtual

Reads the next character from the input stream and advances the character position by one character.

Returns
The next character from the input stream, or EOF if no more characters are available.

Reimplemented from xtd::io::text_reader.


The documentation for this class was generated from the following file: