InPipe is a class for reading input from an arbitrary data source such as a file, network socket,
or encryption/compression codec. It's often used as the underlying input source of an
InPipe is a lower-level class than
InStream and is more akin to a Unix file descriptor. When the
InPipe reads from a file or network socket, each call to
read() invokes a system
call to the OS kernel. Therefore, when reading directly from an
InPipe, it's best to read
medium-to-large quantities of data (say, several KB) at a time in order to minimize system call
Also included from
template <typename T>
InPipeto a derived type such as
InPipe_Winsockin order to access additional functions or data members. A runtime check is performed to ensure the cast is valid.
Attempts to read some data into
buffrom the input source. If the
InPipeis waiting for data, this function will block until some data arrives. Returns the actual number of bytes read, which might be less than the size of
buf. Returns 0 if EOF/error is encountered.
Attempts to completely fill
bufwith data from the input source. If the
InPipeis waiting for data, this function will block until
bufis completely filled. Returns
trueif successful. [FIXME: Reconsider how incomplete reads are handled]
u64 getFileSize() const[code]
InPipeis reading from a file, returns the size of the file in bytes.