OutPipe is a class for writing output to an arbitrary destination such as a file, network socket,
or encryption/compression codec. It's often used as the underlying output destination of an
OutPipe is a lower-level class than
OutStream and is more akin to a Unix file descriptor. When
OutPipe writes to a file or network socket, each call to
write() invokes a system call to
the OS kernel. Therefore, when writing directly to an
OutPipe, it's best to write medium-to-large
quantities of data (say, several KB) at a time in order to minimize system call overhead.
Also included from
template <typename T>
OutPipeto a derived type such as
OutPipe_Winsockin order to access additional functions or data members. A runtime check is performed to ensure the cast is valid.
Attempts to write the entire contents of
bufto the output destination. This call may block depending on the state of the
OutPipe. For example, if the
OutPipeis a network socket or a pipe, and the process on the other end is not reading quickly enough,
write()may block. Returns
trueif successful. Return
falseif the write fails such as when attempting to a network socket that was closed prematurely.
bool flush(bool toDevice = true)[code]
Flushes any application-level memory buffers in the same manner as
flushMem(), then performs an implementation-specific device flush if
true. For example, if
true, this will call
fsync()on when writing to a POSIX file descriptor or
FlushFileBuffers()when writing to a Windows file handle. Returns
trueunless there's an error in the implementation-specific device flush.
Flushes any application-level memory buffers maintained by the
OutPipewill be flushed to their destination. Appropriate to use when the
OutPipeis a line feed filter or any kind of application-level conversion, compression or encryption filter.
u64 seek(s64 pos, SeekDir seekDir)[code]
If the output destination is seekable, seeks to the specified file offset and returns the current file offset. To get the current file offset without changing it, call