Implements a xtd::io::text_reader that reads characters from a byte stream.
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 | |
std::optional< std::reference_wrapper< std::istream > > | base_stream () const |
Returns the underlying stream. | |
bool | end_of_stream () const |
Gets a value that indicates whether the current stream position is at the end of the stream. | |
Public Methods | |
void | close () override |
Closes the stream_reader object and the underlying stream, and releases any system resources associated with the reader. | |
int32 | peek () const 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. | |
int32 | read () override |
Reads the next character from the input stream and advances the character position by one character. | |
Additional Inherited Members | |
![]() | |
virtual size_t | read (xtd::span< char > &buffer) |
Reads the characters from the current reader and writes the data to the specified buffer. | |
virtual size_t | read (xtd::array< char > &buffer, size_t index, size_t count) |
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 size_t | read_block (xtd::span< char > &buffer) |
Reads the characters from the current stream and writes the data to a buffer. | |
virtual size_t | read_block (xtd::array< char > &buffer, size_t index, size_t count) |
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 xtd::string | read_line () |
Reads a line of characters from the current stream and returns the data as a string. | |
virtual xtd::string | read_to_end () |
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::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
virtual xtd::string | to_string () const noexcept |
Returns a xtd::string that represents the current object. | |
![]() | |
static null_text_reader & | null () noexcept |
Provides a text_reader with no data to read from. | |
static synchronized_text_reader | synchronised (text_reader &reader) noexcept |
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. | |
|
explicit |
Initializes a new instance of the stream_reader class for the specified file name.
path | The complete file path to be read. |
xtd::argument_exception | path 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. |
|
explicit |
Initializes a new instance of the stream_reader class for the specified stream.
stream | The stream to be read. |
std::optional< std::reference_wrapper< std::istream > > xtd::io::stream_reader::base_stream | ( | ) | const |
bool xtd::io::stream_reader::end_of_stream | ( | ) | const |
Gets a value that indicates whether the current stream position is at the end of the stream.
true
if the current stream position is at the end of the stream; otherwise false
.
|
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.
|
overridevirtual |
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.
Reimplemented from xtd::io::text_reader.
|
overridevirtual |
Reads the next character from the input stream and advances the character position by one character.
Reimplemented from xtd::io::text_reader.