shevek::file Class Reference

Use normal files with the fd class. More...

`#include <file.hh>`

Inheritance diagram for shevek::file:

## Public Member Functions

void | open (std::string name, bool read, bool write)
| Open a new file in the object.
void | close ()
| Close the file.
Public Member Functions inherited from shevek::fd
void | read_custom (read_custom_t cb)
| Poll for read with a custom callback to poll. More...
void | read_priority_custom (read_custom_t cb)
| Poll for priority read with a custom callback to poll.
void | read (read_t cb)
| Poll for read and set read callback (resets custom callback) More...
void | read_priority (read_t cb)
| Poll for priority read and set read callback (resets custom callback)
void | read_lines (read_lines_t cb)
| Poll for read and set read lines callback (resets custom and read callback). Polls for priority read as well.
void | unread (bool flush_buffer=false, flush_t cb=flush_t())
| Stop polling for read (including priority read).
void | write (std::string const &data, write_done_t cb=write_done_t())
| Write data and set a callback (defaults to none).
void | write_raw (std::string const &data, write_done_t cb=write_done_t())
| Write data, ignoring the filter, and set a callback (defaults to none).
bool | write_block (relative_time timeout=relative_time(-1, 0))
| Block until write buffer is empty. More...
std::string & | read_block (relative_time timeout=relative_time(-1, 0))
| Block until data is read, try writing if there is a write buffer. More...
std::string | read_line_block (relative_time timeout=relative_time(-1, 0))
| Call read_block until a line has been read, or the timeout expires.
void | set_fd (int fd)
| Change file descriptor.
void | in_filter (filter_t cb)
| If set, incoming data is filtered through this callback before it is put into the buffer.
void | out_filter (filter_t cb)
| If set, outgoing data is filtered through this callback before it is sent to the file descriptor.
void | set_error (error_t cb)
| Set a callback for all error types at once. More...
void | set_poll_error (error_t cb)
| Callback for errors from poll.
void | set_read_error (error_t cb)
| Callback for errors from read.
void | set_write_error (error_t cb)
| Callback for errors from write.
void | set_eof (error_t cb)
| Callback for end of file.
void | read_reset ()
| Stop reading, delete the buffer.
void | write_reset ()
| Stop writing, delete the buffer.
void | reset ()
| Stop reading and writing, delete the buffers.
int | get_fd () const
| Get the fd. This function should mostly be used by derived classes.
Glib::RefPtr< Glib::MainContext > | get_main_context ()
| Get the main context. Also mostly used by derived classes.
Public Member Functions inherited from shevek::refbase
template<typename _T >
Glib::RefPtr< _T > | cast_dynamic ()
| Identical to GLib::RefPtr <>::cast_dynamic, but nicer to type.

## Static Public Member Functions

static Glib::RefPtr< file > | create (Glib::RefPtr< Glib::MainContext > main=Glib::MainContext::get_default())
| Create a new file object.
Static Public Member Functions inherited from shevek::fd
static Glib::RefPtr< fd > | create (int value=-1, Glib::RefPtr< Glib::MainContext > main=Glib::MainContext::get_default())
| Create a new fd.

## Additional Inherited Members

Public Types inherited from shevek::fd
typedef sigc::slot0< void > | read_custom_t
| Function pointer to call when data is read from fd.
typedef sigc::slot1< bool, std::string & > | read_t
| Function pointer to call when fd is ready for reading.
typedef sigc::slot1< void, std::string const & > | read_lines_t
| Function pointer to call when a complete line has arrived.
typedef sigc::slot0< void > | error_t
| Function pointer to call when an error occurs.
typedef sigc::slot0< void > | write_done_t
| Function pointer to call when data has been written.
typedef sigc::slot1< void, std::string & > | filter_t
| Function pointer to filter in and outgoing data.
typedef sigc::slot0< void > | flush_t
| Function pointer to signal that all data is flushed after unread ()
Protected Member Functions inherited from shevek::fd
| fd (int value, Glib::RefPtr< Glib::MainContext > main)
| Constructor.
| ~fd ()
| Destructor.
Protected Member Functions inherited from shevek::refbase
| refbase ()
| Constructor, increments reference count.
virtual | ~refbase ()
| Destructor, decrements reference count and destroys the object if it reaches 0.
template<typename T >
Glib::RefPtr< T > | refptr_this ()
| Get a RefPtr to this, protected because only members should need it. More...

## Detailed Description

Use normal files with the fd class.

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

- src/file.hh