.TH "shevek::fd" 3 "Wed Jul 9 2014" "libshevek" \" -*- nroff -*- .ad l .nh .SH NAME shevek::fd \- .PP The fd class is a generic wrapper for a file descriptor to use it in the Glib event loop\&. .SH SYNOPSIS .br .PP .PP \fC#include \fP .PP Inherits \fBshevek::refbase\fP\&. .PP Inherited by \fBshevek::file\fP, and \fBshevek::socket\fP\&. .SS "Public Types" .in +1c .ti -1c .RI "typedef sigc::slot0< void > \fBread_custom_t\fP" .br .RI "\fIFunction pointer to call when data is read from fd\&. \fP" .ti -1c .RI "typedef sigc::slot1< bool, .br std::string & > \fBread_t\fP" .br .RI "\fIFunction pointer to call when fd is ready for reading\&. \fP" .ti -1c .RI "typedef sigc::slot1< void, .br std::string const & > \fBread_lines_t\fP" .br .RI "\fIFunction pointer to call when a complete line has arrived\&. \fP" .ti -1c .RI "typedef sigc::slot0< void > \fBerror_t\fP" .br .RI "\fIFunction pointer to call when an error occurs\&. \fP" .ti -1c .RI "typedef sigc::slot0< void > \fBwrite_done_t\fP" .br .RI "\fIFunction pointer to call when data has been written\&. \fP" .ti -1c .RI "typedef sigc::slot1< void, .br std::string & > \fBfilter_t\fP" .br .RI "\fIFunction pointer to filter in and outgoing data\&. \fP" .ti -1c .RI "typedef sigc::slot0< void > \fBflush_t\fP" .br .RI "\fIFunction pointer to signal that all data is flushed after unread () \fP" .in -1c .SS "Public Member Functions" .in +1c .ti -1c .RI "void \fBread_custom\fP (\fBread_custom_t\fP cb)" .br .RI "\fIPoll for read with a custom callback to poll\&. \fP" .ti -1c .RI "void \fBread_priority_custom\fP (\fBread_custom_t\fP cb)" .br .RI "\fIPoll for priority read with a custom callback to poll\&. \fP" .ti -1c .RI "void \fBread\fP (\fBread_t\fP cb)" .br .RI "\fIPoll for read and set read callback (resets custom callback) \fP" .ti -1c .RI "void \fBread_priority\fP (\fBread_t\fP cb)" .br .RI "\fIPoll for priority read and set read callback (resets custom callback) \fP" .ti -1c .RI "void \fBread_lines\fP (\fBread_lines_t\fP cb)" .br .RI "\fIPoll for read and set read lines callback (resets custom and read callback)\&. Polls for priority read as well\&. \fP" .ti -1c .RI "void \fBunread\fP (bool flush_buffer=false, \fBflush_t\fP cb=\fBflush_t\fP())" .br .RI "\fIStop polling for read (including priority read)\&. \fP" .ti -1c .RI "void \fBwrite\fP (std::string const &data, \fBwrite_done_t\fP cb=\fBwrite_done_t\fP())" .br .RI "\fIWrite data and set a callback (defaults to none)\&. \fP" .ti -1c .RI "void \fBwrite_raw\fP (std::string const &data, \fBwrite_done_t\fP cb=\fBwrite_done_t\fP())" .br .RI "\fIWrite data, ignoring the filter, and set a callback (defaults to none)\&. \fP" .ti -1c .RI "bool \fBwrite_block\fP (\fBrelative_time\fP timeout=\fBrelative_time\fP(-1, 0))" .br .RI "\fIBlock until write buffer is empty\&. \fP" .ti -1c .RI "std::string & \fBread_block\fP (\fBrelative_time\fP timeout=\fBrelative_time\fP(-1, 0))" .br .RI "\fIBlock until data is read, try writing if there is a write buffer\&. \fP" .ti -1c .RI "std::string \fBread_line_block\fP (\fBrelative_time\fP timeout=\fBrelative_time\fP(-1, 0))" .br .RI "\fICall read_block until a line has been read, or the timeout expires\&. \fP" .ti -1c .RI "void \fBset_fd\fP (int \fBfd\fP)" .br .RI "\fIChange file descriptor\&. \fP" .ti -1c .RI "void \fBin_filter\fP (\fBfilter_t\fP cb)" .br .RI "\fIIf set, incoming data is filtered through this callback before it is put into the buffer\&. \fP" .ti -1c .RI "void \fBout_filter\fP (\fBfilter_t\fP cb)" .br .RI "\fIIf set, outgoing data is filtered through this callback before it is sent to the file descriptor\&. \fP" .ti -1c .RI "void \fBset_error\fP (\fBerror_t\fP cb)" .br .RI "\fISet a callback for all error types at once\&. \fP" .ti -1c .RI "void \fBset_poll_error\fP (\fBerror_t\fP cb)" .br .RI "\fICallback for errors from poll\&. \fP" .ti -1c .RI "void \fBset_read_error\fP (\fBerror_t\fP cb)" .br .RI "\fICallback for errors from read\&. \fP" .ti -1c .RI "void \fBset_write_error\fP (\fBerror_t\fP cb)" .br .RI "\fICallback for errors from write\&. \fP" .ti -1c .RI "void \fBset_eof\fP (\fBerror_t\fP cb)" .br .RI "\fICallback for end of file\&. \fP" .ti -1c .RI "void \fBread_reset\fP ()" .br .RI "\fIStop reading, delete the buffer\&. \fP" .ti -1c .RI "void \fBwrite_reset\fP ()" .br .RI "\fIStop writing, delete the buffer\&. \fP" .ti -1c .RI "void \fBreset\fP ()" .br .RI "\fIStop reading and writing, delete the buffers\&. \fP" .ti -1c .RI "int \fBget_fd\fP () const " .br .RI "\fIGet the fd\&. This function should mostly be used by derived classes\&. \fP" .ti -1c .RI "Glib::RefPtr< Glib::MainContext > \fBget_main_context\fP ()" .br .RI "\fIGet the main context\&. Also mostly used by derived classes\&. \fP" .in -1c .SS "Static Public Member Functions" .in +1c .ti -1c .RI "static Glib::RefPtr< \fBfd\fP > \fBcreate\fP (int value=-1, Glib::RefPtr< Glib::MainContext > main=Glib::MainContext::get_default())" .br .RI "\fICreate a new fd\&. \fP" .in -1c .SS "Protected Member Functions" .in +1c .ti -1c .RI "\fBfd\fP (int value, Glib::RefPtr< Glib::MainContext > main)" .br .RI "\fIConstructor\&. \fP" .ti -1c .RI "\fB~fd\fP ()" .br .RI "\fIDestructor\&. \fP" .in -1c .SH "Detailed Description" .PP The fd class is a generic wrapper for a file descriptor to use it in the Glib event loop\&. .SH "Member Function Documentation" .PP .SS "void shevek::fd::read (\fBread_t\fPcb)" .PP Poll for read and set read callback (resets custom callback) If no callback is set for priority read, this callback is used for that as well\&. .SS "std::string& shevek::fd::read_block (\fBrelative_time\fPtimeout = \fC\fBrelative_time\fP(-1, 0)\fP)" .PP Block until data is read, try writing if there is a write buffer\&. Return read data as reference to buffer\&. (callback is not called) Returns immediately if buffer is not empty\&. Priority read buffer and normal read buffer are both checked\&. This will block at most until the timeout is reached, if it is positive\&. .SS "void shevek::fd::read_custom (\fBread_custom_t\fPcb)" .PP Poll for read with a custom callback to poll\&. If no callback is set for priority read, this callback is used for that as well\&. .SS "void shevek::fd::set_error (\fBerror_t\fPcb)" .PP Set a callback for all error types at once\&. This is used for any error for which no other callback is set\&. .SS "bool shevek::fd::write_block (\fBrelative_time\fPtimeout = \fC\fBrelative_time\fP(-1, 0)\fP)" .PP Block until write buffer is empty\&. This will block at most until the timeout is reached, if it is positive\&. .SH "Author" .PP Generated automatically by Doxygen for libshevek from the source code\&.