MemoryInputStream

gio.MemoryInputStream is a class for using arbitrary memory chunks as input for GIO streaming input operations.

As of GLib 2.34, gio.MemoryInputStream implements GPollableInputStream

Constructors

this
this(GMemoryInputStream* gMemoryInputStream, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new empty gio.MemoryInputStream

this
this(Bytes bytes)

Creates a new gio.MemoryInputStream with data from the given bytes.

this
this(ubyte[] data, GDestroyNotify destroy)

Creates a new gio.MemoryInputStream with data in memory of a given size.

Members

Functions

addBytes
void addBytes(Bytes bytes)

Appends bytes to data that can be read from the input stream.

addData
void addData(ubyte[] data, GDestroyNotify destroy)

Appends data to data that can be read from the input stream

getMemoryInputStreamStruct
GMemoryInputStream* getMemoryInputStreamStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

Static functions

getType
GType getType()

Variables

gMemoryInputStream
GMemoryInputStream* gMemoryInputStream;

the main Gtk struct

Inherited Members

From InputStream

gInputStream
GInputStream* gInputStream;

the main Gtk struct

getInputStreamStruct
GInputStream* getInputStreamStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
clearPending
void clearPending()

Clears the pending flag on stream.

close
bool close(Cancellable cancellable)

Closes the stream, releasing resources related to it.

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

Requests an asynchronous closes of the stream, releasing resources related to it. When the operation is finished callback will be called. You can then call InputStream.closeFinish to get the result of the operation.

closeFinish
bool closeFinish(AsyncResultIF result)

Finishes closing a stream asynchronously, started from InputStream.closeAsync.

hasPending
bool hasPending()

Checks if an input stream has pending actions.

isClosed
bool isClosed()

Checks if an input stream is closed.

read
ptrdiff_t read(ubyte[] buffer, Cancellable cancellable)

Tries to read count bytes from the stream into the buffer starting at buffer. Will block during this read.

readAll
bool readAll(ubyte[] buffer, size_t bytesRead, Cancellable cancellable)

Tries to read count bytes from the stream into the buffer starting at buffer. Will block during this read.

readAllAsync
void readAllAsync(ubyte[] buffer, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Request an asynchronous read of count bytes from the stream into the buffer starting at buffer.

readAllFinish
bool readAllFinish(AsyncResultIF result, size_t bytesRead)

Finishes an asynchronous stream read operation started with InputStream.readAllAsync.

readAsync
void readAsync(ubyte[] buffer, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Request an asynchronous read of count bytes from the stream into the buffer starting at buffer. When the operation is finished callback will be called. You can then call InputStream.readFinish to get the result of the operation.

readBytes
Bytes readBytes(size_t count, Cancellable cancellable)

Like InputStream.read, this tries to read count bytes from the stream in a blocking fashion. However, rather than reading into a user-supplied buffer, this will create a new glib.Bytes containing the data that was read. This may be easier to use from language bindings.

readBytesAsync
void readBytesAsync(size_t count, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Request an asynchronous read of count bytes from the stream into a new glib.Bytes When the operation is finished callback will be called. You can then call InputStream.readBytesFinish to get the result of the operation.

readBytesFinish
Bytes readBytesFinish(AsyncResultIF result)

Finishes an asynchronous stream read-into-glib.Bytes operation.

readFinish
ptrdiff_t readFinish(AsyncResultIF result)

Finishes an asynchronous stream read operation.

setPending
bool setPending()

Sets stream to have actions pending. If the pending flag is already set or stream is closed, it will return FALSE and set error.

skip
ptrdiff_t skip(size_t count, Cancellable cancellable)

Tries to skip count bytes from the stream. Will block during the operation.

skipAsync
void skipAsync(size_t count, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)

Request an asynchronous skip of count bytes from the stream. When the operation is finished callback will be called. You can then call InputStream.skipFinish to get the result of the operation.

skipFinish
ptrdiff_t skipFinish(AsyncResultIF result)

Finishes a stream skip operation.

From PollableInputStreamIF

getPollableInputStreamStruct
GPollableInputStream* getPollableInputStreamStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
canPoll
bool canPoll()

Checks if stream is actually pollable. Some classes may implement GPollableInputStream but have only certain instances of that class be pollable. If this method returns FALSE, then the behavior of other GPollableInputStream methods is undefined.

createSource
Source createSource(Cancellable cancellable)

Creates a glib.Source that triggers when stream can be read, or cancellable is triggered or an error occurs. The callback on the source is of the GPollableSourceFunc type.

isReadable
bool isReadable()

Checks if stream can be read.

readNonblocking
ptrdiff_t readNonblocking(ubyte[] buffer, Cancellable cancellable)

Attempts to read up to count bytes from stream into buffer, as with InputStream.read. If stream is not currently readable, this will immediately return G_IO_ERROR_WOULD_BLOCK, and you can use g_pollable_input_stream_create_source() to create a glib.Source that will be triggered when stream is readable.

From SeekableIF

getSeekableStruct
GSeekable* getSeekableStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
canSeek
bool canSeek()

Tests if the stream supports the GSeekableIface

canTruncate
bool canTruncate()

Tests if the length of the stream can be adjusted with g_seekable_truncate().

seek
bool seek(long offset, GSeekType type, Cancellable cancellable)

Seeks in the stream by the given offset, modified by type.

tell
long tell()

Tells the current position within the stream.

truncate
bool truncate(long offset, Cancellable cancellable)

Sets the length of the stream to offset. If the stream was previously larger than offset, the extra data is discarded. If the stream was previouly shorter than offset, it is extended with NUL ('\0') bytes.