gi-gobject-2.0.31: GObject bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.GObject.Structs.ValueArray

Contents

- Exported types
- Methods
  - append
  - copy
  - getNth
  - insert
  - new
  - prepend
  - remove
  - sort
- Properties
  - nValues
  - values

Description

A `GValueArray` is a container structure to hold an array of generic values.

The prime purpose of a `GValueArray` is for it to be used as an object property that holds an array of values. A `GValueArray` wraps an array of `GValue` elements in order for it to be used as a boxed type through `G_TYPE_VALUE_ARRAY`.

`GValueArray` is deprecated in favour of `GArray` since GLib 2.32. It is possible to create a `GArray` that behaves like a `GValueArray` by using the size of `GValue` as the element size, and by setting `valueUnset` as the clear function using `Array`.`set_clear_func`(), for instance, the following code:

### c code

     GValueArray *array = g_value_array_new (10);

can be replaced by:

### c code

     GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 10);
     g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);

Synopsis

- newtype ValueArray = ValueArray (ManagedPtr ValueArray)
- newZeroValueArray :: MonadIO m => m ValueArray
- valueArrayAppend :: (HasCallStack, MonadIO m) => ValueArray -> Maybe GValue -> m ValueArray
- valueArrayCopy :: (HasCallStack, MonadIO m) => ValueArray -> m ValueArray
- valueArrayGetNth :: (HasCallStack, MonadIO m) => ValueArray -> Word32 -> m GValue
- valueArrayInsert :: (HasCallStack, MonadIO m) => ValueArray -> Word32 -> Maybe GValue -> m ValueArray
- valueArrayNew :: (HasCallStack, MonadIO m) => Word32 -> m ValueArray
- valueArrayPrepend :: (HasCallStack, MonadIO m) => ValueArray -> Maybe GValue -> m ValueArray
- valueArrayRemove :: (HasCallStack, MonadIO m) => ValueArray -> Word32 -> m ValueArray
- valueArraySort :: (HasCallStack, MonadIO m) => ValueArray -> CompareDataFunc -> m ValueArray
- getValueArrayNValues :: MonadIO m => ValueArray -> m Word32
- setValueArrayNValues :: MonadIO m => ValueArray -> Word32 -> m ()
- clearValueArrayValues :: MonadIO m => ValueArray -> m ()
- getValueArrayValues :: MonadIO m => ValueArray -> m (Maybe GValue)
- setValueArrayValues :: MonadIO m => ValueArray -> Ptr GValue -> m ()

# Exported types

newtype ValueArray Source #

Memory-managed wrapper type.

Constructors

ValueArray (ManagedPtr ValueArray) |

#### Instances

Instances details

Eq ValueArray Source # |
Instance details Defined in GI.GObject.Structs.ValueArray Methods (==) :: ValueArray -> ValueArray -> Bool Source # (/=) :: ValueArray -> ValueArray -> Bool Source #
GBoxed ValueArray Source # |
Instance details Defined in GI.GObject.Structs.ValueArray
ManagedPtrNewtype ValueArray Source # |
Instance details Defined in GI.GObject.Structs.ValueArray Methods toManagedPtr :: ValueArray -> ManagedPtr ValueArray Source #
TypedObject ValueArray Source # |
Instance details Defined in GI.GObject.Structs.ValueArray Methods glibType :: IO GType Source #
HasParentTypes ValueArray Source # |
Instance details Defined in GI.GObject.Structs.ValueArray
tag ~ 'AttrSet => Constructible ValueArray tag Source # |
Instance details Defined in GI.GObject.Structs.ValueArray Methods new :: MonadIO m => (ManagedPtr ValueArray -> ValueArray) -> [AttrOp ValueArray tag] -> m ValueArray Source #
IsGValue (Maybe ValueArray) Source # | Convert `ValueArray` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.GObject.Structs.ValueArray Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe ValueArray -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe ValueArray) Source #
type ParentTypes ValueArray Source # |
Instance details Defined in GI.GObject.Structs.ValueArray type ParentTypes ValueArray = '[] :: [Type]

newZeroValueArray :: MonadIO m => m ValueArray Source #

Construct a `ValueArray` struct initialized to zero.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

append, copy, insert, prepend, remove, sort.

#### Getters

getNth.

