libcommonc++  0.7
Pipe Class Reference

A unidirectional stream pipe. More...

#include <Pipe.h++>

Public Member Functions

 Pipe ()
 Constructor. More...
 
 ~Pipe ()
 Destructor. More...
 
void open ()
 Create and open the pipe. More...
 
void close ()
 Close the pipe. More...
 
bool isOpen () const
 Test if the pipe is open. More...
 
ssize_t read (byte_t *buf, size_t count)
 Read raw data from the read end of the pipe. More...
 
ssize_t write (const byte_t *buf, size_t count)
 Write raw data to the write end of the pipe. More...
 
void setBlocking (bool blocking)
 Set the blocking state of the pipe. More...
 
FileHandle getReadDescriptor () const
 Get the file descriptor for the read end of the pipe. More...
 
FileHandle getWriteDescriptor () const
 Get the file descriptor for the write end of the pipe. More...
 

Detailed Description

A unidirectional stream pipe.

The pipe has two file descriptors, one for reading, and one for writing.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ Pipe()

Pipe ( )

Constructor.

The actual pipe is not created until open() is called.

◆ ~Pipe()

~Pipe ( )

Destructor.

Closes the pipe if it is open.

Member Function Documentation

◆ close()

void close ( )

Close the pipe.

◆ getReadDescriptor()

FileHandle getReadDescriptor ( ) const
inline

Get the file descriptor for the read end of the pipe.

◆ getWriteDescriptor()

FileHandle getWriteDescriptor ( ) const
inline

Get the file descriptor for the write end of the pipe.

◆ isOpen()

bool isOpen ( ) const

Test if the pipe is open.

◆ open()

void open ( )

Create and open the pipe.

Exceptions
IOExceptionIf an I/O error occurs.

◆ read()

ssize_t read ( byte_t buf,
size_t  count 
)

Read raw data from the read end of the pipe.

Parameters
bufThe buffer to read into.
countThe number of bytes to read.
Returns
The number of bytes actually read, or a negative value if an error occurs.

◆ setBlocking()

void setBlocking ( bool  blocking)

Set the blocking state of the pipe.

Parameters
blockingA flag indicating whether the pipe should be blocking or non-blocking.
Exceptions
IOExceptionIf an I/O error occurs.

◆ write()

ssize_t write ( const byte_t buf,
size_t  count 
)

Write raw data to the write end of the pipe.

Parameters
bufThe buffer to write.
countThe number of bytes to write.
Returns
The number of bytes actually written, or a negative value if an error occurs.

The documentation for this class was generated from the following files: