| 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 |
GI.Soup.Structs.Buffer
Contents
Description
A data buffer, generally used to represent a chunk of a
MessageBody.
data is a char because that's generally convenient; in some
situations you may need to cast it to guchar or another type.
- newtype Buffer = Buffer (ManagedPtr Buffer)
- newZeroBuffer :: MonadIO m => m Buffer
- noBuffer :: Maybe Buffer
- data BufferCopyMethodInfo
- bufferCopy :: (HasCallStack, MonadIO m) => Buffer -> m Buffer
- data BufferFreeMethodInfo
- bufferFree :: (HasCallStack, MonadIO m) => Buffer -> m ()
- data BufferGetAsBytesMethodInfo
- bufferGetAsBytes :: (HasCallStack, MonadIO m) => Buffer -> m Bytes
- data BufferGetDataMethodInfo
- bufferGetData :: (HasCallStack, MonadIO m) => Buffer -> m ByteString
- data BufferGetOwnerMethodInfo
- bufferGetOwner :: (HasCallStack, MonadIO m) => Buffer -> m (Ptr ())
- bufferNew :: (HasCallStack, MonadIO m) => ByteString -> m Buffer
- data BufferNewSubbufferMethodInfo
- bufferNewSubbuffer :: (HasCallStack, MonadIO m) => Buffer -> Word64 -> Word64 -> m Buffer
- bufferNewWithOwner :: (HasCallStack, MonadIO m) => ByteString -> Ptr () -> Maybe DestroyNotify -> m Buffer
- buffer_data :: AttrLabelProxy "data"
- clearBufferData :: MonadIO m => Buffer -> m ()
- getBufferData :: MonadIO m => Buffer -> m (Ptr ())
- setBufferData :: MonadIO m => Buffer -> Ptr () -> m ()
- buffer_length :: AttrLabelProxy "length"
- getBufferLength :: MonadIO m => Buffer -> m Word64
- setBufferLength :: MonadIO m => Buffer -> Word64 -> m ()
Exported types
Constructors
| Buffer (ManagedPtr Buffer) |
Instances
Methods
copy
data BufferCopyMethodInfo Source #
Instances
| ((~) * signature (m Buffer), MonadIO m) => MethodInfo * BufferCopyMethodInfo Buffer signature Source # | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Buffer |
|
| -> m Buffer | Returns: the new (or newly-reffed) buffer |
Makes a copy of buffer. In reality, Buffer is a refcounted
type, and calling bufferCopy will normally just increment
the refcount on buffer and return it. However, if buffer was
created with SOUP_MEMORY_TEMPORARY memory, then bufferCopy
will actually return a copy of it, so that the data in the copy
will remain valid after the temporary buffer is freed.
free
data BufferFreeMethodInfo Source #
Instances
| ((~) * signature (m ()), MonadIO m) => MethodInfo * BufferFreeMethodInfo Buffer signature Source # | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Buffer |
|
| -> m () |
Frees buffer. (In reality, as described in the documentation for
bufferCopy, this is actually an "unref" operation, and may
or may not actually free buffer.)
getAsBytes
data BufferGetAsBytesMethodInfo Source #
Instances
| ((~) * signature (m Bytes), MonadIO m) => MethodInfo * BufferGetAsBytesMethodInfo Buffer signature Source # | |
getData
data BufferGetDataMethodInfo Source #
Instances
| ((~) * signature (m ByteString), MonadIO m) => MethodInfo * BufferGetDataMethodInfo Buffer signature Source # | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Buffer |
|
| -> m ByteString |
This function exists for use by language bindings, because it's not
currently possible to get the right effect by annotating the fields
of Buffer.
Since: 2.32
getOwner
data BufferGetOwnerMethodInfo Source #
Instances
| ((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * BufferGetOwnerMethodInfo Buffer signature Source # | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Buffer |
|
| -> m (Ptr ()) | Returns: the owner pointer |
Gets the "owner" object for a buffer created with
bufferNewWithOwner.
new
Arguments
| :: (HasCallStack, MonadIO m) | |
| => ByteString |
|
| -> m Buffer | Returns: the new |
Creates a new Buffer containing length bytes from data.
This function is exactly equivalent to soup_buffer_new() with
MemoryUseTake as first argument; it exists mainly for
convenience and simplifying language bindings.
Since: 2.32
newSubbuffer
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Buffer |
|
| -> Word64 |
|
| -> Word64 |
|
| -> m Buffer | Returns: the new |
Creates a new Buffer containing length bytes "copied" from
parent starting at offset. (Normally this will not actually copy
any data, but will instead simply reference the same data as
parent does.)
newWithOwner
Arguments
| :: (HasCallStack, MonadIO m) | |
| => ByteString |
|
| -> Ptr () |
|
| -> Maybe DestroyNotify |
|
| -> m Buffer | Returns: the new |
Creates a new Buffer containing length bytes from data. When
the Buffer is freed, it will call ownerDnotify, passing
owner to it. You must ensure that data will remain valid until
ownerDnotify is called.
For example, you could use this to create a buffer containing data returned from libxml without needing to do an extra copy:
<informalexample><programlisting> xmlDocDumpMemory (doc, &xmlbody, &len); return soup_buffer_new_with_owner (xmlbody, len, xmlbody, (GDestroyNotify)xmlFree); </programlisting></informalexample>
In this example, data and owner are the same, but in other cases
they would be different (eg, owner would be a object, and data
would be a pointer to one of the object's fields).
Properties
data
buffer_data :: AttrLabelProxy "data" Source #
clearBufferData :: MonadIO m => Buffer -> m () Source #
length
buffer_length :: AttrLabelProxy "length" Source #