|
Jameo Core Library
|
The Stream class is an abstraction class for manipulating data streams through a unified interface. The stream itself can be a file, a byte array, a network interface, or anything else. More...
Public Member Functions | |
| Stream () | |
| Constructor. | |
| virtual size_t | size () const =0 |
| Returns the length of the stream. | |
| virtual Status | open (FileMode mode)=0 |
| Opens the stream for read or write operations. | |
| virtual bool | isOpen ()=0 |
| Returns whether the file is open or not. | |
| virtual bool | canRead () const =0 |
| Checks if the file/stream can be read. | |
| virtual void | close ()=0 |
| Closes the stream if it was previously opened and releases any system resources. | |
| virtual size_t | read (uint8 *buffer, size_t length)=0 |
| Reads a maximum of length bytes into the array. | |
| virtual size_t | readFully (ByteArray &buffer, size_t length)=0 |
| Reads a maximum of length bytes into the array. | |
| size_t | readFully (ByteArray &buffer) |
| Reads a maximum of length bytes into the array. | |
| virtual void | seek (size_t position)=0 |
| Moves the file cursor to the desired position, counted from the beginning of the file (0-based index). | |
| virtual void | move (ssize_t offset)=0 |
| Moves the file cursor to the desired position, counted from the current position. | |
| virtual size_t | position ()=0 |
| Returns the current cursor position in the file. | |
| virtual size_t | write (const uint8 *buffer, size_t length)=0 |
| Writes a buffer to the output file. | |
| size_t | write (const int8 *buffer, size_t length) |
| Writes a buffer to the output file. | |
| size_t | write (const String &string) |
| Writes a string to the output file. The encoding is the default encoding (UTF-8). NOT AS A C-STRING! | |
Public Member Functions inherited from jm::Object | |
| Object () noexcept | |
| Constructor. | |
| virtual | ~Object () noexcept |
| Destructor. | |
| void | release () noexcept |
| Decreases the reference counter and releases the object immediately when the reference counter becomes 0. | |
| Object * | retain () noexcept |
| Increases the reference counter of this object by 1. | |
| Object * | autorelease () noexcept |
| Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object. | |
| int32 | referenceCount () const noexcept |
| Returns the value of the reference counter. | |
| virtual bool | equals (const Object *other) const |
| Comparison of objects. | |
| virtual String | displayName () const |
| Returns the display name of the object intended to present to a user. | |
| virtual void | printDiffInfo (DiffOperation operation, Object *other) const |
| Output method for outputting the diff results for the diff algorithm. | |
| void | setHighBit (bool status) noexcept |
| bool | highBit () const noexcept |
The Stream class is an abstraction class for manipulating data streams through a unified interface. The stream itself can be a file, a byte array, a network interface, or anything else.
The Stream class provides methods for reading and writing data, as well as managing the stream's state.
| jm::Stream::Stream | ( | ) |
Constructor.
|
pure virtual |
Checks if the file/stream can be read.
Implemented in jm::File, jm::MemoryStream, and jm::Resource.
|
pure virtual |
Closes the stream if it was previously opened and releases any system resources.
This method closes the stream if it was previously opened and releases any system resources associated with it.
Implemented in jm::File, jm::MemoryStream, and jm::Resource.
|
pure virtual |
Returns whether the file is open or not.
This method returns a boolean value indicating whether the file is currently open or not.
true if the file is open, false otherwise. Implemented in jm::File, jm::MemoryStream, and jm::Resource.
|
pure virtual |
Moves the file cursor to the desired position, counted from the current position.
This method moves the file cursor to the specified position, counted from the current position.
Implemented in jm::File, jm::MemoryStream, and jm::Resource.
Opens the stream for read or write operations.
| mode | The mode to open the stream. |
This method opens the stream for read or write operations based on the specified mode.
Implemented in jm::File, jm::MemoryStream, and jm::Resource.
|
pure virtual |
Returns the current cursor position in the file.
This method returns the current cursor position in the file.
Implemented in jm::File, jm::MemoryStream, and jm::Resource.
|
pure virtual |
Reads a maximum of length bytes into the array.
For large blocks, it is possible that not all bytes are read because it is still waiting for data. In this case, only a portion may be returned. If you want to ensure that all data is read, you should call readFully().
Implemented in jm::MemoryStream, jm::Resource, and jm::File.
| size_t jm::Stream::readFully | ( | ByteArray & | buffer | ) |
Reads a maximum of length bytes into the array.
| buffer | The buffer to read the data from. |
|
pure virtual |
Reads a maximum of length bytes into the array.
For large blocks, it is possible that not all bytes are read because it is still waiting for data. In this case, only a portion may be returned. If you want to ensure that all data is read, you should call readFully().
| buffer | The buffer to read the data from. |
| length | The maximum number of bytes to read. |
Implemented in jm::File, jm::MemoryStream, and jm::Resource.
|
pure virtual |
Moves the file cursor to the desired position, counted from the beginning of the file (0-based index).
This method moves the file cursor to the specified position, counted from the beginning of the file.
Implemented in jm::File, jm::MemoryStream, and jm::Resource.
|
pure virtual |
Returns the length of the stream.
This method returns the length of the stream in bytes.
Implemented in jm::File, jm::MemoryStream, and jm::Resource.
| size_t jm::Stream::write | ( | const int8 * | buffer, |
| size_t | length | ||
| ) |
Writes a buffer to the output file.
This method writes the contents of the buffer to the output file.
| buffer | The buffer containing the data to be written. |
| length | The number of bytes to write from the buffer. |
| size_t jm::Stream::write | ( | const String & | string | ) |
Writes a string to the output file. The encoding is the default encoding (UTF-8). NOT AS A C-STRING!
This method writes the specified string to the output file using the default encoding, which is UTF-8. The string should not be passed as a C-string.
|
pure virtual |
Writes a buffer to the output file.
This method writes the contents of the buffer to the output file.
| buffer | The buffer containing the data to be written. |
| length | The number of bytes to write from the buffer. |
Implemented in jm::File, jm::MemoryStream, and jm::Resource.