gi-gio-2.0.18: Gio bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Objects.MemoryOutputStream

Contents

Description

MemoryOutputStream is a class for using arbitrary memory chunks as output for GIO streaming output operations.

As of GLib 2.34, MemoryOutputStream trivially implements PollableOutputStream: it always polls as ready.

Synopsis

Exported types

class GObject o => IsMemoryOutputStream o Source #

Type class for types which can be safely cast to MemoryOutputStream, for instance with toMemoryOutputStream.

toMemoryOutputStream :: (MonadIO m, IsMemoryOutputStream o) => o -> m MemoryOutputStream Source #

Cast to MemoryOutputStream, for types for which this is known to be safe. For general casts, use castTo.

Methods

getData

memoryOutputStreamGetData Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) 
=> a

ostream: a MemoryOutputStream

-> m (Ptr ())

Returns: pointer to the stream's data, or Nothing if the data has been stolen

Gets any loaded data from the ostream.

Note that the returned pointer may become invalid on the next write or truncate operation on the stream.

getDataSize

memoryOutputStreamGetDataSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) 
=> a

ostream: a MemoryOutputStream

-> m Word64

Returns: the number of bytes written to the stream

Returns the number of bytes from the start up to including the last byte written in the stream that has not been truncated away.

Since: 2.18

getSize

memoryOutputStreamGetSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) 
=> a

ostream: a MemoryOutputStream

-> m Word64

Returns: the number of bytes allocated for the data buffer

Gets the size of the currently allocated data area (available from memoryOutputStreamGetData).

You probably don't want to use this function on resizable streams. See memoryOutputStreamGetDataSize instead. For resizable streams the size returned by this function is an implementation detail and may be change at any time in response to operations on the stream.

If the stream is fixed-sized (ie: no realloc was passed to g_memory_output_stream_new()) then this is the maximum size of the stream and further writes will return IOErrorEnumNoSpace.

In any case, if you want the number of bytes currently written to the stream, use memoryOutputStreamGetDataSize.

newResizable

memoryOutputStreamNewResizable :: (HasCallStack, MonadIO m) => m MemoryOutputStream Source #

Creates a new MemoryOutputStream, using realloc and free for memory allocation.

Since: 2.36

stealAsBytes

memoryOutputStreamStealAsBytes Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) 
=> a

ostream: a MemoryOutputStream

-> m Bytes

Returns: the stream's data

Returns data from the ostream as a Bytes. ostream must be closed before calling this function.

Since: 2.34

stealData

memoryOutputStreamStealData Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) 
=> a

ostream: a MemoryOutputStream

-> m (Ptr ())

Returns: the stream's data, or Nothing if it has previously been stolen

Gets any loaded data from the ostream. Ownership of the data is transferred to the caller; when no longer needed it must be freed using the free function set in ostream's MemoryOutputStream:destroy-function property.

ostream must be closed before calling this function.

Since: 2.26

Properties

data

Pointer to buffer where data will be written.

Since: 2.24

constructMemoryOutputStreamData :: IsMemoryOutputStream o => Ptr () -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “data” property. This is rarely needed directly, but it is used by new.

getMemoryOutputStreamData :: (MonadIO m, IsMemoryOutputStream o) => o -> m (Ptr ()) Source #

Get the value of the “data” property. When overloading is enabled, this is equivalent to

get memoryOutputStream #data

dataSize

Size of data written to the buffer.

Since: 2.24

getMemoryOutputStreamDataSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong Source #

Get the value of the “data-size” property. When overloading is enabled, this is equivalent to

get memoryOutputStream #dataSize

size

Current size of the data buffer.

Since: 2.24

constructMemoryOutputStreamSize :: IsMemoryOutputStream o => CULong -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “size” property. This is rarely needed directly, but it is used by new.

getMemoryOutputStreamSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong Source #

Get the value of the “size” property. When overloading is enabled, this is equivalent to

get memoryOutputStream #size