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 |
JsonSerializable
is an interface for controlling the serialization
and deserialization of GObject
classes.
Implementing this interface allows controlling how the class is going
to be serialized or deserialized by [funcjson
.construct_gobject] and
[funcjson
.serialize_gobject], respectively.
Synopsis
- newtype Serializable = Serializable (ManagedPtr Serializable)
- class (GObject o, IsDescendantOf Serializable o) => IsSerializable o
- toSerializable :: (MonadIO m, IsSerializable o) => o -> m Serializable
- serializableDefaultDeserializeProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> GValue -> GParamSpec -> Node -> m Bool
- serializableDefaultSerializeProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> GValue -> GParamSpec -> m (Maybe Node)
- serializableDeserializeProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> GParamSpec -> Node -> m (Bool, GValue)
- serializableFindProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> m (Maybe GParamSpec)
- serializableGetProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> GParamSpec -> m GValue
- serializableSerializeProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> GValue -> GParamSpec -> m Node
- serializableSetProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> GParamSpec -> GValue -> m ()
Exported types
newtype Serializable Source #
Memory-managed wrapper type.
Instances
Eq Serializable Source # | |
Defined in GI.Json.Interfaces.Serializable (==) :: Serializable -> Serializable -> Bool # (/=) :: Serializable -> Serializable -> Bool # | |
GObject Serializable Source # | |
Defined in GI.Json.Interfaces.Serializable | |
ManagedPtrNewtype Serializable Source # | |
Defined in GI.Json.Interfaces.Serializable | |
TypedObject Serializable Source # | |
Defined in GI.Json.Interfaces.Serializable | |
HasParentTypes Serializable Source # | |
Defined in GI.Json.Interfaces.Serializable | |
IsGValue (Maybe Serializable) Source # | Convert |
Defined in GI.Json.Interfaces.Serializable gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe Serializable -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe Serializable) # | |
type ParentTypes Serializable Source # | |
Defined in GI.Json.Interfaces.Serializable |
class (GObject o, IsDescendantOf Serializable o) => IsSerializable o Source #
Type class for types which can be safely cast to Serializable
, for instance with toSerializable
.
Instances
(GObject o, IsDescendantOf Serializable o) => IsSerializable o Source # | |
Defined in GI.Json.Interfaces.Serializable |
toSerializable :: (MonadIO m, IsSerializable o) => o -> m Serializable Source #
Cast to Serializable
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, defaultDeserializeProperty, defaultSerializeProperty, deserializeProperty, findProperty, forceFloating, freezeNotify, getv, isFloating, listProperties, notify, notifyByPspec, ref, refSink, runDispose, serializeProperty, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getProperty, getQdata.
Setters
defaultDeserializeProperty
serializableDefaultDeserializeProperty Source #
:: (HasCallStack, MonadIO m, IsSerializable a) | |
=> a |
|
-> Text |
|
-> GValue |
|
-> GParamSpec |
|
-> Node |
|
-> m Bool | Returns: |
Calls the default implementation of the [vfuncjson
.Serializable.deserialize_property]
virtual function.
This function can be used inside a custom implementation of the
deserialize_property()
virtual function in lieu of calling the
default implementation through g_type_default_interface_peek()
:
``@c JsonSerializable *iface; gboolean res;
iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE); res = iface->deserialize_property (serializable, property_name, value, pspec, property_node); @``
Since: 0.10
defaultSerializeProperty
serializableDefaultSerializeProperty Source #
:: (HasCallStack, MonadIO m, IsSerializable a) | |
=> a |
|
-> Text |
|
-> GValue |
|
-> GParamSpec |
|
-> m (Maybe Node) | Returns: a node containing the serialized property |
Calls the default implementation of the [vfuncjson
.Serializable.serialize_property]
virtual function.
This function can be used inside a custom implementation of the
serialize_property()
virtual function in lieu of calling the
default implementation through g_type_default_interface_peek()
:
``@c JsonSerializable *iface; JsonNode *node;
iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
node = iface->serialize_property (serializable, property_name,
value,
pspec);
`
This function will return @NULL` if the property could not be serialized.
Since: 0.10
deserializeProperty
serializableDeserializeProperty Source #
:: (HasCallStack, MonadIO m, IsSerializable a) | |
=> a |
|
-> Text |
|
-> GParamSpec |
|
-> Node |
|
-> m (Bool, GValue) | Returns: |
Asks a JsonSerializable
implementation to deserialize the
property contained inside property_node
and place its value
into value
.
The value
can be:
- an empty
GValue
initialized byG_VALUE_INIT
, which will be automatically initialized with the expected type of the property by using the given property description (since JSON-GLib 1.6) - a
GValue
initialized with the expected type of the property
findProperty
serializableFindProperty Source #
:: (HasCallStack, MonadIO m, IsSerializable a) | |
=> a |
|
-> Text |
|
-> m (Maybe GParamSpec) | Returns: the property description |
Calls the [vfuncjson
.Serializable.find_property] implementation on
the JsonSerializable
instance, which will return the property
description for the given name.
Since: 0.14
getProperty
serializableGetProperty Source #
:: (HasCallStack, MonadIO m, IsSerializable a) | |
=> a |
|
-> GParamSpec |
|
-> m GValue |
Calls the [vfuncjson
.Serializable.get_property] implementation
on the JsonSerializable
instance, which will get the value of
the given property.
Since: 0.14
serializeProperty
serializableSerializeProperty Source #
:: (HasCallStack, MonadIO m, IsSerializable a) | |
=> a |
|
-> Text |
|
-> GValue |
|
-> GParamSpec |
|
-> m Node | Returns: a node containing the serialized property |
Asks a JsonSerializable
implementation to serialize an object
property into a JSON node.
setProperty
serializableSetProperty Source #
:: (HasCallStack, MonadIO m, IsSerializable a) | |
=> a |
|
-> GParamSpec |
|
-> GValue |
|
-> m () |
Calls the [vfuncjson
.Serializable.set_property] implementation
on the JsonSerializable
instance, which will set the property
with the given value.
Since: 0.14