![]() |
![]() |
Inheritance diagram for Glib::IOChannel:
Public Member Functions | |
virtual | ~IOChannel () |
IOStatus | read (gunichar& unichar) |
Read a single UCS-4 character. | |
IOStatus | read (char* buf, gsize count, gsize& bytes_read) |
Read a character sequence into memory. | |
IOStatus | read (Glib::ustring& str, gsize count) |
Read a maximum of count bytes into str. | |
IOStatus | read_line (Glib::ustring& line) |
Read a whole line. | |
IOStatus | read_to_end (Glib::ustring& str) |
Reads all the remaining data from the file. | |
IOStatus | write (const Glib::ustring& str) |
Write a string to the I/O channel. | |
IOStatus | write (const char* buf, gssize count, gsize& bytes_written) |
Write a memory area of count bytes to the I/O channel. | |
IOStatus | write (gunichar unichar) |
Write a single UCS-4 character to the I/O channel. | |
IOStatus | seek (gint64 offset, SeekType type=SEEK_TYPE_SET) |
Seek the I/O channel to a specific position. | |
IOStatus | flush () |
Flush the buffers of the I/O channel. | |
IOStatus | close (bool flush=true) |
Close the I/O channel. | |
gsize | get_buffer_size () const |
Get the IOChannel internal buffer size. | |
void | set_buffer_size (gsize size) |
Set the internal IOChannel buffer size. | |
IOFlags | get_flags () const |
Get the current flags for a IOChannel, including read-only flags such as Glib::IO_FLAG_IS_READABLE. | |
IOStatus | set_flags (IOFlags flags) |
Set flags on the IOChannel. | |
void | set_buffered (bool buffered) |
Set the buffering status of the I/O channel. | |
bool | get_buffered () const |
Get the buffering status of the I/O channel. | |
IOCondition | get_buffer_condition () const |
Returns an IOCondition depending on whether there is data to be read/space to write data in the internal buffers in the I/O channel. | |
bool | get_close_on_unref () const |
Returns whether the file/socket/whatever associated with the I/O channel will be closed when the channel receives its final unref and is destroyed. | |
void | set_close_on_unref (bool do_close) |
Setting this flag to true for a channel you have already closed can cause problems. | |
IOStatus | set_encoding (const std::string& encoding=std::string()) |
Sets the encoding for the input/output of the channel. | |
std::string | get_encoding () const |
Get the encoding of the I/O channel. | |
void | set_line_term (const std::string& term=std::string()) |
std::string | get_line_term () const |
Glib::RefPtr<IOSource> | create_watch (IOCondition condition) |
Creates an IOSource object. | |
virtual void | reference () const |
virtual void | unreference () const |
GIOChannel* | gobj () |
const GIOChannel* | gobj () const |
Static Public Member Functions | |
Glib::RefPtr<IOChannel> | create_from_file (const std::string& filename, const std::string& mode) |
Open a file filename as an I/O channel using mode mode. | |
Glib::RefPtr<IOChannel> | create_from_fd (int fd) |
Creates an I/O channel from a file descriptor. | |
Glib::RefPtr<IOChannel> | create_from_win32_fd (int fd) |
Create an I/O channel for C runtime (emulated Unix-like) file descriptors. | |
Glib::RefPtr<IOChannel> | create_from_win32_socket (int socket) |
Create an I/O channel for a winsock socket. | |
Protected Member Functions | |
IOChannel () | |
Constructor that should be used by derived classes. | |
virtual IOStatus | read_vfunc (char* buf, gsize count, gsize& bytes_read) |
virtual IOStatus | write_vfunc (const char* buf, gsize count, gsize& bytes_written) |
virtual IOStatus | seek_vfunc (gint64 offset, SeekType type) |
virtual IOStatus | close_vfunc () |
virtual IOStatus | set_flags_vfunc (IOFlags flags) |
virtual IOFlags | get_flags_vfunc () |
virtual Glib::RefPtr<Glib::Source> | create_watch_vfunc (IOCondition cond) |
Protected Attributes | |
GIOChannel* | gobject_ |
Note that IOChannels implement an automatic implicit character set conversion to the data stream, and usually will not pass by default binary data unchanged. To set the encoding of the channel, use e.g. set_encoding("ISO-8859-15"). To set the channel to no encoding, use set_encoding() without any arguments.
You can create an IOChannel with one of the static create methods, or implement one yourself, in which case you have to 1) override all _vfunc() members. 2) set the GIOChannel flags in your constructor.
|
|
|
Constructor that should be used by derived classes. Use this constructor if you want to inherit from IOChannel. It will set up a GIOChannel that will call the vfuncs of your class even if it is being used from C code, and it will keep a reference to the C++ code while the GIOChannel exists. |
|
Close the I/O channel.
Any pending data to be written will be flushed if flush is
|
|
Reimplemented in Glib::StreamIOChannel. |
|
Creates an I/O channel from a file descriptor. On Unix, IOChannels created with this function work for any file descriptor or socket.
On Win32, this can be used either for files opened with the MSVCRT (the Microsoft run-time C library)
The term file descriptor as used in the context of Win32 refers to the emulated Unix-like file descriptors MSVCRT provides. The native corresponding concept is file |
|
Open a file filename as an I/O channel using mode mode. This channel will be closed when the last reference to it is dropped, so there is no need to call close() (though doing so will not cause problems, as long as no attempt is made to access the channel after it is closed).
|
|
Create an I/O channel for C runtime (emulated Unix-like) file descriptors.
After calling add_watch() on a I/O channel returned by this function, you shouldn't call read() on the file descriptor. This is because adding polling for a file descriptor is implemented on Win32 by starting a thread that sits blocked in a |
|
Create an I/O channel for a winsock socket.
The parameter should be a |
|
Creates an IOSource object. Create a slot from a function to be called when condition is met for the channel with sigc::ptr_fun() or sigc::mem_fun() and pass it into the connect() function of the returned IOSource object. Polling of the channel will start when you attach a MainContext object to the returned IOSource object using its attach() function. Glib::signal_io().connect() is a simpler interface to the same functionality, for the case where you want to add the source to the default main context.
|
|
Reimplemented in Glib::StreamIOChannel. |
|
Flush the buffers of the I/O channel.
|
|
Returns an IOCondition depending on whether there is data to be read/space to write data in the internal buffers in the I/O channel. Only the flags Glib::IO_IN and Glib::IO_OUT may be set.
|
|
Get the IOChannel internal buffer size.
|
|
Get the buffering status of the I/O channel.
|
|
Returns whether the file/socket/whatever associated with the I/O channel will be closed when the channel receives its final unref and is destroyed.
The default value of this is
|
|
Get the encoding of the I/O channel.
|
|
Get the current flags for a IOChannel, including read-only flags such as Glib::IO_FLAG_IS_READABLE.
The values of the flags Glib::IO_FLAG_IS_READABLE and Glib::IO_FLAG_IS_WRITEABLE are cached for internal use by the channel when it is created. If they should change at some later point (e.g. partial shutdown of a socket with the UNIX
|
|
Reimplemented in Glib::StreamIOChannel. |
|
|
|
|
|
|
|
Read a maximum of count bytes into str.
|
|
Read a character sequence into memory.
|
|
Read a single UCS-4 character.
|
|
Read a whole line. Reads until the line separator is found, which is included in the result string.
|
|
Reads all the remaining data from the file.
|
|
Reimplemented in Glib::StreamIOChannel. |
|
|
|
Seek the I/O channel to a specific position.
|
|
Reimplemented in Glib::StreamIOChannel. |
|
Set the internal IOChannel buffer size.
|
|
Set the buffering status of the I/O channel.
The buffering state can only be set if the channel's encoding is A buffered channel can only be set unbuffered if the channel's internal buffers have been flushed. Newly created channels or channels which have returned Glib::IO_STATUS_EOF not require such a flush. For write-only channels, a call to flush() is sufficient. For all other channels, the buffers may be flushed by a call to seek(). This includes the possibility of seeking with seek type Glib::SEEK_TYPE_CUR and an offset of zero. Note that this means that socket-based channels cannot be set unbuffered once they have had data read from them. The default state of the channel is buffered.
|
|
Setting this flag to
|
|
Sets the encoding for the input/output of the channel.
The internal encoding is always UTF-8. The default encoding for the external file is UTF-8. The encoding The encoding can only be set if one of the following conditions is true:
Channels which do not meet one of the above conditions cannot call seek_position() with a seek type of Glib::SEEK_TYPE_CUR and, if they are "seekable", cannot call write() after calling one of the API "read" methods.
|
|
Set flags on the IOChannel.
|
|
Reimplemented in Glib::StreamIOChannel. |
|
|
|
|
|
Write a single UCS-4 character to the I/O channel.
|
|
Write a memory area of count bytes to the I/O channel.
|
|
Write a string to the I/O channel. Note that this method does not return the number of characters written. If the channel is blocking and the returned value is Glib::IO_STATUS_NORMAL, the whole string was written.
|
|
Reimplemented in Glib::StreamIOChannel. |
|
|