#### Setters

None.

## append

valueArrayAppend Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ValueArray | `valueArray`: `ValueArray` to add an element to
-> Maybe GValue | `value`: `Value` to copy into `ValueArray`, or `Nothing`
-> m ValueArray | Returns: the `ValueArray` passed in as `valueArray`

Deprecated: (Since version 2.32)Use `Array` and `g_array_append_val()` instead.

Insert a copy of `value` as last element of `valueArray`. If `value` is `Nothing`, an uninitialized value is appended.

## copy

valueArrayCopy Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ValueArray | `valueArray`: `ValueArray` to copy
-> m ValueArray | Returns: Newly allocated copy of `ValueArray`

Deprecated: (Since version 2.32)Use `Array` and `g_array_ref()` instead.

Construct an exact copy of a `ValueArray` by duplicating all its contents.

## getNth

valueArrayGetNth Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ValueArray | `valueArray`: `ValueArray` to get a value from
-> Word32 | `index_`: index of the value of interest
-> m GValue | Returns: pointer to a value at `index_` in `valueArray`

Deprecated: (Since version 2.32)Use `g_array_index()` instead.

Return a pointer to the value at `index_` contained in `valueArray`.

## insert

valueArrayInsert Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ValueArray | `valueArray`: `ValueArray` to add an element to
-> Word32 | `index_`: insertion position, must be <= value_array->;n_values
-> Maybe GValue | `value`: `Value` to copy into `ValueArray`, or `Nothing`
-> m ValueArray | Returns: the `ValueArray` passed in as `valueArray`

Deprecated: (Since version 2.32)Use `Array` and `g_array_insert_val()` instead.

Insert a copy of `value` at specified position into `valueArray`. If `value` is `Nothing`, an uninitialized value is inserted.

## new

valueArrayNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `nPrealloced`: number of values to preallocate space for
-> m ValueArray | Returns: a newly allocated `ValueArray` with 0 values

Deprecated: (Since version 2.32)Use `Array` and `g_array_sized_new()` instead.

Allocate and initialize a new `ValueArray`, optionally preserve space for `nPrealloced` elements. New arrays always contain 0 elements, regardless of the value of `nPrealloced`.

## prepend

valueArrayPrepend Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ValueArray | `valueArray`: `ValueArray` to add an element to
-> Maybe GValue | `value`: `Value` to copy into `ValueArray`, or `Nothing`
-> m ValueArray | Returns: the `ValueArray` passed in as `valueArray`

Deprecated: (Since version 2.32)Use `Array` and `g_array_prepend_val()` instead.

Insert a copy of `value` as first element of `valueArray`. If `value` is `Nothing`, an uninitialized value is prepended.

## remove

valueArrayRemove Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ValueArray | `valueArray`: `ValueArray` to remove an element from
-> Word32 | `index_`: position of value to remove, which must be less than `valueArray`->n_values
-> m ValueArray | Returns: the `ValueArray` passed in as `valueArray`

Deprecated: (Since version 2.32)Use `Array` and `g_array_remove_index()` instead.

Remove the value at position `index_` from `valueArray`.

## sort

valueArraySort Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> ValueArray | `valueArray`: `ValueArray` to sort
-> CompareDataFunc | `compareFunc`: function to compare elements
-> m ValueArray | Returns: the `ValueArray` passed in as `valueArray`

Deprecated: (Since version 2.32)Use `Array` and `g_array_sort_with_data()`.

Sort `valueArray` using `compareFunc` to compare the elements according to the semantics of `CompareDataFunc`.

The current implementation uses the same sorting algorithm as standard C `qsort()` function.

# Properties

## nValues

number of values contained in the array

getValueArrayNValues :: MonadIO m => ValueArray -> m Word32 Source #

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

    get valueArray #nValues

setValueArrayNValues :: MonadIO m => ValueArray -> Word32 -> m () Source #

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

    set valueArray [ #nValues := value ]

## values

array of values

clearValueArrayValues :: MonadIO m => ValueArray -> m () Source #

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

    clear #values

getValueArrayValues :: MonadIO m => ValueArray -> m (Maybe GValue) Source #

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

    get valueArray #values

setValueArrayValues :: MonadIO m => ValueArray -> Ptr GValue -> m () Source #

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

    set valueArray [ #values := value ]