Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
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.
- newtype MemoryOutputStream = MemoryOutputStream (ManagedPtr MemoryOutputStream)
- class GObject o => IsMemoryOutputStream o
- toMemoryOutputStream :: (MonadIO m, IsMemoryOutputStream o) => o -> m MemoryOutputStream
- noMemoryOutputStream :: Maybe MemoryOutputStream
- memoryOutputStreamGetData :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m (Ptr ())
- memoryOutputStreamGetDataSize :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m Word64
- memoryOutputStreamGetSize :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m Word64
- memoryOutputStreamNewResizable :: (HasCallStack, MonadIO m) => m MemoryOutputStream
- memoryOutputStreamStealAsBytes :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m Bytes
- memoryOutputStreamStealData :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m (Ptr ())
- constructMemoryOutputStreamData :: IsMemoryOutputStream o => Ptr () -> IO (GValueConstruct o)
- getMemoryOutputStreamData :: (MonadIO m, IsMemoryOutputStream o) => o -> m (Ptr ())
- getMemoryOutputStreamDataSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong
- constructMemoryOutputStreamSize :: IsMemoryOutputStream o => CULong -> IO (GValueConstruct o)
- getMemoryOutputStreamSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong
Exported types
newtype MemoryOutputStream Source #
class GObject o => IsMemoryOutputStream o Source #
toMemoryOutputStream :: (MonadIO m, IsMemoryOutputStream o) => o -> m MemoryOutputStream Source #
Methods
getData
memoryOutputStreamGetData Source #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> m (Ptr ()) | Returns: pointer to the stream's data, or |
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 #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> m (Ptr ()) | Returns: the stream's data, or |
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
constructMemoryOutputStreamData :: IsMemoryOutputStream o => Ptr () -> IO (GValueConstruct o) Source #
getMemoryOutputStreamData :: (MonadIO m, IsMemoryOutputStream o) => o -> m (Ptr ()) Source #
dataSize
getMemoryOutputStreamDataSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong Source #
size
constructMemoryOutputStreamSize :: IsMemoryOutputStream o => CULong -> IO (GValueConstruct o) Source #
getMemoryOutputStreamSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong Source #