DataInputStream

Data input stream implements GInputStream and includes functions for reading structured data directly from a binary input stream.

Constructors

this
this(GDataInputStream* gDataInputStream)

Sets our main struct and passes it to the parent class

this
this(InputStream baseStream)

Creates a new data input stream for the base_stream.

Members

Functions

getByteOrder
GDataStreamByteOrder getByteOrder()

Gets the byte order for the data input stream.

getDataInputStreamStruct
GDataInputStream* getDataInputStreamStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getNewlineType
GDataStreamNewlineType getNewlineType()

Gets the current newline type for the stream.

getStruct
void* getStruct()

the main Gtk struct as a void*

readInt16
short readInt16(Cancellable cancellable)

Reads a 16-bit/2-byte value from stream. In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().

readInt32
int readInt32(Cancellable cancellable)

Reads a signed 32-bit/4-byte value from stream. In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned.

readInt64
long readInt64(Cancellable cancellable)

Reads a 64-bit/8-byte value from stream. In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned.

readLine
string readLine(Cancellable cancellable)

Reads a line from the data input stream. Note that no encoding checks or conversion is performed; the input is not guaranteed to be UTF-8, and may in fact have embedded NUL characters. If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned.

readLineAsync
void readLineAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

The asynchronous version of g_data_input_stream_read_line(). It is an error to have two outstanding calls to this function. When the operation is finished, callback will be called. You can then call g_data_input_stream_read_line_finish() to get the result of the operation. Since 2.20

readLineFinish
string readLineFinish(GAsyncResult result)

Finish an asynchronous call started by g_data_input_stream_read_line_async(). Note the warning about string encoding in g_data_input_stream_read_line() applies here as well. Since 2.20

readLineFinishUtf8
string readLineFinishUtf8(AsyncResultIF result, gsize length)

Finish an asynchronous call started by g_data_input_stream_read_line_async(). Since 2.30

readLineUtf8
string readLineUtf8(gsize length, Cancellable cancellable)

Reads a UTF-8 encoded line from the data input stream. If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned. Since 2.30

readUint16
ushort readUint16(Cancellable cancellable)

Reads an unsigned 16-bit/2-byte value from stream. In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().

readUint32
uint readUint32(Cancellable cancellable)

Reads an unsigned 32-bit/4-byte value from stream. In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order(). If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned.

readUint64
ulong readUint64(Cancellable cancellable)

Reads an unsigned 64-bit/8-byte value from stream. In order to get the correct byte order for this read operation, see g_data_input_stream_get_byte_order(). If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned.

readUntil
string readUntil(string stopChars, Cancellable cancellable)

Reads a string from the data input stream, up to the first occurrence of any of the stop characters. Note that, in contrast to g_data_input_stream_read_until_async(), this function consumes the stop character that it finds. Don't use this function in new code. Its functionality is inconsistent with g_data_input_stream_read_until_async(). Both functions will be marked as deprecated in a future release. Use g_data_input_stream_read_upto() instead, but note that that function does not consume the stop character.

