gi-soup-2.4.23: Libsoup bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Soup.Structs.Buffer

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.

Synopsis

Exported types

newtype Buffer Source #

Memory-managed wrapper type.

Constructors

Buffer (ManagedPtr Buffer) 

Instances

Instances details
Eq Buffer Source # 
Instance details

Defined in GI.Soup.Structs.Buffer

Methods

(==) :: Buffer -> Buffer -> Bool

(/=) :: Buffer -> Buffer -> Bool

GBoxed Buffer Source # 
Instance details

Defined in GI.Soup.Structs.Buffer

ManagedPtrNewtype Buffer Source # 
Instance details

Defined in GI.Soup.Structs.Buffer

Methods

toManagedPtr :: Buffer -> ManagedPtr Buffer

TypedObject Buffer Source # 
Instance details

Defined in GI.Soup.Structs.Buffer

Methods

glibType :: IO GType

IsGValue Buffer Source #

Convert Buffer to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Soup.Structs.Buffer

Methods

toGValue :: Buffer -> IO GValue

fromGValue :: GValue -> IO Buffer

HasParentTypes Buffer Source # 
Instance details

Defined in GI.Soup.Structs.Buffer

tag ~ 'AttrSet => Constructible Buffer tag Source # 
Instance details

Defined in GI.Soup.Structs.Buffer

Methods

new :: MonadIO m => (ManagedPtr Buffer -> Buffer) -> [AttrOp Buffer tag] -> m Buffer

type ParentTypes Buffer Source # 
Instance details

Defined in GI.Soup.Structs.Buffer

type ParentTypes Buffer = '[] :: [Type]

newZeroBuffer :: MonadIO m => m Buffer Source #

Construct a Buffer struct initialized to zero.

Methods

Overloaded methods

copy

bufferCopy Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a 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

bufferFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a 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

bufferGetAsBytes Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer

-> m Bytes

Returns: a new Bytes which has the same content as the Buffer.

Creates a Bytes pointing to the same memory as buffer. The Bytes will hold a reference on buffer to ensure that it is not freed while the Bytes is still valid.

Since: 2.40

getData

bufferGetData Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a 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

bufferGetOwner Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: a Buffer created with bufferNewWithOwner

-> m (Ptr ())

Returns: the owner pointer

Gets the "owner" object for a buffer created with bufferNewWithOwner.

new

bufferNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteString

data: data

-> m Buffer

Returns: the new Buffer.

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

bufferNewSubbuffer Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

parent: the parent Buffer

-> Word64

offset: offset within parent to start at

-> Word64

length: number of bytes to copy from parent

-> m Buffer

Returns: the new Buffer.

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

bufferNewWithOwner Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ByteString

data: data

-> Ptr ()

owner: pointer to an object that owns data

-> Maybe DestroyNotify

ownerDnotify: a function to free/unref owner when the buffer is freed

-> m Buffer

Returns: the new Buffer.

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

the data

clearBufferData :: MonadIO m => Buffer -> m () Source #

Set the value of the “data” field to Nothing. When overloading is enabled, this is equivalent to

clear #data

getBufferData :: MonadIO m => Buffer -> m (Ptr ()) Source #

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

get buffer #data

setBufferData :: MonadIO m => Buffer -> Ptr () -> m () Source #

Set the value of the “data” field. When overloading is enabled, this is equivalent to

set buffer [ #data := value ]

length

length of data

getBufferLength :: MonadIO m => Buffer -> m Word64 Source #

Get the value of the “length” field. When overloading is enabled, this is equivalent to

get buffer #length

setBufferLength :: MonadIO m => Buffer -> Word64 -> m () Source #

Set the value of the “length” field. When overloading is enabled, this is equivalent to

set buffer [ #length := value ]