Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GI.Json.Structs.Array
Contents
- Exported types
- Methods
- addArrayElement
- addBooleanElement
- addDoubleElement
- addElement
- addIntElement
- addNullElement
- addObjectElement
- addStringElement
- dupElement
- equal
- foreachElement
- getArrayElement
- getBooleanElement
- getDoubleElement
- getElement
- getElements
- getIntElement
- getLength
- getNullElement
- getObjectElement
- getStringElement
- hash
- isImmutable
- new
- ref
- removeElement
- seal
- sizedNew
- unref
Description
JsonArray
is the representation of the array type inside JSON.
A JsonArray
contains [structjson
.Node] elements, which may contain
fundamental types, other arrays or objects.
Since arrays can be arbitrarily big, copying them can be expensive; for
this reason, they are reference counted. You can control the lifetime of
a JsonArray
using arrayRef
and arrayUnref
.
To append an element, use arrayAddElement
.
To extract an element at a given index, use arrayGetElement
.
To retrieve the entire array in list form, use arrayGetElements
.
To retrieve the length of the array, use arrayGetLength
.
Synopsis
- newtype Array = Array (ManagedPtr Array)
- arrayAddArrayElement :: (HasCallStack, MonadIO m) => Array -> Maybe Array -> m ()
- arrayAddBooleanElement :: (HasCallStack, MonadIO m) => Array -> Bool -> m ()
- arrayAddDoubleElement :: (HasCallStack, MonadIO m) => Array -> Double -> m ()
- arrayAddElement :: (HasCallStack, MonadIO m) => Array -> Node -> m ()
- arrayAddIntElement :: (HasCallStack, MonadIO m) => Array -> Int64 -> m ()
- arrayAddNullElement :: (HasCallStack, MonadIO m) => Array -> m ()
- arrayAddObjectElement :: (HasCallStack, MonadIO m) => Array -> Maybe Object -> m ()
- arrayAddStringElement :: (HasCallStack, MonadIO m) => Array -> Text -> m ()
- arrayDupElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Node
- arrayEqual :: (HasCallStack, MonadIO m) => Array -> Array -> m Bool
- arrayForeachElement :: (HasCallStack, MonadIO m) => Array -> ArrayForeach -> m ()
- arrayGetArrayElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Array
- arrayGetBooleanElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Bool
- arrayGetDoubleElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Double
- arrayGetElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Node
- arrayGetElements :: (HasCallStack, MonadIO m) => Array -> m [Node]
- arrayGetIntElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Int64
- arrayGetLength :: (HasCallStack, MonadIO m) => Array -> m Word32
- arrayGetNullElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Bool
- arrayGetObjectElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Object
- arrayGetStringElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Text
- arrayHash :: (HasCallStack, MonadIO m) => Array -> m Word32
- arrayIsImmutable :: (HasCallStack, MonadIO m) => Array -> m Bool
- arrayNew :: (HasCallStack, MonadIO m) => m Array
- arrayRef :: (HasCallStack, MonadIO m) => Array -> m Array
- arrayRemoveElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m ()
- arraySeal :: (HasCallStack, MonadIO m) => Array -> m ()
- arraySizedNew :: (HasCallStack, MonadIO m) => Word32 -> m Array
- arrayUnref :: (HasCallStack, MonadIO m) => Array -> m ()
Exported types
Memory-managed wrapper type.
Instances
Eq Array Source # | |
GBoxed Array Source # | |
Defined in GI.Json.Structs.Array | |
ManagedPtrNewtype Array Source # | |
Defined in GI.Json.Structs.Array Methods toManagedPtr :: Array -> ManagedPtr Array | |
TypedObject Array Source # | |
Defined in GI.Json.Structs.Array | |
HasParentTypes Array Source # | |
Defined in GI.Json.Structs.Array | |
IsGValue (Maybe Array) Source # | Convert |
Defined in GI.Json.Structs.Array Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Array -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Array) | |
type ParentTypes Array Source # | |
Defined in GI.Json.Structs.Array |
Methods
Click to display all available methods, including inherited ones
Methods
addArrayElement, addBooleanElement, addDoubleElement, addElement, addIntElement, addNullElement, addObjectElement, addStringElement, dupElement, equal, foreachElement, hash, isImmutable, ref, removeElement, seal, unref.
Getters
getArrayElement, getBooleanElement, getDoubleElement, getElement, getElements, getIntElement, getLength, getNullElement, getObjectElement, getStringElement.
Setters
None.
addArrayElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Maybe Array |
|
-> m () |
Conveniently adds an array element into an array.
If value
is NULL
, a null
element will be added instead.
See also: arrayAddElement
, nodeTakeArray
Since: 0.8
addBooleanElement
arrayAddBooleanElement Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Bool |
|
-> m () |
Conveniently adds the given boolean value into an array.
See also: arrayAddElement
, nodeSetBoolean
Since: 0.8
addDoubleElement
arrayAddDoubleElement Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Double |
|
-> m () |
Conveniently adds the given floating point value into an array.
See also: arrayAddElement
, nodeSetDouble
Since: 0.8
addElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Node |
|
-> m () |
Appends the given node
inside an array.
addIntElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Int64 |
|
-> m () |
Conveniently adds the given integer value into an array.
See also: arrayAddElement
, nodeSetInt
Since: 0.8
addNullElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m () |
addObjectElement
arrayAddObjectElement Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Maybe Object |
|
-> m () |
Conveniently adds an object into an array.
If value
is NULL
, a null
element will be added instead.
See also: arrayAddElement
, nodeTakeObject
Since: 0.8
addStringElement
arrayAddStringElement Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Text |
|
-> m () |
Conveniently adds the given string value into an array.
See also: arrayAddElement
, nodeSetString
Since: 0.8
dupElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Node | Returns: a copy of the element at the given position |
Retrieves a copy of the element at the given position in the array.
Since: 0.6
equal
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Array |
|
-> m Bool | Returns: |
Check whether two arrays are equal.
Equality is defined as:
- the array have the same number of elements
- the values of elements in corresponding positions are equal
Since: 1.2
foreachElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> ArrayForeach |
|
-> m () |
Iterates over all elements of an array, and calls a function on each one of them.
It is safe to change the value of an element of the array while iterating over it, but it is not safe to add or remove elements from the array.
Since: 0.8
getArrayElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Array | Returns: the array |
Conveniently retrieves the array at the given position inside an array.
See also: arrayGetElement
, nodeGetArray
Since: 0.8
getBooleanElement
arrayGetBooleanElement Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Bool | Returns: the boolean value |
Conveniently retrieves the boolean value of the element at the given position inside an array.
See also: arrayGetElement
, nodeGetBoolean
Since: 0.8
getDoubleElement
arrayGetDoubleElement Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Double | Returns: the floating point value |
Conveniently retrieves the floating point value of the element at the given position inside an array.
See also: arrayGetElement
, nodeGetDouble
Since: 0.8
getElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Node | Returns: the element at the given position |
Retrieves the element at the given position in the array.
getElements
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m [Node] | Returns: the elements of the array |
Retrieves all the elements of an array as a list of nodes.
getIntElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Int64 | Returns: the integer value |
Conveniently retrieves the integer value of the element at the given position inside an array.
See also: arrayGetElement
, nodeGetInt
Since: 0.8
getLength
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m Word32 | Returns: the length of the array |
Retrieves the length of the given array
getNullElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Bool | Returns: |
Conveniently checks whether the element at the given position inside the
array contains a null
value.
See also: arrayGetElement
, nodeIsNull
Since: 0.8
getObjectElement
arrayGetObjectElement Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Object | Returns: the object |
Conveniently retrieves the object at the given position inside an array.
See also: arrayGetElement
, nodeGetObject
Since: 0.8
getStringElement
arrayGetStringElement Source #
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Text | Returns: the string value |
Conveniently retrieves the string value of the element at the given position inside an array.
See also: arrayGetElement
, nodeGetString
Since: 0.8
hash
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m Word32 | Returns: hash value for the key |
Calculates a hash value for the given key
.
The hash is calculated over the array and all its elements, recursively.
If the array is immutable, this is a fast operation; otherwise, it scales proportionally with the length of the array.
Since: 1.2
isImmutable
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m Bool | Returns: |
Check whether the given array
has been marked as immutable by calling
arraySeal
on it.
Since: 1.2
new
Arguments
:: (HasCallStack, MonadIO m) | |
=> m Array | Returns: the newly created array |
Creates a new array.
ref
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m Array | Returns: the passed array, with the reference count increased by one |
Acquires a reference on the given array.
removeElement
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m () |
Removes the element at the given position inside an array.
This function will release the reference held on the element.
seal
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m () |
Seals the given array, making it immutable to further changes.
This function will recursively seal all elements in the array too.
If the array
is already immutable, this is a no-op.
Since: 1.2
sizedNew
Arguments
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Array | Returns: the newly created array |
Creates a new array with n_elements
slots already allocated.
unref
Arguments
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m () |
Releases a reference on the given array.
If the reference count reaches zero, the array is destroyed and all its allocated resources are freed.