readUntilAsync
void readUntilAsync(string stopChars, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

The asynchronous version of g_data_input_stream_read_until(). It is an error to have two outstanding calls to this function. Note that, in contrast to g_data_input_stream_read_until(), this function does not consume the stop character that it finds. You must read it for yourself. When the operation is finished, callback will be called. You can then call g_data_input_stream_read_until_finish() to get the result of the operation. Don't use this function in new code. Its functionality is inconsistent with g_data_input_stream_read_until(). Both functions will be marked as deprecated in a future release. Use g_data_input_stream_read_upto_async() instead. Since 2.20

readUntilFinish
string readUntilFinish(GAsyncResult result)

Finish an asynchronous call started by g_data_input_stream_read_until_async(). Since 2.20

readUpto
string readUpto(string stopChars, Cancellable cancellable)

Reads a string from the data input stream, up to the first occurrence of any of the stop characters. In contrast to g_data_input_stream_read_until(), this function does not consume the stop character. You have to use g_data_input_stream_read_byte() to get it before calling g_data_input_stream_read_upto() again. Note that stop_chars may contain '\0' if stop_chars_len is specified. Since 2.26

readUptoAsync
void readUptoAsync(string stopChars, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

The asynchronous version of g_data_input_stream_read_upto(). It is an error to have two outstanding calls to this function. In contrast to g_data_input_stream_read_until(), this function does not consume the stop character. You have to use g_data_input_stream_read_byte() to get it before calling g_data_input_stream_read_upto() again. Note that stop_chars may contain '\0' if stop_chars_len is specified. When the operation is finished, callback will be called. You can then call g_data_input_stream_read_upto_finish() to get the result of the operation. Since 2.26

readUptoFinish
string readUptoFinish(GAsyncResult result)

Finish an asynchronous call started by g_data_input_stream_read_upto_async(). Note that this function does not consume the stop character. You have to use g_data_input_stream_read_byte() to get it before calling g_data_input_stream_read_upto_async() again. Since 2.24

setByteOrder
void setByteOrder(GDataStreamByteOrder order)

This function sets the byte order for the given stream. All subsequent reads from the stream will be read in the given order.

setNewlineType
void setNewlineType(GDataStreamNewlineType type)

Sets the newline type for the stream. Note that using G_DATA_STREAM_NEWLINE_TYPE_ANY is slightly unsafe. If a read chunk ends in "CR" we must read an additional byte to know if this is "CR" or "CR LF", and this might block if there is no more data available.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

gDataInputStream
GDataInputStream* gDataInputStream;

the main Gtk struct

Inherited Members

From BufferedInputStream

gBufferedInputStream
GBufferedInputStream* gBufferedInputStream;

the main Gtk struct

getBufferedInputStreamStruct
GBufferedInputStream* getBufferedInputStreamStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
getBufferSize
gsize getBufferSize()

Gets the size of the input buffer.

setBufferSize
void setBufferSize(gsize size)

Sets the size of the internal buffer of stream to size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents.

getAvailable
gsize getAvailable()

Gets the size of the available data within the stream.

peekBuffer
void* peekBuffer(gsize count)

Returns the buffer with the currently available bytes. The returned buffer must not be modified and will become invalid when reading from the stream or filling the buffer.

peek
gsize peek(void* buffer, gsize offset, gsize count)

Peeks in the buffer, copying data of size count into buffer, offset offset bytes.

fill
gssize fill(gssize count, Cancellable cancellable)

Tries to read count bytes from the stream into the buffer. Will block during this read. If count is zero, returns zero and does nothing. A value of count larger than G_MAXSSIZE will cause a G_IO_ERROR_INVALID_ARGUMENT error. On success, the number of bytes read into the buffer is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. near the end of a file. Zero is returned on end of file (or if count is zero), but never otherwise. If count is -1 then the attempted read size is equal to the number of bytes that are required to fill the buffer. If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an operation was partially finished when the operation was cancelled the partial result will be returned, without an error. On error -1 is returned and error is set accordingly. For the asynchronous, non-blocking, version of this function, see g_buffered_input_stream_fill_async().

fillAsync
void fillAsync(gssize count, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Reads data into stream's buffer asynchronously, up to count size. io_priority can be used to prioritize reads. For the synchronous version of this function, see g_buffered_input_stream_fill(). If count is -1 then the attempted read size is equal to the number of bytes that are required to fill the buffer.

fillFinish
gssize fillFinish(AsyncResultIF result)

Finishes an asynchronous read.

readByte
int readByte(Cancellable cancellable)

Tries to read a single byte from the stream or the buffer. Will block during this read. On success, the byte read from the stream is returned. On end of stream -1 is returned but it's not an exceptional error and error is not set. If cancellable is not NULL, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an operation was partially finished when the operation was cancelled the partial result will be returned, without an error. On error -1 is returned and error is set accordingly.

Meta