W Wrapl, The Programming Language

Libraries:Gtk:Glib:GIOChannel

Types

T

Constants

Nil : T

Functions

ErrorFromErrno(en @ Std.Integer.SmallT) : Gtk.Glib.GIOChannelError.T

Converts an errno error number to a Gtk.Glib.GIOChannelError.T.

en an errno error number, e.g. EINVAL
Returns a Gtk.Glib.GIOChannelError.T error number, e.g. Gtk.Glib.GIOChannelError.Inval.


ErrorQuark() : Std.Integer.SmallT



LNewFile(filename @ Std.String.T, mode @ Std.String.T, error @ Std.Object.T) : Gtk.Glib.GIOChannel.T



UnixNew(fd @ Std.Integer.SmallT) : Gtk.Glib.GIOChannel.T

Creates a new T given a file descriptor. On UNIX systems this works for plain files, pipes, and sockets.

The returned T has a reference count of 1.

The default encoding for T is UTF-8. If your application is reading output from a command using via pipe, you may need to set the encoding to the encoding of the current locale (see Gtk.Glib.GUnicode.GetCharset) with the SetEncoding function.

If you want to read raw binary data without interpretation, then call the SetEncoding function with NULL for the encoding argument.

This function is available in GLib on Windows, too, but you should avoid using it on Windows. The domain of file descriptors and sockets overlap. There is no way for GLib to know which one you mean in case the argument you pass to this function happens to be both a valid file descriptor and socket. If that happens a warning is issued, and GLib assumes that it is the file descriptor you mean.

fd a file descriptor.
Returns a new T.


Methods

:"="(_ @ T, _ @ T)

:AddWatch(self @ T, condition @ Gtk.Glib.GIOCondition.T, func @ Std.Function.T, user_data) : Std.Integer.SmallT

Adds the T into the default main loop context with the default priority.

channel a T
condition the condition to watch for
func the function to call when the condition is satisfied
user_data user data to pass to func
Returns the event source id


:AddWatchFull(self @ T, priority @ Std.Integer.SmallT, condition @ Gtk.Glib.GIOCondition.T, func @ Std.Function.T, user_data, notify @ Std.Function.T) : Std.Integer.SmallT

Adds the T into the default main loop context with the given priority.

This internally creates a main loop source using CreateWatch and attaches it to the main loop context with Gtk.Glib.GMain.SourceAttach. You can do these steps manually if you need greater control.

channel a T
priority the priority of the T source
condition the condition to watch for
func the function to call when the condition is satisfied
user_data user data to pass to func
notify the function to call when the source is removed
Returns the event source id Rename to: g_io_add_watch


:Close(self @ T) : Std.Object.T

Warning

Close has been deprecated since version 2.2 and should not be used in newly-written code. Use Shutdown instead.



:CreateWatch(self @ T, condition @ Gtk.Glib.GIOCondition.T) : Std.Integer.SmallT

Creates a Gtk.Glib.GSource.T that's dispatched when condition is met for the given channel. For example, if condition is Gtk.Glib.GIOCondition.In, the source will be dispatched when there's data available for reading.

AddWatch is a simpler interface to this same functionality, for the case where you want to add the source to the default main loop context at the default priority.

On Windows, polling a Gtk.Glib.GSource.T created to watch a channel for a socket puts the socket in non-blocking mode. This is a side-effect of the implementation and unavoidable.

channel a T to watch
condition conditions to watch for
Returns a new Gtk.Glib.GSource.T


:Flush(self @ T, error) : Gtk.Glib.GIOStatus.T

Flushes the write buffer for the GIOChannel.

channel a T
error location to store an error of type Gtk.Glib.GIOChannelError.T
Returns the status of the operation: One of Gtk.Glib.GIOStatus.Normal, Gtk.Glib.GIOStatus.Again, or Gtk.Glib.GIOStatus.Error.


:GetBufferCondition(self @ T) : Gtk.Glib.GIOCondition.T

This function returns a Gtk.Glib.GIOCondition.T depending on whether there is data to be read/space to write data in the internal buffers in the T. Only the flags Gtk.Glib.GIOCondition.In and Gtk.Glib.GIOCondition.Out may be set.

channel A T
Returns A Gtk.Glib.GIOCondition.T


:GetBufferSize(self @ T) : Std.Integer.SmallT

Gets the buffer size.

channel a T
Returns the size of the buffer.


:GetBuffered(self @ T) : Std.Symbol.T

Returns whether channel is buffered.

channel a T
Returns TRUE if the channel is buffered.


:GetCloseOnUnref(self @ T) : Std.Symbol.T

Returns whether the file/socket/whatever associated with channel will be closed when channel receives its final unref and is destroyed. The default value of this is TRUE for channels created by g_io_channel_new_file(), and FALSE for all other channels.

channel a T.
Returns Whether the channel will be closed on the final unref of the GIOChannel data structure.


:GetEncoding(self @ T) : Std.String.T

Gets the encoding for the input/output of the channel. The internal encoding is always UTF-8. The encoding NULL makes the channel safe for binary data.

channel a T
Returns A string containing the encoding, this string is owned by GLib and must not be freed.


:GetFlags(self @ T) : Std.Integer.SmallT

Gets the current flags for a T, including read-only flags such as Gtk.Glib.GIOFlags.IsReadable.

The values of the flags Gtk.Glib.GIOFlags.IsReadable and Gtk.Glib.GIOFlags.IsWriteable 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 shutdown() function), the user should immediately call GetFlags to update the internal values of these flags.

channel a T
Returns the flags which are set on the channel


:GetLineTerm(self @ T, length @ Std.Object.T) : Std.String.T

This returns the string that T uses to determine where in the file a line break occurs. A value of NULL indicates autodetection.

channel a T
length a location to return the length of the line terminator
Returns The line termination string. This value is owned by GLib and must not be freed.


:Init(self @ T) : Std.Object.T

Initializes a T struct.

This is called by each of the above functions when creating a T, and so is not often needed by the application programmer (unless you are creating a new type of T).

channel a T


:Read(self @ T, buf @ Std.String.T, count @ Std.Integer.SmallT, bytes_read @ Std.Object.T) : Gtk.Glib.GIOError.T

Warning

Read has been deprecated since version 2.2 and should not be used in newly-written code. Use ReadChars instead.



:ReadChars(self @ T, buf @ Std.String.T, count @ Std.Integer.SmallT, bytes_read @ Std.Object.T, error) : Gtk.Glib.GIOStatus.T

Replacement for Read with the new API.

channel a T
buf a buffer to read data into
count the size of the buffer. Note that the buffer may not be complelely filled even if there is data in the buffer if the remaining data is not a complete character.
bytes_read The number of bytes read. This may be zero even on success if count < 6 and the channel's encoding is non-NULL. This indicates that the next UTF-8 character is too wide for the buffer. [allow-none]
error a location to return an error of type Gtk.Glib.GConvertError.T or Gtk.Glib.GIOChannelError.T.
Returns the status of the operation.


:ReadLine(self @ T, str_return @ Agg.List.T, length @ Std.Object.T, terminator_pos @ Std.Object.T, error) : Gtk.Glib.GIOStatus.T

Reads a line, including the terminating character(s), from a T into a newly-allocated string. str_return will contain allocated memory if the return is Gtk.Glib.GIOStatus.Normal.

channel a T
str_return The line read from the T, including the line terminator. This data should be freed with g_free() when no longer needed. This is a nul-terminated string. If a length of zero is returned, this will be NULL instead.
length location to store length of the read data, or NULL
terminator_pos location to store position of line terminator, or NULL
error A location to return an error of type Gtk.Glib.GConvertError.T or Gtk.Glib.GIOChannelError.T
Returns the status of the operation.


:ReadLineString(self @ T, buffer @ Gtk.Glib.GString.T, terminator_pos @ Std.Object.T, error) : Gtk.Glib.GIOStatus.T

Reads a line from a T, using a Gtk.Glib.GString.T as a buffer.

channel a T
buffer a Gtk.Glib.GString.T into which the line will be written. If buffer already contains data, the old data will be overwritten.
terminator_pos location to store position of line terminator, or NULL
error a location to store an error of type Gtk.Glib.GConvertError.T or Gtk.Glib.GIOChannelError.T
Returns the status of the operation.


:ReadToEnd(self @ T, str_return @ Agg.List.T, length @ Std.Object.T, error) : Gtk.Glib.GIOStatus.T

Reads all the remaining data from the file.

channel a T
str_return Location to store a pointer to a string holding the remaining data in the T. This data should be freed with g_free() when no longer needed. This data is terminated by an extra nul character, but there may be other nuls in the intervening data.
length location to store length of the data
error location to return an error of type Gtk.Glib.GConvertError.T or Gtk.Glib.GIOChannelError.T
Returns Gtk.Glib.GIOStatus.Normal on success. This function never returns Gtk.Glib.GIOStatus.Eof.


:ReadUnichar(self @ T, thechar @ Std.Object.T, error) : Gtk.Glib.GIOStatus.T

Reads a Unicode character from channel. This function cannot be called on a channel with NULL encoding.

channel a T
thechar a location to return a character
error a location to return an error of type Gtk.Glib.GConvertError.T or Gtk.Glib.GIOChannelError.T
Returns a Gtk.Glib.GIOStatus.T


:Ref(self @ T) : Gtk.Glib.GIOChannel.T

Increments the reference count of a T.

channel a T
Returns the channel that was passed in (since 2.6)


:Seek(self @ T, offset @ Std.Integer.T, type @ Gtk.Glib.GSeekType.T) : Gtk.Glib.GIOError.T

Warning

Seek has been deprecated since version 2.2 and should not be used in newly-written code. Use SeekPosition instead.



:SeekPosition(self @ T, offset @ Std.Integer.T, type @ Gtk.Glib.GSeekType.T, error) : Gtk.Glib.GIOStatus.T

