ConverterT

Description GConverter is implemented by objects that convert binary data in various ways. The conversion can be stateful and may fail at any place. Some example conversions are: character set conversion, compression, decompression and regular expression replace.

Members

Functions

convert
GConverterResult convert(void[] inbuf, void[] outbuf, GConverterFlags flags, gsize bytesRead, gsize bytesWritten)

This is the main operation used when converting data. It is to be called multiple times in a loop, and each time it will do some work, i.e. producing some output (in outbuf) or consuming some input (from inbuf) or both. If its not possible to do any work an error is returned. Note that a single call may not consume all input (or any input at all). Also a call may produce output even if given no input, due to state stored in the converter producing output. If any data was either produced or consumed, and then an error happens, then only the successful conversion is reported and the error is returned on the next call. A full conversion loop involves calling this method repeatedly, each time giving it new input and space output space. When there is no more input data after the data in inbuf, the flag G_CONVERTER_INPUT_AT_END must be set. The loop will be (unless some error happens) returning G_CONVERTER_CONVERTED each time until all data is consumed and all output is produced, then G_CONVERTER_FINISHED is returned instead. Note, that G_CONVERTER_FINISHED may be returned even if G_CONVERTER_INPUT_AT_END is not set, for instance in a decompression converter where the end of data is detectable from the data (and there might even be other data after the end of the compressed data). When some data has successfully been converted bytes_read and is set to the number of bytes read from inbuf, and bytes_written is set to indicate how many bytes was written to outbuf. If there are more data to output or consume (i.e. unless the G_CONVERTER_INPUT_AT_END is specified) then G_CONVERTER_CONVERTED is returned, and if no more data is to be output then G_CONVERTER_FINISHED is returned. On error G_CONVERTER_ERROR is returned and error is set accordingly. Since 2.24

getConverterTStruct
GConverter* getConverterTStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
reset
void reset()

Resets all internal state in the converter, making it behave as if it was just created. If the converter has any internal state that would produce output then that output is lost. Since 2.24

Variables

gConverter
GConverter* gConverter;

the main Gtk struct

Meta