xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Public Member Functions | List of all members
xtd::io::stream_reader Class Reference

#include <stream_reader.h>

Definition

Represents a reader that can read a sequential series of characters.

Namespace
xtd::io
Library
xtd.core

Public Member Functions

 stream_reader (const xtd::ustring &path)
 Initializes a new instance of the stream_reader class for the specified file name. More...
 
 stream_reader (std::istream &stream)
 Initializes a new instance of the stream_reader class for the specified stream. More...
 
std::optional< std::reference_wrapper< std::istream > > base_stream () const
 Returns the underlying stream. More...
 
void close () override
 Closes the stream_reader object and the underlying stream, and releases any system resources associated with the reader. More...
 
bool end_of_stream () const
 Gets a value that indicates whether the current stream position is at the end of the stream. More...
 
int32_t 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. More...
 
int32_t read () override
 Reads the next character from the input stream and advances the character position by one character. More...
 
- Public Member Functions inherited from xtd::io::text_reader
virtual size_t read (std::vector< 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. More...
 
virtual size_t read_block (std::vector< 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. More...
 
virtual xtd::ustring read_line ()
 Reads a line of characters from the current stream and returns the data as a string. More...
 
virtual xtd::ustring read_to_end ()
 Reads all characters from the current position to the end of the text_reader and returns them as one string. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from xtd::io::text_reader
static null_text_readernull () noexcept
 Provides a text_reader with no data to read from. More...
 
static synchronized_text_reader synchronised (text_reader &reader) noexcept
 Creates a thread-safe (synchronized) wrapper around the specified text_reader object. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 
- Protected Member Functions inherited from xtd::io::text_reader
 text_reader ()=default
 Initializes a new instance of the xtd::io::text_reader class. More...
 

Constructor & Destructor Documentation

◆ stream_reader() [1/2]

xtd::io::stream_reader::stream_reader ( const xtd::ustring path)

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)

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

Parameters
streamThe stream to be read.

Member Function Documentation

◆ base_stream()

std::optional<std::reference_wrapper<std::istream> > xtd::io::stream_reader::base_stream ( ) const

Returns the underlying stream.

Returns
The underlying stream.

◆ close()

void xtd::io::stream_reader::close ( )
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.

◆ end_of_stream()

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.

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

◆ peek()

int32_t xtd::io::stream_reader::peek ( ) const
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.

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()

int32_t xtd::io::stream_reader::read ( )
overridevirtual

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: