nlib
|
The base class for output streams. This class cannot be instantiated. More...
#include "nn/nlib/OutputStream.h"
Public Types | |
enum | BufferingMode { kBufferingModeBlockBuffered = 0, kBufferingModeLineBuffered, kBufferingModeUnbuffered } |
The buffering mode for OutputStream . More... | |
Public Member Functions | |
size_t | Pos () const noexcept |
Returns the current position in the stream. More... | |
uint64_t | Pos64 () const noexcept |
Returns the current position in the stream as a 64-bit integer. More... | |
bool | Write (int b) noexcept |
Writes one byte of data to the stream. More... | |
bool | Write (const void *p, size_t n) noexcept |
Writes n bytes of data to the stream. More... | |
bool | WriteGather (const nlib_fd_iovec *iov, int iovcnt) noexcept |
Writes data from multiple non-continuous buffers to a stream. More... | |
bool | Flush () noexcept |
Flushes the stream. More... | |
bool | Close () noexcept |
Closes the stream after it has been flushed. Returns true if successful. More... | |
errno_t | GetErrorValue () const noexcept |
Gets the error value. More... | |
BufferingMode | GetBufferingMode () const noexcept |
Gets the buffering mode. | |
operator bool () const | |
Returns true if no internal error has occurred. | |
Basic Member Functions | |
constexpr | OutputStream () noexcept |
Instantiates the object with default parameters (default constructor). | |
virtual | ~OutputStream () noexcept |
Destructor. Does not do anything. | |
Functions Used From Derived Classes | |
BufferingMode | m_BufferingMode |
Stores the buffering mode. More... | |
void | ResetBuffer (void *p, size_t nbytes) noexcept |
Sets the buffer held by OutputStream . More... | |
void | SetError (errno_t e) const noexcept |
Sets an error to OutputStream . More... | |
The base class for output streams. This class cannot be instantiated.
OutputStream
class may change without notice. You can lower your risk by implementing derived classes independently whenever possible. However, if necessary, you can define derived classes by overriding the following virtual function. true
, the device must be flushed. GetWorkBuffer_
function (described below), you can call this function with NULL
specified for the p parameter. If you do that, you need to call the ResetBuffer
function and reset the OutputStream
internal buffer. EBADF
error and return false
. EIO
) and return false
. Close
function to close handles and other internal resources. At the time that the Close
function is called, the buffer referenced by the base class is guaranteed to have been emptied by the PushBuffer_
function. If the derived class has a different buffer than this, you must close the device after the data has been actually written to the device. Close_
function from the base class destructor. EBADF
error and return false
. EIO
) and return false
. is_buf_
is NULL
, OutputStream
calls this function to try to get a buffer. The return value is the pointer to the buffer. The size gets set in nbytes. The buffer itself is owned by the derived class, so the freeing of the buffer must be coded in the derived class. NULL
and set nbytes to 0
. NULL
and -1
is substituted for the value in nbytes. In that case, InputStream
uses the FillBuffer_
function to try to get a buffer. Definition at line 30 of file OutputStream.h.
The buffering mode for OutputStream
.
Definition at line 32 of file OutputStream.h.
|
noexcept |
Closes the stream after it has been flushed. Returns true
if successful.
true
when successful.false
, a process failed. Even if a process fails, you do not need to close again. If already successfully closed, the function returns true
.
|
inlinenoexcept |
Flushes the stream.
true
when successful.Definition at line 101 of file OutputStream.h.
|
inlinenoexcept |
Gets the error value.
Definition at line 103 of file OutputStream.h.
|
inlinenoexcept |
Returns the current position in the stream.
Definition at line 54 of file OutputStream.h.
|
inlinenoexcept |
Returns the current position in the stream as a 64-bit integer.
Definition at line 55 of file OutputStream.h.
|
inlineprotectednoexcept |
Sets the buffer held by OutputStream
.
[in] | p | Pointer to the buffer. |
[in] | nbytes | Buffer size. |
Definition at line 110 of file OutputStream.h.
|
inlineprotectednoexcept |
Sets an error to OutputStream
.
[in] | e | An error value. |
Definition at line 114 of file OutputStream.h.
|
inlinenoexcept |
Writes one byte of data to the stream.
[in] | b | The data to write. |
true
when successful. Definition at line 56 of file OutputStream.h.
|
inlinenoexcept |
Writes n bytes of data to the stream.
[in] | p | Pointer to the data to write. |
[in] | n | The number of bytes. |
true
when successful. Definition at line 70 of file OutputStream.h.
|
inlinenoexcept |
Writes data from multiple non-continuous buffers to a stream.
[in] | iov | Pointers to iovcnt number of buffers and the corresponding sizes. |
[in] | iovcnt | The number of iov. |
true
when successful.FileOutputStream
, this member function may write the data from the buffers one by one in order to speed up the write process. However, the write process is not guaranteed to be performed atomically, as it is when using the nlib_fd_writev
function. Definition at line 88 of file OutputStream.h.
|
protected |
Stores the buffering mode.
Definition at line 142 of file OutputStream.h.
© 2012-2017 Nintendo Co., Ltd. All rights reserved.