Generic output stream interface.
#include <UTIOStreams.h>
Public Member Functions | |
virtual | ~OutputStream_t () |
virtual Status_t | Write (const byte *buffer, int bytes_to_write, bool force_write_all=true)=0 |
virtual Status_t | WriteLine (const String_t &line, line_ending_type_t line_ending=eLINEENDING_native) |
virtual Status_t | WriteLine (const utf8 *line, line_ending_type_t line_ending=eLINEENDING_native) |
virtual Status_t | WriteLine (stringliteral *line, line_ending_type_t line_ending=eLINEENDING_native) |
virtual Status_t | Position (out fileoff_t *position)=0 |
virtual Status_t | Seek (fileoff_t position)=0 |
virtual Status_t | SeekRelative (fileoff_t delta) |
virtual Status_t | Flush ()=0 |
virtual Status_t | Close ()=0 |
Definition at line 149 of file UTIOStreams.h.
virtual OutputStream_t::~OutputStream_t | ( | ) | [virtual] |
Pure virtual destructor, used exclusively to allow an output stream to be deleted by the owner of a pointer merely to OutputStream_t. Unless an error had occurred previously, an output stream must be closed before deleting it.
virtual Status_t OutputStream_t::Write | ( | const byte * | buffer, | |
int | bytes_to_write, | |||
bool | force_write_all = true | |||
) | [pure virtual] |
Writes up to bytes_to_write bytes from buffer, and returns the number of bytes written as a success status indication, or an error status. If an error status is returned, some data may have been written, and it is not possible to determine how much data was written.
For nonblocking streams, if force_write_all is true, Write will block until all data has been written.
If force_write_all is true, either all data will be written or an error will be returned. An end of file condition for write is not expected for regular files, but if reaching end-of-file without writing all of the specified data is not to be considered an error, force_write_all must be set to false.
If force_write_all is false, in the absence of any other error, the returned status will be the number of bytes written, which may be less than what was requested. An end of file condition for write is not expected for regular files, but if end of the stream is reached with no data having been written, the returned status will be eERR_end_of_file.
Some OutputStream_t subclasses can implement nonblocking I/O, for which the request will proceed to completion asynchronously. If force_write_all is false, such classes return eERR_async_io_in_progress to indicate that the data is being written asynchronously, in which case the next call to Write must exactly match the one which returned eERR_async_io_in_progress, and the buffer must remain valid until the next call. Also in that case, no other stream operations are permissible until the previous request has been repeated and succeeded.
Implemented in BufferedFile_t, File_t, and BufferIOStream_t.
virtual Status_t OutputStream_t::WriteLine | ( | const String_t & | line, | |
line_ending_type_t | line_ending = eLINEENDING_native | |||
) | [virtual] |
Writes a line of text, converting line endings if necessary to the specified format. If the string contains line endings, they will be converted to the specified format. If the string ends with a line ending, an additional one will not be added to the end.
Reimplemented in BufferedFile_t.
virtual Status_t OutputStream_t::WriteLine | ( | const utf8 * | line, | |
line_ending_type_t | line_ending = eLINEENDING_native | |||
) | [virtual] |
Writes a line of text, converting line endings if necessary to the specified format. If the string contains line endings, they will be converted to the specified format. If the string ends with a line ending, an additional one will not be added to the end.
Reimplemented in BufferedFile_t.
virtual Status_t OutputStream_t::WriteLine | ( | stringliteral * | line, | |
line_ending_type_t | line_ending = eLINEENDING_native | |||
) | [virtual] |
Writes a line of text, converting line endings if necessary to the specified format. If the string contains line endings, they will be converted to the specified format. If the string ends with a line ending, an additional one will not be added to the end.
Reimplemented in BufferedFile_t.
Returns the position in the output stream through the position output parameter unless an error occurs, in which case an error status is returned in the Status_t return value. For streams of infinite length with a signed fileoff_t type on the target platform, negative values are legitimate, with the largest negative value representing wraparound from the largest positive value.
Implemented in BufferedFile_t, File_t, IOStream_t, and BufferIOStream_t.
Repositions the output stream to the requested position. Note that not all types of streams support seeking. For streams of infinite length with a signed fileoff_t type on the target platform, negative values are legitimate, with the largest negative value representing wraparound from the largest positive value. If an error occurs, an error status will be returned.
Implemented in BufferedFile_t, File_t, IOStream_t, and BufferIOStream_t.
Repositions the output stream to the requested position, relative to the current position. Note that not all types of streams support seeking. If an error occurs, an error status will be returned.
Reimplemented in IOStream_t, and BufferIOStream_t.
virtual Status_t OutputStream_t::Flush | ( | ) | [pure virtual] |
Flushes any data buffered but not written to whatever physical layer the output stream represents. Flushing is not relevant to all types of streams, but those to which the Flush operation is irrelevant will return a success status indication. If an error occurs, an error status will be returned.
Implemented in BufferedFile_t, File_t, and BufferIOStream_t.
virtual Status_t OutputStream_t::Close | ( | ) | [pure virtual] |
Closes this output stream and releases any resources associated with it. Any unflushed data needing to be written will be written. If an error occurs in either flushing or closing the output stream, an error status will be returned, but regardless the stream can be considered closed. If an error status is returned, data may have been lost.
Implemented in BufferedFile_t, File_t, IOStream_t, and BufferIOStream_t.