Replacement for Seek with the new API.

channel a T
offset The offset in bytes from the position specified by type
type a Gtk.Glib.GSeekType.T. The type Gtk.Glib.GSeekType.Cur is only allowed in those cases where a call to SetEncoding is allowed. See the documentation for SetEncoding for details.
error A location to return an error of type Gtk.Glib.GIOChannelError.T
Returns the status of the operation.


:SetBufferSize(self @ T, size @ Std.Integer.SmallT) : Std.Object.T

Sets the buffer size.

channel a T
size the size of the buffer, or 0 to let GLib pick a good size


:SetBuffered(self @ T, buffered @ Std.Symbol.T) : Std.Object.T

The buffering state can only be set if the channel's encoding is NULL. For any other encoding, the channel must be buffered.

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 Gtk.Glib.GIOStatus.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 SeekPosition. This includes the possibility of seeking with seek type Gtk.Glib.GSeekType.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.

On unbuffered channels, it is safe to mix read and write calls from the new and old APIs, if this is necessary for maintaining old code.

The default state of the channel is buffered.

channel a T
buffered whether to set the channel buffered or unbuffered


:SetCloseOnUnref(self @ T, do_close @ Std.Symbol.T) : Std.Object.T

Setting this flag to TRUE for a channel you have already closed can cause problems.

channel a T
do_close Whether to close the channel on the final unref of the GIOChannel data structure. The default value of this is TRUE for channels created by g_io_channel_new_file(), and FALSE for all other channels.


:SetEncoding(self @ T, encoding @ Std.String.T, error) : Gtk.Glib.GIOStatus.T

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 NULL is safe to use with binary data.

The encoding can only be set if one of the following conditions is true:



:SetFlags(self @ T, flags @ Std.Integer.SmallT, error) : Gtk.Glib.GIOStatus.T

Sets the (writeable) flags in channel to (flags & G_IO_CHANNEL_SET_MASK).

channel a T
flags the flags to set on the IO channel
error A location to return an error of type Gtk.Glib.GIOChannelError.T
Returns the status of the operation.


:SetLineTerm(self @ T, line_term @ Std.String.T, length @ Std.Integer.SmallT) : Std.Object.T

This sets the string that T uses to determine where in the file a line break occurs.

channel a T
line_term The line termination string. Use NULL for autodetect. Autodetection breaks on "\n", "\r\n", "\r", "\0", and the Unicode paragraph separator. Autodetection should not be used for anything other than file-based channels.
length The length of the termination string. If -1 is passed, the string is assumed to be nul-terminated. This option allows termination strings with embedded nuls.


:Shutdown(self @ T, flush @ Std.Symbol.T, err) : Gtk.Glib.GIOStatus.T

Close an IO channel. Any pending data to be written will be flushed if flush is TRUE. The channel will not be freed until the last reference is dropped using Unref.

channel a T
flush if TRUE, flush pending
err location to store a Gtk.Glib.GIOChannelError.T
Returns the status of the operation.


:UnixGetFd(self @ T) : Std.Integer.SmallT

Returns the file descriptor of the T.

On Windows this function returns the file descriptor or socket of the T.

channel a T, created with UnixNew.
Returns the file descriptor of the T.


:Unref(self @ T) : Std.Object.T

Decrements the reference count of a T.

channel a T


:Write(self @ T, buf @ Std.String.T, count @ Std.Integer.SmallT, bytes_written @ Std.Object.T) : Gtk.Glib.GIOError.T

Warning

Write has been deprecated since version 2.2 and should not be used in newly-written code. Use WriteChars instead.



:WriteChars(self @ T, buf @ Std.String.T, count @ Std.Integer.SmallT, bytes_written @ Std.Object.T, error) : Gtk.Glib.GIOStatus.T

Replacement for Write with the new API.

On seekable channels with encodings other than NULL or UTF-8, generic mixing of reading and writing is not allowed. A call to WriteChars may only be made on a channel from which data has been read in the cases described in the documentation for SetEncoding.

channel a T
buf a buffer to write data from
count the size of the buffer. If -1, the buffer is taken to be a nul-terminated string.
bytes_written The number of bytes written. This can be nonzero even if the return value is not Gtk.Glib.GIOStatus.Normal. If the return value is Gtk.Glib.GIOStatus.Normal and the channel is blocking, this will always be equal to count if count >= 0.
error a location to return an error of type Gtk.Glib.GConvertError.T or Gtk.Glib.GIOChannelError.T
Returns the status of the operation.


:WriteUnichar(self @ T, thechar @ Std.Integer.SmallT, error) : Gtk.Glib.GIOStatus.T

Writes a Unicode character to channel. This function cannot be called on a channel with NULL encoding.

channel a T
thechar a character
error location to return an error of type Gtk.Glib.GConvertError.T or Gtk.Glib.GIOChannelError.T
Returns a Gtk.Glib.GIOStatus.T


:"~="(_ @ T, _ @ T)