ConverterIF.convert

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

interface ConverterIF
convert

Parameters

inbuf void[]

the buffer containing the data to convert. [array length=inbuf_size][element-type guint8]

outbuf void[]

a buffer to write converted data in.

flags GConverterFlags

a GConverterFlags controlling the conversion details

bytesRead gsize

will be set to the number of bytes read from inbuf on success. out

bytesWritten gsize

will be set to the number of bytes written to outbuf on success. out

Return Value

a GConverterResult, G_CONVERTER_ERROR on error.

Throws

GException on failure.

Meta