Reads primitive data types as binary values in a specific encoding.
Public Constructors | |
binary_reader (const xtd::string &path) | |
Initializes a new instance of the xtd::io::binary_reader class for the specified file name. | |
binary_reader (std::istream &stream) | |
Initializes a new instance of the xtd::io::binary_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 () |
Closes the xtd::io::binary_reader object and the underlying stream, and releases any system resources associated with the reader. | |
int32 | peek_char () const |
Returns the next available character and does not advance the byte or character position. | |
std::streampos | pop () |
Pop the current top position. | |
void | push (std::streampos pos=0) |
Push the current position. | |
virtual int32 | read () |
Reads characters from the underlying stream and advances the current position of the stream in accordance with the Encoding used and the specific character being read from the stream. | |
virtual size_t | read (std::vector< xtd::byte > &buffer, size_t index, size_t count) |
Reads the specified number of bytes from the stream, starting from a specified point in the byte array. | |
virtual size_t | read (std::vector< char > &buffer, size_t index, size_t count) |
Reads the specified number of characters from the stream, starting from a specified point in the character array. | |
virtual bool | read_boolean () |
Reads a boolean value from the current stream and advances the current position of the stream by one byte. | |
virtual xtd::byte | read_byte () |
Reads the next byte from the current stream and advances the current position of the stream by one byte. | |
virtual std::vector< xtd::byte > | read_bytes (size_t count) |
Reads the specified number of bytes from the current stream into a byte array and advances the current position by that number of bytes. | |
virtual char | read_char () |
Reads the next character from the current stream and advances the current position of the stream by one byte. | |
virtual std::vector< char > | read_chars (size_t count) |
Reads the specified number of characters from the current stream into a byte array and advances the current position by that number of bytes. | |
virtual double | read_double () |
Reads an 8-byte floating point value from the current stream and advances the current position of the stream by eight bytes. | |
virtual int16 | read_int16 () |
Reads a 2-byte signed integer from the current stream and advances the current position of the stream by two bytes. | |
virtual int32 | read_int32 () |
Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes. | |
virtual int64 | read_int64 () |
Reads a 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes. | |
virtual sbyte | read_sbyte () |
Reads the a signed byte from the current stream and advances the current position of the stream by one byte. | |
virtual float | read_single () |
Reads an 4-byte floating point value from the current stream and advances the current position of the stream by four bytes. | |
virtual string | read_string () |
Reads a string from the current stream. The string is prefixed with the length. | |
virtual uint16 | read_uint16 () |
Reads a 2-byte unsigned integer from the current stream and advances the current position of the stream by two bytes. | |
virtual uint32 | read_uint32 () |
Reads a 4-byte unsigned integer from the current stream and advances the current position of the stream by four bytes. | |
virtual uint64 | read_uint64 () |
Reads a 8-byte unsigned integer from the current stream and advances the current position of the stream by eight bytes. | |
void | rewind () |
Rewind stream. | |
void | seekg (std::streamoff off, std::ios_base::seekdir dir=std::ios_base::cur) |
Change the position of the readers stream. | |
std::streampos | tellg () |
Tell the current seek position of the readers stream;. | |
Additional Inherited Members | |
Public Member Functions inherited from xtd::object | |
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 size_t | 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<typename 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 Public Member Functions inherited from xtd::object | |
template<typename object_a_t , typename 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<typename object_a_t , typename 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. | |
|
explicit |
Initializes a new instance of the xtd::io::binary_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 xtd::io::binary_reader class for the specified stream.
stream | The stream to be read. |
std::optional< std::reference_wrapper< std::istream > > xtd::io::binary_reader::base_stream | ( | ) | const |
Returns the underlying stream.
bool xtd::io::binary_reader::end_of_stream | ( | ) | const |
Gets a value that indicates whether the current stream position is at the end of the stream.
void xtd::io::binary_reader::close | ( | ) |
Closes the xtd::io::binary_reader object and the underlying stream, and releases any system resources associated with the reader.
int32 xtd::io::binary_reader::peek_char | ( | ) | const |
Returns the next available character and does not advance the byte or character position.
xtd::io::io_exception | An I/O error occurred. |
std::streampos xtd::io::binary_reader::pop | ( | ) |
Pop the current top position.
void xtd::io::binary_reader::push | ( | std::streampos | pos = 0 | ) |
Push the current position.
pos | The stream position to be push/saved relative to ios_base::beg direction |
|
virtual |
Reads characters from the underlying stream and advances the current position of the stream in accordance with the Encoding used and the specific character being read from the stream.
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads the specified number of bytes from the stream, starting from a specified point in the byte array.
buffer | The buffer to read data into. |
index | The starting point in the buffer at which to begin reading into the buffer. |
count | The number of bytes to read. |
xtd::argument_exception | The buffer length minus index is less than count. |
xtd::io_io_exception | An I/O error occurred. |
|
virtual |
Reads the specified number of characters from the stream, starting from a specified point in the character array.
buffer | The buffer to read data into. |
index | The starting point in the buffer at which to begin reading into the buffer. |
count | The number of characters to read. |
xtd::argument_exception | The buffer length minus index is less than count. |
xtd::io_io_exception | An I/O error occurred. |
|
virtual |
Reads a boolean value from the current stream and advances the current position of the stream by one byte.
EndOfStreamException | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads the next byte from the current stream and advances the current position of the stream by one byte.
EndOfStreamException | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads the specified number of bytes from the current stream into a byte array and advances the current position by that number of bytes.
count | The number of bytes to read. This value must be 0 or a non-negative number or an exception will occur. |
EndOfStreamException | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads the next character from the current stream and advances the current position of the stream by one byte.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads the specified number of characters from the current stream into a byte array and advances the current position by that number of bytes.
count | The number of characters to read. This value must be 0 or a non-negative number or an exception will occur. |
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads an 8-byte floating point value from the current stream and advances the current position of the stream by eight bytes.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads a 2-byte signed integer from the current stream and advances the current position of the stream by two bytes.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads a 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads the a signed byte from the current stream and advances the current position of the stream by one byte.
EndOfStreamException | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads an 4-byte floating point value from the current stream and advances the current position of the stream by four bytes.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads a string from the current stream. The string is prefixed with the length.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads a 2-byte unsigned integer from the current stream and advances the current position of the stream by two bytes.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads a 4-byte unsigned integer from the current stream and advances the current position of the stream by four bytes.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
|
virtual |
Reads a 8-byte unsigned integer from the current stream and advances the current position of the stream by eight bytes.
xtd::io::end_of_stream_exception | The end of the stream is reached. |
xtd::io::io_exception | An I/O error occurred. |
void xtd::io::binary_reader::rewind | ( | ) |
Rewind stream.
void xtd::io::binary_reader::seekg | ( | std::streamoff | off, |
std::ios_base::seekdir | dir = std::ios_base::cur |
||
) |
Change the position of the readers stream.
off | The offset being added to the direction |
dir | The seek direction. If ommited defaults to ios_base::cur |
std::streampos xtd::io::binary_reader::tellg | ( | ) |
Tell the current seek position of the readers stream;.