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 |
- 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
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 [methodjson
.Array.ref] and [methodjson
.Array.unref].
To append an element, use [methodjson
.Array.add_element].
To extract an element at a given index, use [methodjson
.Array.get_element].
To retrieve the entire array in list form, use [methodjson
.Array.get_elements].
To retrieve the length of the array, use [methodjson
.Array.get_length].
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 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 | |
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
:: (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: [methodjson
.Array.add_element], [methodjson
.Node.take_array]
Since: 0.8
addBooleanElement
arrayAddBooleanElement Source #
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Bool |
|
-> m () |
Conveniently adds the given boolean value into an array.
See also: [methodjson
.Array.add_element], [methodjson
.Node.set_boolean]
Since: 0.8
addDoubleElement
arrayAddDoubleElement Source #
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Double |
|
-> m () |
Conveniently adds the given floating point value into an array.
See also: [methodjson
.Array.add_element], [methodjson
.Node.set_double]
Since: 0.8
addElement
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Node |
|
-> m () |
Appends the given node
inside an array.
addIntElement
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Int64 |
|
-> m () |
Conveniently adds the given integer value into an array.
See also: [methodjson
.Array.add_element], [methodjson
.Node.set_int]
Since: 0.8
addNullElement
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m () |
Conveniently adds a null
element into an array
See also: [methodjson
.Array.add_element], JSON_NODE_NULL
Since: 0.8
addObjectElement
arrayAddObjectElement Source #
:: (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: [methodjson
.Array.add_element], [methodjson
.Node.take_object]
Since: 0.8
addStringElement
arrayAddStringElement Source #
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Text |
|
-> m () |
Conveniently adds the given string value into an array.
See also: [methodjson
.Array.add_element], [methodjson
.Node.set_string]
Since: 0.8
dupElement
:: (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
:: (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
:: (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
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Array | Returns: the array |
Conveniently retrieves the array at the given position inside an array.
See also: [methodjson
.Array.get_element], [methodjson
.Node.get_array]
Since: 0.8
getBooleanElement
arrayGetBooleanElement Source #
:: (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: [methodjson
.Array.get_element], [methodjson
.Node.get_boolean]
Since: 0.8
getDoubleElement
arrayGetDoubleElement Source #
:: (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: [methodjson
.Array.get_element], [methodjson
.Node.get_double]
Since: 0.8
getElement
:: (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
:: (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
:: (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: [methodjson
.Array.get_element], [methodjson
.Node.get_int]
Since: 0.8
getLength
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m Word32 | Returns: the length of the array |
Retrieves the length of the given array
getNullElement
:: (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: [methodjson
.Array.get_element], [methodjson
.Node.is_null]
Since: 0.8
getObjectElement
arrayGetObjectElement Source #
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> Word32 |
|
-> m Object | Returns: the object |
Conveniently retrieves the object at the given position inside an array.
See also: [methodjson
.Array.get_element], [methodjson
.Node.get_object]
Since: 0.8
getStringElement
arrayGetStringElement Source #
:: (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: [methodjson
.Array.get_element], [methodjson
.Node.get_string]
Since: 0.8
hash
:: (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
:: (HasCallStack, MonadIO m) | |
=> Array |
|
-> m Bool | Returns: |
Check whether the given array
has been marked as immutable by calling
[methodjson
.Array.seal] on it.
Since: 1.2
new
:: (HasCallStack, MonadIO m) | |
=> m Array | Returns: the newly created array |
Creates a new array.
ref
:: (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
:: (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
:: (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
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Array | Returns: the newly created array |
Creates a new array with n_elements
slots already allocated.
unref
:: (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.