-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | JSON GObject bindings
--
-- Low-level bindings for json-glib, autogenerated by haskell-gi.
@package gi-json
@version 1.0.2
-- | Build time configuration used during code generation.
module GI.Json.Config
-- | Overrides used when generating these bindings.
overrides :: Text
module GI.Json.Constants
-- | The version of JSON-GLib, encoded as a string, useful for printing and
-- concatenation.
pattern VERSION_S :: Text
-- | Json minor version component (e.g. 2 if JSON_VERSION is
-- "1.2.3")
pattern MINOR_VERSION :: Int32
-- | Json micro version component (e.g. 3 if JSON_VERSION is
-- "1.2.3")
pattern MICRO_VERSION :: Int32
-- | Json major version component (e.g. 1 if JSON_VERSION is
-- "1.2.3")
pattern MAJOR_VERSION :: Int32
module GI.Json.Enums
-- | Indicates the content of a node.
data NodeType
-- | The node contains a JSON object
NodeTypeObject :: NodeType
-- | The node contains a JSON array
NodeTypeArray :: NodeType
-- | The node contains a fundamental type
NodeTypeValue :: NodeType
-- | Special type, for nodes containing null
NodeTypeNull :: NodeType
-- | Catch-all for unknown values
AnotherNodeType :: Int -> NodeType
-- | Error codes for JSON_PARSER_ERROR.
--
-- This enumeration can be extended at later date
data ParserError
-- | parse error
ParserErrorParse :: ParserError
-- | unexpected trailing comma
ParserErrorTrailingComma :: ParserError
-- | expected comma
ParserErrorMissingComma :: ParserError
-- | expected colon
ParserErrorMissingColon :: ParserError
-- | invalid bareword
ParserErrorInvalidBareword :: ParserError
-- | empty member name (Since: 0.16)
ParserErrorEmptyMemberName :: ParserError
-- | invalid data (Since: 0.18)
ParserErrorInvalidData :: ParserError
-- | unknown error
ParserErrorUnknown :: ParserError
-- | Catch-all for unknown values
AnotherParserError :: Int -> ParserError
-- | Catch exceptions of type ParserError. This is a specialized
-- version of catchGErrorJustDomain.
catchParserError :: IO a -> (ParserError -> GErrorMessage -> IO a) -> IO a
-- | Handle exceptions of type ParserError. This is a specialized
-- version of handleGErrorJustDomain.
handleParserError :: (ParserError -> GErrorMessage -> IO a) -> IO a -> IO a
-- | Error codes for JSON_PATH_ERROR.
--
-- This enumeration can be extended at later date
--
-- Since: 0.14
data PathError
-- | Invalid query
PathErrorQuery :: PathError
-- | Catch-all for unknown values
AnotherPathError :: Int -> PathError
-- | Catch exceptions of type PathError. This is a specialized
-- version of catchGErrorJustDomain.
catchPathError :: IO a -> (PathError -> GErrorMessage -> IO a) -> IO a
-- | Handle exceptions of type PathError. This is a specialized
-- version of handleGErrorJustDomain.
handlePathError :: (PathError -> GErrorMessage -> IO a) -> IO a -> IO a
-- | Error codes for JSON_READER_ERROR.
--
-- This enumeration can be extended at later date
--
-- Since: 0.12
data ReaderError
-- | No array found at the current position
ReaderErrorNoArray :: ReaderError
-- | Index out of bounds
ReaderErrorInvalidIndex :: ReaderError
-- | No object found at the current position
ReaderErrorNoObject :: ReaderError
-- | Member not found
ReaderErrorInvalidMember :: ReaderError
-- | No valid node found at the current position
ReaderErrorInvalidNode :: ReaderError
-- | The node at the current position does not hold a value
ReaderErrorNoValue :: ReaderError
-- | The node at the current position does not hold a value of the desired
-- type
ReaderErrorInvalidType :: ReaderError
-- | Catch-all for unknown values
AnotherReaderError :: Int -> ReaderError
-- | Catch exceptions of type ReaderError. This is a specialized
-- version of catchGErrorJustDomain.
catchReaderError :: IO a -> (ReaderError -> GErrorMessage -> IO a) -> IO a
-- | Handle exceptions of type ReaderError. This is a specialized
-- version of handleGErrorJustDomain.
handleReaderError :: (ReaderError -> GErrorMessage -> IO a) -> IO a -> IO a
instance GHC.Classes.Eq GI.Json.Enums.ReaderError
instance GHC.Show.Show GI.Json.Enums.ReaderError
instance GHC.Classes.Eq GI.Json.Enums.PathError
instance GHC.Show.Show GI.Json.Enums.PathError
instance GHC.Classes.Eq GI.Json.Enums.ParserError
instance GHC.Show.Show GI.Json.Enums.ParserError
instance GHC.Classes.Eq GI.Json.Enums.NodeType
instance GHC.Show.Show GI.Json.Enums.NodeType
instance GHC.Enum.Enum GI.Json.Enums.NodeType
instance GHC.Classes.Ord GI.Json.Enums.NodeType
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Enums.NodeType
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Enums.NodeType
instance Data.GI.Base.BasicTypes.BoxedEnum GI.Json.Enums.NodeType
instance GHC.Enum.Enum GI.Json.Enums.ParserError
instance GHC.Classes.Ord GI.Json.Enums.ParserError
instance Data.GI.Base.GError.GErrorClass GI.Json.Enums.ParserError
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Enums.ParserError
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Enums.ParserError
instance Data.GI.Base.BasicTypes.BoxedEnum GI.Json.Enums.ParserError
instance GHC.Enum.Enum GI.Json.Enums.PathError
instance GHC.Classes.Ord GI.Json.Enums.PathError
instance Data.GI.Base.GError.GErrorClass GI.Json.Enums.PathError
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Enums.PathError
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Enums.PathError
instance Data.GI.Base.BasicTypes.BoxedEnum GI.Json.Enums.PathError
instance GHC.Enum.Enum GI.Json.Enums.ReaderError
instance GHC.Classes.Ord GI.Json.Enums.ReaderError
instance Data.GI.Base.GError.GErrorClass GI.Json.Enums.ReaderError
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Enums.ReaderError
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Enums.ReaderError
instance Data.GI.Base.BasicTypes.BoxedEnum GI.Json.Enums.ReaderError
-- | JsonObject is the representation of the object type inside
-- JSON.
--
-- A JsonObject contains [structjson.Node]
-- "members", which may contain fundamental types, arrays or other
-- objects; each member of an object is accessed using a unique string,
-- or "name".
--
-- Since objects can be arbitrarily big, copying them can be expensive;
-- for this reason they are reference counted. You can control the
-- lifetime of a JsonObject using
-- [methodjson.Object.ref] and
-- [methodjson.Object.unref].
--
-- To add or overwrite a member with a given name, use
-- [methodjson.Object.set_member].
--
-- To extract a member with a given name, use
-- [methodjson.Object.get_member].
--
-- To retrieve the list of members, use
-- [methodjson.Object.get_members].
--
-- To retrieve the size of the object (that is, the number of members it
-- has), use [methodjson.Object.get_size].
module GI.Json.Structs.Object
-- | Memory-managed wrapper type.
newtype Object
Object :: ManagedPtr Object -> Object
-- | Adds a new member for the given name and value into an object.
--
-- This function will return if the object already contains a member with
-- the same name.
-- | Deprecated: (Since version 0.8)Use
-- [methodjson.Object.set_member] instead
objectAddMember :: (HasCallStack, MonadIO m) => Object -> Text -> Node -> m ()
-- | Retrieves a copy of the value of the given member inside an object.
--
-- Since: 0.6
objectDupMember :: (HasCallStack, MonadIO m) => Object -> Text -> m (Maybe Node)
-- | Check whether a and b are equal
-- objects, meaning they have the same set of members, and the values of
-- corresponding members are equal.
--
-- Since: 1.2
objectEqual :: (HasCallStack, MonadIO m) => Object -> Object -> m Bool
-- | Iterates over all members of object and calls
-- func on each one of them.
--
-- It is safe to change the value of a member of the oobject from within
-- the iterator function, but it is not safe to add or remove members
-- from the object.
--
-- The order in which the object members are iterated is the insertion
-- order.
--
-- Since: 0.8
objectForeachMember :: (HasCallStack, MonadIO m) => Object -> ObjectForeach -> m ()
-- | Convenience function that retrieves the array stored in
-- memberName of object. It is an error
-- to specify a memberName which does not exist.
--
-- If memberName contains null, then this
-- function will return NULL.
--
-- See also: [methodjson.Object.get_member],
-- [methodjson.Object.has_member]
--
-- Since: 0.8
objectGetArrayMember :: (HasCallStack, MonadIO m) => Object -> Text -> m (Maybe Array)
-- | Convenience function that retrieves the boolean value stored in
-- memberName of object. It is an error
-- to specify a memberName which does not exist.
--
-- See also:
-- [methodjson.Object.get_boolean_member_with_default],
-- [methodjson.Object.get_member],
-- [methodjson.Object.has_member]
--
-- Since: 0.8
objectGetBooleanMember :: (HasCallStack, MonadIO m) => Object -> Text -> m Bool
-- | Convenience function that retrieves the boolean value stored in
-- memberName of object.
--
-- If memberName does not exist, does not contain a
-- scalar value, or contains null, then
-- defaultValue is returned instead.
--
-- Since: 1.6
objectGetBooleanMemberWithDefault :: (HasCallStack, MonadIO m) => Object -> Text -> Bool -> m Bool
-- | Convenience function that retrieves the floating point value stored in
-- memberName of object. It is an error
-- to specify a memberName which does not exist.
--
-- See also:
-- [methodjson.Object.get_double_member_with_default],
-- [methodjson.Object.get_member],
-- [methodjson.Object.has_member]
--
-- Since: 0.8
objectGetDoubleMember :: (HasCallStack, MonadIO m) => Object -> Text -> m Double
-- | Convenience function that retrieves the floating point value stored in
-- memberName of object.
--
-- If memberName does not exist, does not contain a
-- scalar value, or contains null, then
-- defaultValue is returned instead.
--
-- Since: 1.6
objectGetDoubleMemberWithDefault :: (HasCallStack, MonadIO m) => Object -> Text -> Double -> m Double
-- | Convenience function that retrieves the integer value stored in
-- memberName of object. It is an error
-- to specify a memberName which does not exist.
--
-- See also:
-- [methodjson.Object.get_int_member_with_default],
-- [methodjson.Object.get_member],
-- [methodjson.Object.has_member]
--
-- Since: 0.8
objectGetIntMember :: (HasCallStack, MonadIO m) => Object -> Text -> m Int64
-- | Convenience function that retrieves the integer value stored in
-- memberName of object.
--
-- If memberName does not exist, does not contain a
-- scalar value, or contains null, then
-- defaultValue is returned instead.
--
-- Since: 1.6
objectGetIntMemberWithDefault :: (HasCallStack, MonadIO m) => Object -> Text -> Int64 -> m Int64
-- | Retrieves the value of the given member inside an object.
objectGetMember :: (HasCallStack, MonadIO m) => Object -> Text -> m (Maybe Node)
-- | Retrieves all the names of the members of an object.
--
-- You can obtain the value for each member by iterating the returned
-- list and calling [methodjson.Object.get_member].
objectGetMembers :: (HasCallStack, MonadIO m) => Object -> m [Text]
-- | Convenience function that checks whether the value stored in
-- memberName of object is null. It is an
-- error to specify a memberName which does not exist.
--
-- See also: [methodjson.Object.get_member],
-- [methodjson.Object.has_member]
--
-- Since: 0.8
objectGetNullMember :: (HasCallStack, MonadIO m) => Object -> Text -> m Bool
-- | Convenience function that retrieves the object stored in
-- memberName of object. It is an error
-- to specify a memberName which does not exist.
--
-- If memberName contains null, then this
-- function will return NULL.
--
-- See also: [methodjson.Object.get_member],
-- [methodjson.Object.has_member]
--
-- Since: 0.8
objectGetObjectMember :: (HasCallStack, MonadIO m) => Object -> Text -> m (Maybe Object)
-- | Retrieves the number of members of a JSON object.
objectGetSize :: (HasCallStack, MonadIO m) => Object -> m Word32
-- | Convenience function that retrieves the string value stored in
-- memberName of object. It is an error
-- to specify a memberName that does not exist.
--
-- See also:
-- [methodjson.Object.get_string_member_with_default],
-- [methodjson.Object.get_member],
-- [methodjson.Object.has_member]
--
-- Since: 0.8
objectGetStringMember :: (HasCallStack, MonadIO m) => Object -> Text -> m Text
-- | Convenience function that retrieves the string value stored in
-- memberName of object.
--
-- If memberName does not exist, does not contain a
-- scalar value, or contains null, then
-- defaultValue is returned instead.
--
-- Since: 1.6
objectGetStringMemberWithDefault :: (HasCallStack, MonadIO m) => Object -> Text -> Text -> m Text
-- | Retrieves all the values of the members of an object.
objectGetValues :: (HasCallStack, MonadIO m) => Object -> m [Node]
-- | Checks whether object has a member named
-- memberName.
objectHasMember :: (HasCallStack, MonadIO m) => Object -> Text -> m Bool
-- | Calculate a hash value for the given key (a JSON
-- object).
--
-- The hash is calculated over the object and all its members,
-- recursively. If the object is immutable, this is a fast operation;
-- otherwise, it scales proportionally with the number of members in the
-- object.
--
-- Since: 1.2
objectHash :: (HasCallStack, MonadIO m) => Object -> m Word32
-- | Checks whether the given object has been marked as immutable by
-- calling [methodjson.Object.seal] on it.
--
-- Since: 1.2
objectIsImmutable :: (HasCallStack, MonadIO m) => Object -> m Bool
-- | Creates a new object.
objectNew :: (HasCallStack, MonadIO m) => m Object
-- | Acquires a reference on the given object.
objectRef :: (HasCallStack, MonadIO m) => Object -> m Object
-- | Removes memberName from object,
-- freeing its allocated resources.
objectRemoveMember :: (HasCallStack, MonadIO m) => Object -> Text -> m ()
-- | Seals the object, making it immutable to further changes.
--
-- This function will recursively seal all members of the object too.
--
-- If the object is already immutable, this is a no-op.
--
-- Since: 1.2
objectSeal :: (HasCallStack, MonadIO m) => Object -> m ()
-- | Convenience function for setting an object member with an array value.
--
-- See also: [methodjson.Object.set_member],
-- [methodjson.Node.take_array]
--
-- Since: 0.8
objectSetArrayMember :: (HasCallStack, MonadIO m) => Object -> Text -> Array -> m ()
-- | Convenience function for setting an object member with a boolean
-- value.
--
-- See also: [methodjson.Object.set_member],
-- [methodjson.Node.init_boolean]
--
-- Since: 0.8
objectSetBooleanMember :: (HasCallStack, MonadIO m) => Object -> Text -> Bool -> m ()
-- | Convenience function for setting an object member with a floating
-- point value.
--
-- See also: [methodjson.Object.set_member],
-- [methodjson.Node.init_double]
--
-- Since: 0.8
objectSetDoubleMember :: (HasCallStack, MonadIO m) => Object -> Text -> Double -> m ()
-- | Convenience function for setting an object member with an integer
-- value.
--
-- See also: [methodjson.Object.set_member],
-- [methodjson.Node.init_int]
--
-- Since: 0.8
objectSetIntMember :: (HasCallStack, MonadIO m) => Object -> Text -> Int64 -> m ()
-- | Sets the value of a member inside an object.
--
-- If the object does not have a member with the given name, a new member
-- is created.
--
-- If the object already has a member with the given name, the current
-- value is overwritten with the new.
--
-- Since: 0.8
objectSetMember :: (HasCallStack, MonadIO m) => Object -> Text -> Node -> m ()
-- | Convenience function for setting an object member with a null
-- value.
--
-- See also: [methodjson.Object.set_member],
-- [methodjson.Node.init_null]
--
-- Since: 0.8
objectSetNullMember :: (HasCallStack, MonadIO m) => Object -> Text -> m ()
-- | Convenience function for setting an object member with an object
-- value.
--
-- See also: [methodjson.Object.set_member],
-- [methodjson.Node.take_object]
--
-- Since: 0.8
objectSetObjectMember :: (HasCallStack, MonadIO m) => Object -> Text -> Object -> m ()
-- | Convenience function for setting an object member with a string value.
--
-- See also: [methodjson.Object.set_member],
-- [methodjson.Node.init_string]
--
-- Since: 0.8
objectSetStringMember :: (HasCallStack, MonadIO m) => Object -> Text -> Text -> m ()
-- | Releases a reference on the given object.
--
-- If the reference count reaches zero, the object is destroyed and all
-- its resources are freed.
objectUnref :: (HasCallStack, MonadIO m) => Object -> m ()
instance GHC.Classes.Eq GI.Json.Structs.Object.Object
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Structs.Object.Object
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Structs.Object.Object
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Structs.Object.Object
instance Data.GI.Base.BasicTypes.GBoxed GI.Json.Structs.Object.Object
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Structs.Object.Object)
-- | A generic container of JSON data types.
--
-- JsonNode can contain fundamental types (integers, booleans,
-- floating point numbers, strings) and complex types (arrays and
-- objects).
--
-- When parsing a JSON data stream you extract the root node and walk the
-- node tree by retrieving the type of data contained inside the node
-- with the JSON_NODE_TYPE macro. If the node contains a
-- fundamental type you can retrieve a copy of the GValue
-- holding it with the [methodjson.Node.get_value]
-- function, and then use the GValue API to extract the data; if
-- the node contains a complex type you can retrieve the
-- [structjson.Object] or the
-- [structjson.Array] using
-- [methodjson.Node.get_object] or
-- [methodjson.Node.get_array] respectively, and then
-- retrieve the nodes they contain.
--
-- A JsonNode may be marked as immutable using
-- [methodjson.Node.seal]. This marks the node and all
-- its descendents as read-only, and means that subsequent calls to
-- setter functions (such as [methodjson.Node.set_array])
-- on them will abort as a programmer error. By marking a node tree as
-- immutable, it may be referenced in multiple places and its hash value
-- cached for fast lookups, without the possibility of a value deep
-- within the tree changing and affecting hash values. Immutable nodes
-- may be passed to functions which retain a reference to them without
-- needing to take a copy.
--
-- A JsonNode supports two types of memory management:
-- malloc/free semantics, and reference counting
-- semantics. The two may be mixed to a limited extent: nodes may be
-- allocated (which gives them a reference count of 1), referenced one or
-- more times, unreferenced exactly that number of times (using
-- [methodjson.Node.unref]), then either unreferenced
-- exactly once more or freed (using
-- [methodjson.Node.free]) to destroy them. The
-- [methodjson.Node.free] function must not be used when
-- a node might have a reference count not equal to 1. To this end,
-- JSON-GLib uses [methodjson.Node.copy] and
-- [methodjson.Node.unref] internally.
module GI.Json.Structs.Node
-- | Memory-managed wrapper type.
newtype Node
Node :: ManagedPtr Node -> Node
-- | Allocates a new, uninitialized node.
--
-- Use [methodjson.Node.init] and its variants to
-- initialize the returned value.
--
-- Since: 0.16
nodeAlloc :: (HasCallStack, MonadIO m) => m Node
-- | Copies node.
--
-- If the node contains complex data types, their reference counts are
-- increased, regardless of whether the node is mutable or immutable.
--
-- The copy will be immutable if, and only if, node is
-- immutable. However, there should be no need to copy an immutable node.
nodeCopy :: (HasCallStack, MonadIO m) => Node -> m Node
-- | Retrieves the JSON array inside node.
--
-- The reference count of the returned array is increased.
--
-- It is a programmer error to call this on a node which doesn’t hold an
-- array value. Use JSON_NODE_HOLDS_ARRAY first.
nodeDupArray :: (HasCallStack, MonadIO m) => Node -> m (Maybe Array)
-- | Retrieves the object inside node.
--
-- The reference count of the returned object is increased.
--
-- It is a programmer error to call this on a node which doesn’t hold an
-- object value. Use JSON_NODE_HOLDS_OBJECT first.
nodeDupObject :: (HasCallStack, MonadIO m) => Node -> m (Maybe Object)
-- | Gets a copy of the string value stored inside a node.
--
-- If the node does not hold a string value, NULL is returned.
nodeDupString :: (HasCallStack, MonadIO m) => Node -> m (Maybe Text)
-- | Check whether a and b are equal node,
-- meaning they have the same type and same values (checked recursively).
--
-- Note that integer values are compared numerically, ignoring type, so a
-- double value 4.0 is equal to the integer value 4.
--
-- Since: 1.2
nodeEqual :: (HasCallStack, MonadIO m) => Node -> Node -> m Bool
-- | Frees the resources allocated by the node.
nodeFree :: (HasCallStack, MonadIO m) => Node -> m ()
-- | Retrieves the JSON array stored inside a node.
--
-- It is a programmer error to call this on a node which doesn’t hold an
-- array value. Use JSON_NODE_HOLDS_ARRAY first.
nodeGetArray :: (HasCallStack, MonadIO m) => Node -> m (Maybe Array)
-- | Gets the boolean value stored inside a node.
--
-- If the node holds an integer or double value which is zero,
-- FALSE is returned; otherwise TRUE is returned.
--
-- If the node holds a JSON_NODE_NULL value or a value of
-- another non-boolean type, FALSE is returned.
nodeGetBoolean :: (HasCallStack, MonadIO m) => Node -> m Bool
-- | Gets the double value stored inside a node.
--
-- If the node holds an integer value, it is returned as a double.
--
-- If the node holds a FALSE boolean value, 0.0 is
-- returned; otherwise a non-zero double is returned.
--
-- If the node holds a JSON_NODE_NULL value or a value of
-- another non-double type, 0.0 is returned.
nodeGetDouble :: (HasCallStack, MonadIO m) => Node -> m Double
-- | Gets the integer value stored inside a node.
--
-- If the node holds a double value, its integer component is returned.
--
-- If the node holds a FALSE boolean value, 0 is
-- returned; otherwise, a non-zero integer is returned.
--
-- If the node holds a JSON_NODE_NULL value or a value of
-- another non-integer type, 0 is returned.
nodeGetInt :: (HasCallStack, MonadIO m) => Node -> m Int64
-- | Retrieves the type of a node.
--
-- Since: 0.8
nodeGetNodeType :: (HasCallStack, MonadIO m) => Node -> m NodeType
-- | Retrieves the object stored inside a node.
--
-- It is a programmer error to call this on a node which doesn’t hold an
-- object value. Use JSON_NODE_HOLDS_OBJECT first.
nodeGetObject :: (HasCallStack, MonadIO m) => Node -> m (Maybe Object)
-- | Retrieves the parent node of the given node.
nodeGetParent :: (HasCallStack, MonadIO m) => Node -> m (Maybe Node)
-- | Gets the string value stored inside a node.
--
-- If the node does not hold a string value, NULL is returned.
nodeGetString :: (HasCallStack, MonadIO m) => Node -> m (Maybe Text)
-- | Retrieves a value from a node and copies into value.
--
-- When done using it, call g_value_unset() on the
-- GValue to free the associated resources.
--
-- It is a programmer error to call this on a node which doesn’t hold a
-- scalar value. Use JSON_NODE_HOLDS_VALUE first.
nodeGetValue :: (HasCallStack, MonadIO m) => Node -> m GValue
-- | Returns the GType of the payload of the node.
--
-- For JSON_NODE_NULL nodes, the returned type is
-- G_TYPE_INVALID.
--
-- Since: 0.4
nodeGetValueType :: (HasCallStack, MonadIO m) => Node -> m GType
-- | Calculate a hash value for the given key.
--
-- The hash is calculated over the node and its value, recursively. If
-- the node is immutable, this is a fast operation; otherwise, it scales
-- proportionally with the size of the node’s value (for example, with
-- the number of members in the JSON object if this node contains an
-- object).
--
-- Since: 1.2
nodeHash :: (HasCallStack, MonadIO m) => Node -> m Word32
-- | Initializes a node to a specific type.
--
-- If the node has already been initialized once, it will be reset to the
-- given type, and any data contained will be cleared.
--
-- Since: 0.16
nodeInit :: (HasCallStack, MonadIO m) => Node -> NodeType -> m Node
-- | Initializes node to JSON_NODE_ARRAY and sets
-- array into it.
--
-- This function will take a reference on array.
--
-- If the node has already been initialized once, it will be reset to the
-- given type, and any data contained will be cleared.
--
-- Since: 0.16
nodeInitArray :: (HasCallStack, MonadIO m) => Node -> Maybe Array -> m Node
-- | Initializes node to JSON_NODE_VALUE and sets
-- value into it.
--
-- If the node has already been initialized once, it will be reset to the
-- given type, and any data contained will be cleared.
--
-- Since: 0.16
nodeInitBoolean :: (HasCallStack, MonadIO m) => Node -> Bool -> m Node
-- | Initializes node to JSON_NODE_VALUE and sets
-- value into it.
--
-- If the node has already been initialized once, it will be reset to the
-- given type, and any data contained will be cleared.
--
-- Since: 0.16
nodeInitDouble :: (HasCallStack, MonadIO m) => Node -> Double -> m Node
-- | Initializes node to JSON_NODE_VALUE and sets
-- value into it.
--
-- If the node has already been initialized once, it will be reset to the
-- given type, and any data contained will be cleared.
--
-- Since: 0.16
nodeInitInt :: (HasCallStack, MonadIO m) => Node -> Int64 -> m Node
-- | Initializes node to JSON_NODE_NULL.
--
-- If the node has already been initialized once, it will be reset to the
-- given type, and any data contained will be cleared.
--
-- Since: 0.16
nodeInitNull :: (HasCallStack, MonadIO m) => Node -> m Node
-- | Initializes node to JSON_NODE_OBJECT and sets
-- object into it.
--
-- This function will take a reference on object.
--
-- If the node has already been initialized once, it will be reset to the
-- given type, and any data contained will be cleared.
--
-- Since: 0.16
nodeInitObject :: (HasCallStack, MonadIO m) => Node -> Maybe Object -> m Node
-- | Initializes node to JSON_NODE_VALUE and sets
-- value into it.
--
-- If the node has already been initialized once, it will be reset to the
-- given type, and any data contained will be cleared.
--
-- Since: 0.16
nodeInitString :: (HasCallStack, MonadIO m) => Node -> Maybe Text -> m Node
-- | Check whether the given node has been marked as
-- immutable by calling [methodjson.Node.seal] on it.
--
-- Since: 1.2
nodeIsImmutable :: (HasCallStack, MonadIO m) => Node -> m Bool
-- | Checks whether node is a JSON_NODE_NULL.
--
-- A JSON_NODE_NULL node is not the same as a NULL
-- node; a JSON_NODE_NULL represents a literal null
-- value in the JSON tree.
--
-- Since: 0.8
nodeIsNull :: (HasCallStack, MonadIO m) => Node -> m Bool
-- | Creates a new node holding the given type.
--
-- This is a convenience function for
-- [ctorjson.Node.alloc] and
-- [methodjson.Node.init], and it's the equivalent of:
--
-- ``c json_node_init (json_node_alloc (), type); ``
nodeNew :: (HasCallStack, MonadIO m) => NodeType -> m Node
-- | Increments the reference count of node.
--
-- Since: 1.2
nodeRef :: (HasCallStack, MonadIO m) => Node -> m Node
-- | Seals the given node, making it immutable to further changes.
--
-- In order to be sealed, the node must have a type and
-- value set. The value will be recursively sealed — if the node holds an
-- object, that JSON object will be sealed, etc.
--
-- If the node is already immutable, this is a no-op.
--
-- Since: 1.2
nodeSeal :: (HasCallStack, MonadIO m) => Node -> m ()
-- | Sets array inside node.
--
-- The reference count of array is increased.
--
-- It is a programmer error to call this on a node which doesn’t hold an
-- array value. Use JSON_NODE_HOLDS_ARRAY first.
nodeSetArray :: (HasCallStack, MonadIO m) => Node -> Array -> m ()
-- | Sets value as the boolean content of the
-- node, replacing any existing content.
--
-- It is an error to call this on an immutable node, or on a node which
-- is not a value node.
nodeSetBoolean :: (HasCallStack, MonadIO m) => Node -> Bool -> m ()
-- | Sets value as the double content of the
-- node, replacing any existing content.
--
-- It is an error to call this on an immutable node, or on a node which
-- is not a value node.
nodeSetDouble :: (HasCallStack, MonadIO m) => Node -> Double -> m ()
-- | Sets value as the integer content of the
-- node, replacing any existing content.
--
-- It is an error to call this on an immutable node, or on a node which
-- is not a value node.
nodeSetInt :: (HasCallStack, MonadIO m) => Node -> Int64 -> m ()
-- | Sets objects inside node.
--
-- The reference count of object is increased.
--
-- If object is NULL, the node’s existing object
-- is cleared.
--
-- It is an error to call this on an immutable node, or on a node which
-- is not an object node.
nodeSetObject :: (HasCallStack, MonadIO m) => Node -> Maybe Object -> m ()
-- | Sets the parent node for the given node.
--
-- It is an error to call this with an immutable parent.
--
-- The node may be immutable.
--
-- Since: 0.8
nodeSetParent :: (HasCallStack, MonadIO m) => Node -> Maybe Node -> m ()
-- | Sets value as the string content of the
-- node, replacing any existing content.
--
-- It is an error to call this on an immutable node, or on a node which
-- is not a value node.
nodeSetString :: (HasCallStack, MonadIO m) => Node -> Text -> m ()
-- | Sets a scalar value inside the given node.
--
-- The contents of the given GValue are copied into the
-- JsonNode.
--
-- The following GValue types have a direct mapping to JSON
-- types:
--
--
-- G_TYPE_INT64
-- G_TYPE_DOUBLE
-- G_TYPE_BOOLEAN
-- G_TYPE_STRING
--
--
-- JSON-GLib will also automatically promote the following
-- GValue types:
--
--
-- - G_TYPE_INT to G_TYPE_INT64
-- - G_TYPE_FLOAT to G_TYPE_DOUBLE
--
--
-- It is an error to call this on an immutable node, or on a node which
-- is not a value node.
nodeSetValue :: (HasCallStack, MonadIO m) => Node -> GValue -> m ()
-- | Sets array inside node.
--
-- The reference count of array is not increased.
--
-- It is a programmer error to call this on a node which doesn’t hold an
-- array value. Use JSON_NODE_HOLDS_ARRAY first.
nodeTakeArray :: (HasCallStack, MonadIO m) => Node -> Array -> m ()
-- | Sets object inside node.
--
-- The reference count of object is not increased.
--
-- It is an error to call this on an immutable node, or on a node which
-- is not an object node.
nodeTakeObject :: (HasCallStack, MonadIO m) => Node -> Object -> m ()
-- | Retrieves the user readable name of the data type contained by
-- node.
--
--
-- - *Note**: The name is only meant for debugging purposes, and there
-- is no guarantee the name will stay the same across different
-- versions.
--
nodeTypeName :: (HasCallStack, MonadIO m) => Node -> m Text
-- | Decrements the reference count of node.
--
-- If the reference count reaches zero, the node is freed.
--
-- Since: 1.2
nodeUnref :: (HasCallStack, MonadIO m) => Node -> m ()
instance GHC.Classes.Eq GI.Json.Structs.Node.Node
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Structs.Node.Node
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Structs.Node.Node
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Structs.Node.Node
instance Data.GI.Base.BasicTypes.GBoxed GI.Json.Structs.Node.Node
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Structs.Node.Node)
-- | 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].
module GI.Json.Structs.Array
-- | Memory-managed wrapper type.
newtype Array
Array :: ManagedPtr Array -> Array
-- | 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
arrayAddArrayElement :: (HasCallStack, MonadIO m) => Array -> Maybe Array -> m ()
-- | Conveniently adds the given boolean value into an array.
--
-- See also: [methodjson.Array.add_element],
-- [methodjson.Node.set_boolean]
--
-- Since: 0.8
arrayAddBooleanElement :: (HasCallStack, MonadIO m) => Array -> Bool -> m ()
-- | Conveniently adds the given floating point value into an array.
--
-- See also: [methodjson.Array.add_element],
-- [methodjson.Node.set_double]
--
-- Since: 0.8
arrayAddDoubleElement :: (HasCallStack, MonadIO m) => Array -> Double -> m ()
-- | Appends the given node inside an array.
arrayAddElement :: (HasCallStack, MonadIO m) => Array -> Node -> m ()
-- | Conveniently adds the given integer value into an array.
--
-- See also: [methodjson.Array.add_element],
-- [methodjson.Node.set_int]
--
-- Since: 0.8
arrayAddIntElement :: (HasCallStack, MonadIO m) => Array -> Int64 -> m ()
-- | Conveniently adds a null element into an array
--
-- See also: [methodjson.Array.add_element],
-- JSON_NODE_NULL
--
-- Since: 0.8
arrayAddNullElement :: (HasCallStack, MonadIO m) => Array -> 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
arrayAddObjectElement :: (HasCallStack, MonadIO m) => Array -> Maybe Object -> m ()
-- | Conveniently adds the given string value into an array.
--
-- See also: [methodjson.Array.add_element],
-- [methodjson.Node.set_string]
--
-- Since: 0.8
arrayAddStringElement :: (HasCallStack, MonadIO m) => Array -> Text -> m ()
-- | Retrieves a copy of the element at the given position in the array.
--
-- Since: 0.6
arrayDupElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Node
-- | 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
arrayEqual :: (HasCallStack, MonadIO m) => Array -> Array -> m Bool
-- | 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
arrayForeachElement :: (HasCallStack, MonadIO m) => Array -> ArrayForeach -> m ()
-- | Conveniently retrieves the array at the given position inside an
-- array.
--
-- See also: [methodjson.Array.get_element],
-- [methodjson.Node.get_array]
--
-- Since: 0.8
arrayGetArrayElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Array
-- | 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
arrayGetBooleanElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Bool
-- | 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
arrayGetDoubleElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Double
-- | Retrieves the element at the given position in the array.
arrayGetElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Node
-- | Retrieves all the elements of an array as a list of nodes.
arrayGetElements :: (HasCallStack, MonadIO m) => Array -> m [Node]
-- | 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
arrayGetIntElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Int64
-- | Retrieves the length of the given array
arrayGetLength :: (HasCallStack, MonadIO m) => Array -> m Word32
-- | 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
arrayGetNullElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Bool
-- | Conveniently retrieves the object at the given position inside an
-- array.
--
-- See also: [methodjson.Array.get_element],
-- [methodjson.Node.get_object]
--
-- Since: 0.8
arrayGetObjectElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Object
-- | 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
arrayGetStringElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> m Text
-- | 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
arrayHash :: (HasCallStack, MonadIO m) => Array -> m Word32
-- | Check whether the given array has been marked as immutable by
-- calling [methodjson.Array.seal] on it.
--
-- Since: 1.2
arrayIsImmutable :: (HasCallStack, MonadIO m) => Array -> m Bool
-- | Creates a new array.
arrayNew :: (HasCallStack, MonadIO m) => m Array
-- | Acquires a reference on the given array.
arrayRef :: (HasCallStack, MonadIO m) => Array -> m Array
-- | Removes the element at the given position inside an array.
--
-- This function will release the reference held on the element.
arrayRemoveElement :: (HasCallStack, MonadIO m) => Array -> Word32 -> 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
arraySeal :: (HasCallStack, MonadIO m) => Array -> m ()
-- | Creates a new array with n_elements slots already allocated.
arraySizedNew :: (HasCallStack, MonadIO m) => Word32 -> m Array
-- | Releases a reference on the given array.
--
-- If the reference count reaches zero, the array is destroyed and all
-- its allocated resources are freed.
arrayUnref :: (HasCallStack, MonadIO m) => Array -> m ()
instance GHC.Classes.Eq GI.Json.Structs.Array.Array
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Structs.Array.Array
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Structs.Array.Array
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Structs.Array.Array
instance Data.GI.Base.BasicTypes.GBoxed GI.Json.Structs.Array.Array
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Structs.Array.Array)
module GI.Json.Callbacks
-- | The function to be passed to
-- [methodjson.Array.foreach_element].
--
-- You should not add or remove elements to and from
-- array within this function.
--
-- It is safe to change the value of elementNode.
--
-- Since: 0.8
type ArrayForeach = Array " /@array@/: the iterated JSON array" -> Word32 " /@index_@/: the index of the element" -> Node " /@elementNode@/: the value of the element at the given /@index_@/" -> IO ()
-- | The function to be passed to
-- [methodjson.Array.foreach_element].
--
-- You should not add or remove elements to and from
-- array within this function.
--
-- It is safe to change the value of elementNode.
--
-- Since: 0.8
type ArrayForeach_WithClosures = Array " /@array@/: the iterated JSON array" -> Word32 " /@index_@/: the index of the element" -> Node " /@elementNode@/: the value of the element at the given /@index_@/" -> Ptr () " /@userData@/: data passed to the function" -> IO ()
-- | Type for the callback on the (unwrapped) C side.
type C_ArrayForeach = Ptr Array -> Word32 -> Ptr Node -> Ptr () -> IO ()
-- | A simple wrapper that ignores the closure arguments.
drop_closures_ArrayForeach :: ArrayForeach -> ArrayForeach_WithClosures
-- | Given a pointer to a foreign C function, wrap it into a function
-- callable from Haskell.
dynamic_ArrayForeach :: (HasCallStack, MonadIO m) => FunPtr C_ArrayForeach -> Array -> Word32 -> Node -> Ptr () -> m ()
-- | Wrap the callback into a GClosure.
genClosure_ArrayForeach :: MonadIO m => ArrayForeach -> m (GClosure C_ArrayForeach)
-- | Generate a function pointer callable from C code, from a
-- C_ArrayForeach.
mk_ArrayForeach :: C_ArrayForeach -> IO (FunPtr C_ArrayForeach)
-- | A convenience synonym for Nothing :: Maybe
-- ArrayForeach.
noArrayForeach :: Maybe ArrayForeach
-- | A convenience synonym for Nothing :: Maybe
-- ArrayForeach_WithClosures.
noArrayForeach_WithClosures :: Maybe ArrayForeach_WithClosures
-- | Wrap a ArrayForeach into a C_ArrayForeach.
wrap_ArrayForeach :: Maybe (Ptr (FunPtr C_ArrayForeach)) -> ArrayForeach_WithClosures -> C_ArrayForeach
-- | Deserializes the contents of the passed JsonNode into a
-- GBoxed, for instance:
--
-- ``@c static gpointer my_point_deserialize (JsonNode *node) { double x
-- = 0.0, y = 0.0;
--
-- if (JSON_NODE_HOLDS_ARRAY (node)) { JsonArray *array =
-- json_node_get_array (node);
--
-- if (json_array_get_length (array) == 2) { x =
-- json_array_get_double_element (array, 0); y =
-- json_array_get_double_element (array, 1); } } else if
-- (JSON_NODE_HOLDS_OBJECT (node)) { JsonObject *obj =
-- json_node_get_object (node);
--
-- x = json_object_get_double_member_with_default (obj, "x", 0.0); y =
-- json_object_get_double_member_with_default (obj, "y", 0.0); }
--
-- // my_point_new() is defined elsewhere return my_point_new (x, y); }
-- @``
--
-- Since: 0.10
type BoxedDeserializeFunc = Node " /@node@/: a node tree representing a boxed data" -> IO (Ptr ()) " __Returns:__ the newly created boxed structure"
-- | Type for the callback on the (unwrapped) C side.
type C_BoxedDeserializeFunc = Ptr Node -> IO (Ptr ())
-- | Given a pointer to a foreign C function, wrap it into a function
-- callable from Haskell.
dynamic_BoxedDeserializeFunc :: (HasCallStack, MonadIO m) => FunPtr C_BoxedDeserializeFunc -> Node -> m (Ptr ())
-- | Wrap the callback into a GClosure.
genClosure_BoxedDeserializeFunc :: MonadIO m => BoxedDeserializeFunc -> m (GClosure C_BoxedDeserializeFunc)
-- | Generate a function pointer callable from C code, from a
-- C_BoxedDeserializeFunc.
mk_BoxedDeserializeFunc :: C_BoxedDeserializeFunc -> IO (FunPtr C_BoxedDeserializeFunc)
-- | A convenience synonym for Nothing :: Maybe
-- BoxedDeserializeFunc.
noBoxedDeserializeFunc :: Maybe BoxedDeserializeFunc
-- | Wrap a BoxedDeserializeFunc into a
-- C_BoxedDeserializeFunc.
wrap_BoxedDeserializeFunc :: Maybe (Ptr (FunPtr C_BoxedDeserializeFunc)) -> BoxedDeserializeFunc -> C_BoxedDeserializeFunc
-- | Serializes the passed GBoxed and stores it inside a
-- JsonNode, for instance:
--
-- ``@c static JsonNode * my_point_serialize (gconstpointer boxed) {
-- const MyPoint *point = boxed;
--
-- g_autoptr(JsonBuilder) builder = json_builder_new ();
--
-- json_builder_begin_object (builder); json_builder_set_member_name
-- (builder, "x"); json_builder_add_double_value (builder, point->x);
-- json_builder_set_member_name (builder, "y");
-- json_builder_add_double_value (builder, point->y);
-- json_builder_end_object (builder);
--
-- return json_builder_get_root (builder); } @``
--
-- Since: 0.10
type BoxedSerializeFunc = Ptr () " /@boxed@/: a boxed data structure" -> IO Node " __Returns:__ the newly created JSON node tree representing the boxed data"
-- | Type for the callback on the (unwrapped) C side.
type C_BoxedSerializeFunc = Ptr () -> IO (Ptr Node)
-- | Given a pointer to a foreign C function, wrap it into a function
-- callable from Haskell.
dynamic_BoxedSerializeFunc :: (HasCallStack, MonadIO m) => FunPtr C_BoxedSerializeFunc -> Ptr () -> m Node
-- | Wrap the callback into a GClosure.
genClosure_BoxedSerializeFunc :: MonadIO m => BoxedSerializeFunc -> m (GClosure C_BoxedSerializeFunc)
-- | Generate a function pointer callable from C code, from a
-- C_BoxedSerializeFunc.
mk_BoxedSerializeFunc :: C_BoxedSerializeFunc -> IO (FunPtr C_BoxedSerializeFunc)
-- | A convenience synonym for Nothing :: Maybe
-- BoxedSerializeFunc.
noBoxedSerializeFunc :: Maybe BoxedSerializeFunc
-- | Wrap a BoxedSerializeFunc into a C_BoxedSerializeFunc.
wrap_BoxedSerializeFunc :: Maybe (Ptr (FunPtr C_BoxedSerializeFunc)) -> BoxedSerializeFunc -> C_BoxedSerializeFunc
-- | Type for the callback on the (unwrapped) C side.
type C_ObjectForeach = Ptr Object -> CString -> Ptr Node -> Ptr () -> IO ()
-- | The function to be passed to
-- [methodjson.Object.foreach_member].
--
-- You should not add or remove members to and from
-- object within this function.
--
-- It is safe to change the value of memberNode.
--
-- Since: 0.8
type ObjectForeach = Object " /@object@/: the iterated JSON object" -> Text " /@memberName@/: the name of the member" -> Node " /@memberNode@/: the value of the member" -> IO ()
-- | The function to be passed to
-- [methodjson.Object.foreach_member].
--
-- You should not add or remove members to and from
-- object within this function.
--
-- It is safe to change the value of memberNode.
--
-- Since: 0.8
type ObjectForeach_WithClosures = Object " /@object@/: the iterated JSON object" -> Text " /@memberName@/: the name of the member" -> Node " /@memberNode@/: the value of the member" -> Ptr () " /@userData@/: data passed to the function" -> IO ()
-- | A simple wrapper that ignores the closure arguments.
drop_closures_ObjectForeach :: ObjectForeach -> ObjectForeach_WithClosures
-- | Given a pointer to a foreign C function, wrap it into a function
-- callable from Haskell.
dynamic_ObjectForeach :: (HasCallStack, MonadIO m) => FunPtr C_ObjectForeach -> Object -> Text -> Node -> Ptr () -> m ()
-- | Wrap the callback into a GClosure.
genClosure_ObjectForeach :: MonadIO m => ObjectForeach -> m (GClosure C_ObjectForeach)
-- | Generate a function pointer callable from C code, from a
-- C_ObjectForeach.
mk_ObjectForeach :: C_ObjectForeach -> IO (FunPtr C_ObjectForeach)
-- | A convenience synonym for Nothing :: Maybe
-- ObjectForeach.
noObjectForeach :: Maybe ObjectForeach
-- | A convenience synonym for Nothing :: Maybe
-- ObjectForeach_WithClosures.
noObjectForeach_WithClosures :: Maybe ObjectForeach_WithClosures
-- | Wrap a ObjectForeach into a C_ObjectForeach.
wrap_ObjectForeach :: Maybe (Ptr (FunPtr C_ObjectForeach)) -> ObjectForeach_WithClosures -> C_ObjectForeach
-- | JsonReader provides a simple, cursor-based API for parsing a
-- JSON DOM.
--
-- It is similar, in spirit, to the XML Reader API.
--
-- Using JsonReader
--
-- ``@c g_autoptr(JsonParser) parser = json_parser_new ();
--
-- // str is defined elsewhere json_parser_load_from_data (parser, str,
-- -1, NULL);
--
-- g_autoptr(JsonReader) reader = json_reader_new (json_parser_get_root
-- (parser));
--
-- json_reader_read_member (reader, "url"); const char *url =
-- json_reader_get_string_value (reader); json_reader_end_member
-- (reader);
--
-- json_reader_read_member (reader, "size"); json_reader_read_element
-- (reader, 0); int width = json_reader_get_int_value (reader);
-- json_reader_end_element (reader); json_reader_read_element (reader,
-- 1); int height = json_reader_get_int_value (reader);
-- json_reader_end_element (reader); json_reader_end_member (reader);
-- `
--
-- ## Error handling
--
-- In case of error, JsonReader will be set in an error state;
-- all subsequent calls will simply be ignored until a function that
-- resets the error state is called, e.g.:
--
-- `c // ask for the 7th element; if the element does not exist,
-- the // reader will be put in an error state json_reader_read_element
-- (reader, 6);
--
-- // in case of error, this will return NULL, otherwise it will //
-- return the value of the element str = json_reader_get_string_value
-- (value);
--
-- // this function resets the error state if any was set
-- json_reader_end_element (reader); `
--
-- If you want to detect the error state as soon as possible, you can use
-- [method@Json.Reader.get_error]:
--
-- `c // like the example above, but in this case we print out
-- the // error immediately if (!json_reader_read_element (reader, 6)) {
-- const GError *error = json_reader_get_error (reader); g_print ("Unable
-- to read the element: %s", error->message); } @``
--
-- Since: 0.12
module GI.Json.Objects.Reader
-- | Memory-managed wrapper type.
newtype Reader
Reader :: ManagedPtr Reader -> Reader
-- | Type class for types which can be safely cast to Reader, for
-- instance with toReader.
class (GObject o, IsDescendantOf Reader o) => IsReader o
-- | Cast to Reader, for types for which this is known to be safe.
-- For general casts, use castTo.
toReader :: (MonadIO m, IsReader o) => o -> m Reader
-- | Counts the elements of the current position, if the reader is
-- positioned on an array.
--
-- In case of failure, the reader is set to an error state.
--
-- Since: 0.12
readerCountElements :: (HasCallStack, MonadIO m, IsReader a) => a -> m Int32
-- | Counts the members of the current position, if the reader is
-- positioned on an object.
--
-- In case of failure, the reader is set to an error state.
--
-- Since: 0.12
readerCountMembers :: (HasCallStack, MonadIO m, IsReader a) => a -> m Int32
-- | Moves the cursor back to the previous node after being positioned
-- inside an array.
--
-- This function resets the error state of the reader, if any was set.
--
-- Since: 0.12
readerEndElement :: (HasCallStack, MonadIO m, IsReader a) => a -> m ()
-- | Moves the cursor back to the previous node after being positioned
-- inside an object.
--
-- This function resets the error state of the reader, if any was set.
--
-- Since: 0.12
readerEndMember :: (HasCallStack, MonadIO m, IsReader a) => a -> m ()
-- | Retrieves the boolean value of the current position of the reader.
--
-- See also: [methodjson.Reader.get_value]
--
-- Since: 0.12
readerGetBooleanValue :: (HasCallStack, MonadIO m, IsReader a) => a -> m Bool
-- | Retrieves the floating point value of the current position of the
-- reader.
--
-- See also: [methodjson.Reader.get_value]
--
-- Since: 0.12
readerGetDoubleValue :: (HasCallStack, MonadIO m, IsReader a) => a -> m Double
-- | Retrieves the error currently set on the reader.
--
-- Since: 0.12
readerGetError :: (HasCallStack, MonadIO m, IsReader a) => a -> m (Maybe GError)
-- | Retrieves the integer value of the current position of the reader.
--
-- See also: [methodjson.Reader.get_value]
--
-- Since: 0.12
readerGetIntValue :: (HasCallStack, MonadIO m, IsReader a) => a -> m Int64
-- | Retrieves the name of the current member.
--
-- In case of failure, the reader is set to an error state.
--
-- Since: 0.14
readerGetMemberName :: (HasCallStack, MonadIO m, IsReader a) => a -> m (Maybe Text)
-- | Checks whether the value of the current position of the reader is
-- null.
--
-- See also: [methodjson.Reader.get_value]
--
-- Since: 0.12
readerGetNullValue :: (HasCallStack, MonadIO m, IsReader a) => a -> m Bool
-- | Retrieves the string value of the current position of the reader.
--
-- See also: [methodjson.Reader.get_value]
--
-- Since: 0.12
readerGetStringValue :: (HasCallStack, MonadIO m, IsReader a) => a -> m Text
-- | Retrieves the value node at the current position of the reader.
--
-- If the current position does not contain a scalar value, the reader is
-- set to an error state.
--
-- Since: 0.12
readerGetValue :: (HasCallStack, MonadIO m, IsReader a) => a -> m (Maybe Node)
-- | Checks whether the reader is currently on an array.
--
-- Since: 0.12
readerIsArray :: (HasCallStack, MonadIO m, IsReader a) => a -> m Bool
-- | Checks whether the reader is currently on an object.
--
-- Since: 0.12
readerIsObject :: (HasCallStack, MonadIO m, IsReader a) => a -> m Bool
-- | Checks whether the reader is currently on a value.
--
-- Since: 0.12
readerIsValue :: (HasCallStack, MonadIO m, IsReader a) => a -> m Bool
-- | Retrieves a list of member names from the current position, if the
-- reader is positioned on an object.
--
-- In case of failure, the reader is set to an error state.
--
-- Since: 0.14
readerListMembers :: (HasCallStack, MonadIO m, IsReader a) => a -> m [Text]
-- | Creates a new reader.
--
-- You can use this object to read the contents of the JSON tree starting
-- from the given node.
--
-- Since: 0.12
readerNew :: (HasCallStack, MonadIO m) => Maybe Node -> m Reader
-- | Advances the cursor of the reader to the element of the array or the
-- member of the object at the given position.
--
-- You can use [methodjson.Reader.get_value] and its
-- wrapper functions to retrieve the value of the element; for instance,
-- the following code will read the first element of the array at the
-- current cursor position:
--
-- ``c json_reader_read_element (reader, 0); int_value =
-- json_reader_get_int_value (reader); `@
--
-- After reading the value, you should call
-- [method@Json.Reader.end_element] to reposition the cursor inside the
-- reader, e.g.:
--
-- `c const char *str_value = NULL;
--
-- json_reader_read_element (reader, 1); str_value =
-- json_reader_get_string_value (reader); json_reader_end_element
-- (reader);
--
-- json_reader_read_element (reader, 2); str_value =
-- json_reader_get_string_value (reader); json_reader_end_element
-- (reader); `
--
-- If the reader is not currently on an array or an object, or if the
-- index is bigger than the size of the array or the object, the reader
-- will be put in an error state until [method@Json.Reader.end_element]
-- is called. This means that, if used conditionally,
-- [method@Json.Reader.end_element] must be called on all branches:
--
-- `c if (!json_reader_read_element (reader, 1)) {
-- g_propagate_error (error, json_reader_get_error (reader));
-- json_reader_end_element (reader); return FALSE; } else { const char
-- *str_value = json_reader_get_string_value (reader);
-- json_reader_end_element (reader);
--
-- // use str_value
--
-- return TRUE; } @``c
--
-- Since: 0.12
readerReadElement :: (HasCallStack, MonadIO m, IsReader a) => a -> Word32 -> m Bool
-- | Advances the cursor of the reader to the member_name of the
-- object at the current position.
--
-- You can use [methodjson.Reader.get_value] and its
-- wrapper functions to retrieve the value of the member; for instance:
--
-- ``c json_reader_read_member (reader, "width"); width =
-- json_reader_get_int_value (reader); `@
--
-- After reading the value, readerEndMember should be
-- called to reposition the cursor inside the reader, e.g.:
--
-- `c json_reader_read_member (reader, "author"); author =
-- json_reader_get_string_value (reader); json_reader_end_member
-- (reader);
--
-- json_reader_read_member (reader, "title"); title =
-- json_reader_get_string_value (reader); json_reader_end_member
-- (reader); `
--
-- If the reader is not currently on an object, or if the
-- member_name is not defined in the object, the reader will be
-- put in an error state until [method@Json.Reader.end_member] is called.
-- This means that if used conditionally, [method@Json.Reader.end_member]
-- must be called on all branches:
--
-- `c if (!json_reader_read_member (reader, "title")) {
-- g_propagate_error (error, json_reader_get_error (reader));
-- json_reader_end_member (reader); return FALSE; } else { const char
-- *str_value = json_reader_get_string_value (reader);
-- json_reader_end_member (reader);
--
-- // use str_value
--
-- return TRUE; } @``
--
-- Since: 0.12
readerReadMember :: (HasCallStack, MonadIO m, IsReader a) => a -> Text -> m Bool
-- | Sets the root node of the JSON tree to be read by
-- reader.
--
-- The reader will take a copy of the node.
--
-- Since: 0.12
readerSetRoot :: (HasCallStack, MonadIO m, IsReader a) => a -> Maybe Node -> m ()
-- | Set the value of the “root” property to Nothing. When
-- overloading is enabled, this is equivalent to
--
--
-- clear #root
--
clearReaderRoot :: (MonadIO m, IsReader o) => o -> m ()
-- | Construct a GValueConstruct with valid value for the
-- “root” property. This is rarely needed directly, but it is
-- used by new.
constructReaderRoot :: (IsReader o, MonadIO m) => Node -> m (GValueConstruct o)
-- | Get the value of the “root” property. When overloading
-- is enabled, this is equivalent to
--
--
-- get reader #root
--
getReaderRoot :: (MonadIO m, IsReader o) => o -> m (Maybe Node)
-- | Set the value of the “root” property. When overloading
-- is enabled, this is equivalent to
--
--
-- set reader [ #root := value ]
--
setReaderRoot :: (MonadIO m, IsReader o) => o -> Node -> m ()
instance GHC.Classes.Eq GI.Json.Objects.Reader.Reader
instance (Data.GI.Base.BasicTypes.GObject o, Data.GI.Base.Overloading.IsDescendantOf GI.Json.Objects.Reader.Reader o) => GI.Json.Objects.Reader.IsReader o
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Objects.Reader.Reader
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Objects.Reader.Reader
instance Data.GI.Base.BasicTypes.GObject GI.Json.Objects.Reader.Reader
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Objects.Reader.Reader
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Objects.Reader.Reader)
-- | JsonPath is a simple class implementing the JSONPath syntax
-- for extracting data out of a JSON tree.
--
-- While the semantics of the JSONPath expressions are heavily borrowed
-- by the XPath specification for XML, the syntax follows the ECMAScript
-- origins of JSON.
--
-- Once a JsonPath instance has been created, it has to compile
-- a JSONPath expression using [methodjson.Path.compile]
-- before being able to match it to a JSON tree; the same
-- JsonPath instance can be used to match multiple JSON trees.
-- It it also possible to compile a new JSONPath expression using the
-- same JsonPath instance; the previous expression will be
-- discarded only if the compilation of the new expression is successful.
--
-- The simple convenience function [funcjson.Path.query]
-- can be used for one-off matching.
--
-- Syntax of the JSONPath expressions
--
-- A JSONPath expression is composed by path indices and operators. Each
-- path index can either be a member name or an element index inside a
-- JSON tree. A JSONPath expression must start with the $
-- operator; each path index is separated using either the dot notation
-- or the bracket notation, e.g.:
--
-- ``@ // dot notation
module GI.Json.Objects.Path
-- | Memory-managed wrapper type.
newtype Path
Path :: ManagedPtr Path -> Path
-- | Type class for types which can be safely cast to Path, for
-- instance with toPath.
class (GObject o, IsDescendantOf Path o) => IsPath o
-- | Cast to Path, for types for which this is known to be safe. For
-- general casts, use castTo.
toPath :: (MonadIO m, IsPath o) => o -> m Path
-- | Validates and decomposes the given expression.
--
-- A JSONPath expression must be compiled before calling
-- [methodjson.Path.match].
--
-- Since: 0.14
pathCompile :: (HasCallStack, MonadIO m, IsPath a) => a -> Text -> m ()
-- | Matches the JSON tree pointed by root using the expression
-- compiled into the JsonPath.
--
-- The nodes matching the expression will be copied into an array.
--
-- Since: 0.14
pathMatch :: (HasCallStack, MonadIO m, IsPath a) => a -> Node -> m Node
-- | Creates a new JsonPath instance.
--
-- Once created, the JsonPath object should be used with
-- [methodjson.Path.compile] and
-- [methodjson.Path.match].
--
-- Since: 0.14
pathNew :: (HasCallStack, MonadIO m) => m Path
-- | Queries a JSON tree using a JSONPath expression.
--
-- This function is a simple wrapper around
-- [ctorjson.Path.new],
-- [methodjson.Path.compile], and
-- [methodjson.Path.match]. It implicitly creates a
-- JsonPath instance, compiles the given expression and matches
-- it against the JSON tree pointed by root.
--
-- Since: 0.14
pathQuery :: (HasCallStack, MonadIO m) => Text -> Node -> m Node
instance GHC.Classes.Eq GI.Json.Objects.Path.Path
instance (Data.GI.Base.BasicTypes.GObject o, Data.GI.Base.Overloading.IsDescendantOf GI.Json.Objects.Path.Path o) => GI.Json.Objects.Path.IsPath o
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Objects.Path.Path
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Objects.Path.Path
instance Data.GI.Base.BasicTypes.GObject GI.Json.Objects.Path.Path
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Objects.Path.Path
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Objects.Path.Path)
-- | JsonGenerator provides an object for generating a JSON data
-- stream from a tree of [structjson.Node] instances, and
-- put it into a buffer or a file.
module GI.Json.Objects.Generator
-- | Memory-managed wrapper type.
newtype Generator
Generator :: ManagedPtr Generator -> Generator
-- | Type class for types which can be safely cast to Generator, for
-- instance with toGenerator.
class (GObject o, IsDescendantOf Generator o) => IsGenerator o
-- | Cast to Generator, for types for which this is known to be
-- safe. For general casts, use castTo.
toGenerator :: (MonadIO m, IsGenerator o) => o -> m Generator
-- | Retrieves the value set using
-- [methodjson.Generator.set_indent].
--
-- Since: 0.14
generatorGetIndent :: (HasCallStack, MonadIO m, IsGenerator a) => a -> m Word32
-- | Retrieves the value set using
-- [methodjson.Generator.set_indent_char].
--
-- Since: 0.14
generatorGetIndentChar :: (HasCallStack, MonadIO m, IsGenerator a) => a -> m Char
-- | Retrieves the value set using
-- [methodjson.Generator.set_pretty].
--
-- Since: 0.14
generatorGetPretty :: (HasCallStack, MonadIO m, IsGenerator a) => a -> m Bool
-- | Retrieves a pointer to the root node set using
-- [methodjson.Generator.set_root].
--
-- Since: 0.14
generatorGetRoot :: (HasCallStack, MonadIO m, IsGenerator a) => a -> m (Maybe Node)
-- | Creates a new JsonGenerator.
--
-- You can use this object to generate a JSON data stream starting from a
-- data object model composed by [structjson.Node]s.
generatorNew :: (HasCallStack, MonadIO m) => m Generator
-- | Sets the number of repetitions for each indentation level.
--
-- Since: 0.14
generatorSetIndent :: (HasCallStack, MonadIO m, IsGenerator a) => a -> Word32 -> m ()
-- | Sets the character to be used when indenting.
--
-- Since: 0.14
generatorSetIndentChar :: (HasCallStack, MonadIO m, IsGenerator a) => a -> Char -> m ()
-- | Sets whether the generated JSON should be pretty printed.
--
-- Pretty printing will use indentation character specified in the
-- [propertyjson.Generator:indent-char] property and the
-- spacing specified in the
-- [propertyjson.Generator:indent] property.
--
-- Since: 0.14
generatorSetPretty :: (HasCallStack, MonadIO m, IsGenerator a) => a -> Bool -> m ()
-- | Sets the root of the JSON data stream to be serialized by the given
-- generator.
--
-- The passed node is copied by the generator object, so it can
-- be safely freed after calling this function.
generatorSetRoot :: (HasCallStack, MonadIO m, IsGenerator a) => a -> Node -> m ()
-- | Generates a JSON data stream from generator and
-- returns it as a buffer.
generatorToData :: (HasCallStack, MonadIO m, IsGenerator a) => a -> m (Text, Word64)
-- | Creates a JSON data stream and puts it inside filename,
-- overwriting the file's current contents.
--
-- This operation is atomic, in the sense that the data is written to a
-- temporary file which is then renamed to the given filename.
generatorToFile :: (HasCallStack, MonadIO m, IsGenerator a) => a -> [Char] -> m ()
-- | Generates a JSON data stream and appends it to the string buffer.
--
-- Since: 1.4
generatorToGstring :: (HasCallStack, MonadIO m, IsGenerator a) => a -> String -> m String
-- | Outputs JSON data and writes it (synchronously) to the given stream.
--
-- Since: 0.12
generatorToStream :: (HasCallStack, MonadIO m, IsGenerator a, IsOutputStream b, IsCancellable c) => a -> b -> Maybe c -> m ()
-- | Construct a GValueConstruct with valid value for the
-- “indent” property. This is rarely needed directly, but it is
-- used by new.
constructGeneratorIndent :: (IsGenerator o, MonadIO m) => Word32 -> m (GValueConstruct o)
-- | Get the value of the “indent” property. When
-- overloading is enabled, this is equivalent to
--
--
-- get generator #indent
--
getGeneratorIndent :: (MonadIO m, IsGenerator o) => o -> m Word32
-- | Set the value of the “indent” property. When
-- overloading is enabled, this is equivalent to
--
--
-- set generator [ #indent := value ]
--
setGeneratorIndent :: (MonadIO m, IsGenerator o) => o -> Word32 -> m ()
-- | Construct a GValueConstruct with valid value for the
-- “indent-char” property. This is rarely needed directly, but
-- it is used by new.
constructGeneratorIndentChar :: (IsGenerator o, MonadIO m) => Word32 -> m (GValueConstruct o)
-- | Get the value of the “indent-char” property. When
-- overloading is enabled, this is equivalent to
--
--
-- get generator #indentChar
--
getGeneratorIndentChar :: (MonadIO m, IsGenerator o) => o -> m Word32
-- | Set the value of the “indent-char” property. When
-- overloading is enabled, this is equivalent to
--
--
-- set generator [ #indentChar := value ]
--
setGeneratorIndentChar :: (MonadIO m, IsGenerator o) => o -> Word32 -> m ()
-- | Construct a GValueConstruct with valid value for the
-- “pretty” property. This is rarely needed directly, but it is
-- used by new.
constructGeneratorPretty :: (IsGenerator o, MonadIO m) => Bool -> m (GValueConstruct o)
-- | Get the value of the “pretty” property. When
-- overloading is enabled, this is equivalent to
--
--
-- get generator #pretty
--
getGeneratorPretty :: (MonadIO m, IsGenerator o) => o -> m Bool
-- | Set the value of the “pretty” property. When
-- overloading is enabled, this is equivalent to
--
--
-- set generator [ #pretty := value ]
--
setGeneratorPretty :: (MonadIO m, IsGenerator o) => o -> Bool -> m ()
-- | Construct a GValueConstruct with valid value for the
-- “root” property. This is rarely needed directly, but it is
-- used by new.
constructGeneratorRoot :: (IsGenerator o, MonadIO m) => Node -> m (GValueConstruct o)
-- | Get the value of the “root” property. When overloading
-- is enabled, this is equivalent to
--
--
-- get generator #root
--
getGeneratorRoot :: (MonadIO m, IsGenerator o) => o -> m (Maybe Node)
-- | Set the value of the “root” property. When overloading
-- is enabled, this is equivalent to
--
--
-- set generator [ #root := value ]
--
setGeneratorRoot :: (MonadIO m, IsGenerator o) => o -> Node -> m ()
instance GHC.Classes.Eq GI.Json.Objects.Generator.Generator
instance (Data.GI.Base.BasicTypes.GObject o, Data.GI.Base.Overloading.IsDescendantOf GI.Json.Objects.Generator.Generator o) => GI.Json.Objects.Generator.IsGenerator o
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Objects.Generator.Generator
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Objects.Generator.Generator
instance Data.GI.Base.BasicTypes.GObject GI.Json.Objects.Generator.Generator
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Objects.Generator.Generator
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Objects.Generator.Generator)
-- | JsonBuilder provides an object for generating a JSON tree.
--
-- The root of the JSON tree can be either a
-- [structjson.Object] or a
-- [structjson.Array]. Thus the first call must
-- necessarily be either
-- [methodjson.Builder.begin_object] or
-- [methodjson.Builder.begin_array].
--
-- For convenience to language bindings, most JsonBuilder method
-- return the instance, making it easy to chain function calls.
--
-- Using JsonBuilder
--
-- ``@c g_autoptr(JsonBuilder) builder = json_builder_new ();
--
-- json_builder_begin_object (builder);
--
-- json_builder_set_member_name (builder, "url");
-- json_builder_add_string_value (builder,
-- "http://www.gnome.org/img/flash/two-thirty.png");
--
-- json_builder_set_member_name (builder, "size");
-- json_builder_begin_array (builder); json_builder_add_int_value
-- (builder, 652); json_builder_add_int_value (builder, 242);
-- json_builder_end_array (builder);
--
-- json_builder_end_object (builder);
--
-- g_autoptr(JsonNode) root root = json_builder_get_root (builder);
--
-- g_autoptr(JsonGenerator) gen = json_generator_new ();
-- json_generator_set_root (gen, root); g_autofree char *str =
-- json_generator_to_data (gen, NULL);
--
-- // str now contains the following JSON data // { "url" :
-- "http://www.gnome.org/img/flash/two-thirty.png", "size" : [ 652, 242 ]
-- } @``
module GI.Json.Objects.Builder
-- | Memory-managed wrapper type.
newtype Builder
Builder :: ManagedPtr Builder -> Builder
-- | Type class for types which can be safely cast to Builder, for
-- instance with toBuilder.
class (GObject o, IsDescendantOf Builder o) => IsBuilder o
-- | Cast to Builder, for types for which this is known to be safe.
-- For general casts, use castTo.
toBuilder :: (MonadIO m, IsBuilder o) => o -> m Builder
-- | Adds a boolean value to the currently open object member or array.
--
-- If called after [methodjson.Builder.set_member_name],
-- sets the given value as the value of the current member in the open
-- object; otherwise, the value is appended to the elements of the open
-- array.
--
-- See also: [methodjson.Builder.add_value]
builderAddBooleanValue :: (HasCallStack, MonadIO m, IsBuilder a) => a -> Bool -> m (Maybe Builder)
-- | Adds a floating point value to the currently open object member or
-- array.
--
-- If called after [methodjson.Builder.set_member_name],
-- sets the given value as the value of the current member in the open
-- object; otherwise, the value is appended to the elements of the open
-- array.
--
-- See also: [methodjson.Builder.add_value]
builderAddDoubleValue :: (HasCallStack, MonadIO m, IsBuilder a) => a -> Double -> m (Maybe Builder)
-- | Adds an integer value to the currently open object member or array.
--
-- If called after [methodjson.Builder.set_member_name],
-- sets the given value as the value of the current member in the open
-- object; otherwise, the value is appended to the elements of the open
-- array.
--
-- See also: [methodjson.Builder.add_value]
builderAddIntValue :: (HasCallStack, MonadIO m, IsBuilder a) => a -> Int64 -> m (Maybe Builder)
-- | Adds a null value to the currently open object member or array.
--
-- If called after [methodjson.Builder.set_member_name],
-- sets the given value as the value of the current member in the open
-- object; otherwise, the value is appended to the elements of the open
-- array.
--
-- See also: [methodjson.Builder.add_value]
builderAddNullValue :: (HasCallStack, MonadIO m, IsBuilder a) => a -> m (Maybe Builder)
-- | Adds a boolean value to the currently open object member or array.
--
-- If called after [methodjson.Builder.set_member_name],
-- sets the given value as the value of the current member in the open
-- object; otherwise, the value is appended to the elements of the open
-- array.
--
-- See also: [methodjson.Builder.add_value]
builderAddStringValue :: (HasCallStack, MonadIO m, IsBuilder a) => a -> Text -> m (Maybe Builder)
-- | Adds a value to the currently open object member or array.
--
-- If called after [methodjson.Builder.set_member_name],
-- sets the given node as the value of the current member in the open
-- object; otherwise, the node is appended to the elements of the open
-- array.
--
-- The builder will take ownership of the node.
builderAddValue :: (HasCallStack, MonadIO m, IsBuilder a) => a -> Node -> m (Maybe Builder)
-- | Opens an array inside the given builder.
--
-- You can add a new element to the array by using
-- [methodjson.Builder.add_value].
--
-- Once you added all elements to the array, you must call
-- [methodjson.Builder.end_array] to close the array.
builderBeginArray :: (HasCallStack, MonadIO m, IsBuilder a) => a -> m (Maybe Builder)
-- | Opens an object inside the given builder.
--
-- You can add a new member to the object by using
-- [methodjson.Builder.set_member_name], followed by
-- [methodjson.Builder.add_value].
--
-- Once you added all members to the object, you must call
-- [methodjson.Builder.end_object] to close the object.
--
-- If the builder is in an inconsistent state, this function will return
-- NULL.
builderBeginObject :: (HasCallStack, MonadIO m, IsBuilder a) => a -> m (Maybe Builder)
-- | Closes the array inside the given builder that was opened by the most
-- recent call to [methodjson.Builder.begin_array].
--
-- This function cannot be called after
-- [methodjson.Builder.set_member_name].
builderEndArray :: (HasCallStack, MonadIO m, IsBuilder a) => a -> m (Maybe Builder)
-- | Closes the object inside the given builder that was opened by the most
-- recent call to [methodjson.Builder.begin_object].
--
-- This function cannot be called after
-- [methodjson.Builder.set_member_name].
builderEndObject :: (HasCallStack, MonadIO m, IsBuilder a) => a -> m (Maybe Builder)
-- | Returns the root of the currently constructed tree.
--
-- if the build is incomplete (ie: if there are any opened objects, or
-- any open object members and array elements) then this function will
-- return NULL.
builderGetRoot :: (HasCallStack, MonadIO m, IsBuilder a) => a -> m (Maybe Node)
-- | Creates a new JsonBuilder.
--
-- You can use this object to generate a JSON tree and obtain the root
-- node.
builderNew :: (HasCallStack, MonadIO m) => m Builder
-- | Creates a new, immutable JsonBuilder instance.
--
-- It is equivalent to setting the
-- [propertyjson.Builder:immutable] property set to
-- TRUE at construction time.
--
-- Since: 1.2
builderNewImmutable :: (HasCallStack, MonadIO m) => m Builder
-- | Resets the state of the builder back to its initial state.
builderReset :: (HasCallStack, MonadIO m, IsBuilder a) => a -> m ()
-- | Sets the name of the member in an object.
--
-- This function must be followed by of these functions:
--
--
-- - [methodjson.Builder.add_value], to add a scalar
-- value to the member
-- - [methodjson.Builder.begin_object], to add an
-- object to the member
-- - [methodjson.Builder.begin_array], to add an array
-- to the member
--
--
-- This function can only be called within an open object.
builderSetMemberName :: (HasCallStack, MonadIO m, IsBuilder a) => a -> Text -> m (Maybe Builder)
-- | Construct a GValueConstruct with valid value for the
-- “immutable” property. This is rarely needed directly, but it
-- is used by new.
constructBuilderImmutable :: (IsBuilder o, MonadIO m) => Bool -> m (GValueConstruct o)
-- | Get the value of the “immutable” property. When
-- overloading is enabled, this is equivalent to
--
--
-- get builder #immutable
--
getBuilderImmutable :: (MonadIO m, IsBuilder o) => o -> m Bool
instance GHC.Classes.Eq GI.Json.Objects.Builder.Builder
instance (Data.GI.Base.BasicTypes.GObject o, Data.GI.Base.Overloading.IsDescendantOf GI.Json.Objects.Builder.Builder o) => GI.Json.Objects.Builder.IsBuilder o
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Objects.Builder.Builder
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Objects.Builder.Builder
instance Data.GI.Base.BasicTypes.GObject GI.Json.Objects.Builder.Builder
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Objects.Builder.Builder
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Objects.Builder.Builder)
-- | 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.
module GI.Json.Interfaces.Serializable
-- | Memory-managed wrapper type.
newtype Serializable
Serializable :: ManagedPtr Serializable -> Serializable
-- | Type class for types which can be safely cast to Serializable,
-- for instance with toSerializable.
class (GObject o, IsDescendantOf Serializable o) => IsSerializable o
-- | Cast to Serializable, for types for which this is known to be
-- safe. For general casts, use castTo.
toSerializable :: (MonadIO m, IsSerializable o) => o -> m Serializable
-- | 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
serializableDefaultDeserializeProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> GValue -> GParamSpec -> Node -> m Bool
-- | 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
serializableDefaultSerializeProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> GValue -> GParamSpec -> m (Maybe Node)
-- | 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 by G_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
--
serializableDeserializeProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> GParamSpec -> Node -> m (Bool, GValue)
-- | Calls the [vfuncjson.Serializable.find_property]
-- implementation on the JsonSerializable instance, which will
-- return the property description for the given name.
--
-- Since: 0.14
serializableFindProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> m (Maybe GParamSpec)
-- | Calls the [vfuncjson.Serializable.get_property]
-- implementation on the JsonSerializable instance, which will
-- get the value of the given property.
--
-- Since: 0.14
serializableGetProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> GParamSpec -> m GValue
-- | Asks a JsonSerializable implementation to serialize an object
-- property into a JSON node.
serializableSerializeProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> Text -> GValue -> GParamSpec -> m Node
-- | Calls the [vfuncjson.Serializable.set_property]
-- implementation on the JsonSerializable instance, which will
-- set the property with the given value.
--
-- Since: 0.14
serializableSetProperty :: (HasCallStack, MonadIO m, IsSerializable a) => a -> GParamSpec -> GValue -> m ()
instance GHC.Classes.Eq GI.Json.Interfaces.Serializable.Serializable
instance (Data.GI.Base.BasicTypes.GObject o, Data.GI.Base.Overloading.IsDescendantOf GI.Json.Interfaces.Serializable.Serializable o) => GI.Json.Interfaces.Serializable.IsSerializable o
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Interfaces.Serializable.Serializable
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Interfaces.Serializable.Serializable
instance Data.GI.Base.BasicTypes.GObject GI.Json.Interfaces.Serializable.Serializable
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Interfaces.Serializable.Serializable
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Interfaces.Serializable.Serializable)
module GI.Json.Interfaces
module GI.Json.Functions
-- | Checks whether it is possible to deserialize a GBoxed of type
-- gboxed_type from a [structjson.Node] of type
-- node_type.
--
-- Since: 0.10
boxedCanDeserialize :: (HasCallStack, MonadIO m) => GType -> NodeType -> m Bool
-- | Checks whether it is possible to serialize a GBoxed of type
-- gboxed_type into a [structjson.Node].
--
-- The type of the node is placed inside node_type if the
-- function returns TRUE, and it's undefined otherwise.
--
-- Since: 0.10
boxedCanSerialize :: (HasCallStack, MonadIO m) => GType -> m (Bool, NodeType)
-- | Deserializes the given [structjson.Node] into a
-- GBoxed of the given type.
--
-- Since: 0.10
boxedDeserialize :: (HasCallStack, MonadIO m) => GType -> Node -> m (Ptr ())
-- | Serializes a pointer to a GBoxed of the given type into a
-- [structjson.Node].
--
-- If the serialization is not possible, this function will return
-- NULL.
--
-- Since: 0.10
boxedSerialize :: (HasCallStack, MonadIO m) => GType -> Ptr () -> m (Maybe Node)
-- | Deserializes a JSON data stream and creates an instance of the given
-- type
--
-- If the given type implements the
-- [ifacejson.Serializable] interface, it will be asked
-- to deserialize all the JSON members into their respective properties;
-- otherwise, the default implementation will be used to translate the
-- compatible JSON native types.
--
--
-- - *Note**: the JSON data stream must be an object.
--
--
-- Since: 0.4
-- | Deprecated: (Since version 0.10)Use
-- [funcjson.gobject_from_data] instead
constructGobject :: (HasCallStack, MonadIO m) => GType -> Text -> Word64 -> m (Maybe Object)
-- | Parses the given string and returns the corresponding JSON tree.
--
-- If the string is empty, this function will return NULL.
--
-- In case of parsing error, this function returns NULL and sets
-- the error appropriately.
--
-- Since: 1.2
fromString :: (HasCallStack, MonadIO m) => Text -> m (Maybe Node)
-- | Creates a new GObject instance of the given type, and
-- constructs it using the members of the object in the given node.
--
-- Since: 0.10
gobjectDeserialize :: (HasCallStack, MonadIO m) => GType -> Node -> m Object
-- | Deserializes a JSON data stream and creates an instance of the given
-- type.
--
-- If the type implements the [ifacejson.Serializable]
-- interface, it will be asked to deserialize all the JSON members into
-- their respective properties; otherwise, the default implementation
-- will be used to translate the compatible JSON native types.
--
--
-- - *Note**: the JSON data stream must be an object
--
--
-- Since: 0.10
gobjectFromData :: (HasCallStack, MonadIO m) => GType -> Text -> Int64 -> m (Maybe Object)
-- | Creates a JSON tree representing the passed object instance.
--
-- Each member of the returned JSON object will map to a property of the
-- object type.
--
-- The returned JSON tree will be returned as a JsonNode with a
-- type of JSON_NODE_OBJECT.
--
-- Since: 0.10
gobjectSerialize :: (HasCallStack, MonadIO m, IsObject a) => a -> m Node
-- | Serializes a GObject instance into a JSON data stream,
-- iterating recursively over each property.
--
-- If the given object implements the
-- [ifacejson.Serializable] interface, it will be asked
-- to serialize all its properties; otherwise, the default implementation
-- will be use to translate the compatible types into JSON native types.
--
-- Since: 0.10
gobjectToData :: (HasCallStack, MonadIO m, IsObject a) => a -> m (Text, Word64)
-- | Converts a JSON data structure to a GVariant.
--
-- If signature is not NULL, it will be used to resolve
-- ambiguous data types.
--
-- If no error occurs, the resulting GVariant is guaranteed to
-- conform to signature.
--
-- If signature is not NULL but does not represent a
-- valid GVariant type string, NULL is returned and the
-- error is set to G_IO_ERROR_INVALID_ARGUMENT.
--
-- If a signature is provided but the JSON structure cannot be
-- mapped to it, NULL is returned and the error is set
-- to G_IO_ERROR_INVALID_DATA.
--
-- If signature is NULL, the conversion is done based
-- strictly on the types in the JSON nodes.
--
-- The returned variant has a floating reference that will need to be
-- sunk by the caller code.
--
-- Since: 0.14
gvariantDeserialize :: (HasCallStack, MonadIO m) => Node -> Maybe Text -> m (Maybe GVariant)
-- | Converts a JSON string to a GVariant value.
--
-- This function works exactly like
-- [funcjson.gvariant_deserialize], but takes a JSON
-- encoded string instead.
--
-- The string is first converted to a [structjson.Node]
-- using [classjson.Parser], and then
-- json_gvariant_deserialize is called on the node.
--
-- The returned variant has a floating reference that will need to be
-- sunk by the caller code.
--
-- Since: 0.14
gvariantDeserializeData :: (HasCallStack, MonadIO m) => Text -> Int64 -> Maybe Text -> m (Maybe GVariant)
-- | Converts variant to a JSON tree.
--
-- Since: 0.14
gvariantSerialize :: (HasCallStack, MonadIO m) => GVariant -> m Node
-- | Converts variant to its JSON encoded string
-- representation.
--
-- This is a convenience function around
-- [funcjson.gvariant_serialize], to obtain the JSON
-- tree, and then [classjson.Generator] to stringify it.
--
-- Since: 0.14
gvariantSerializeData :: (HasCallStack, MonadIO m) => GVariant -> m (Text, Word64)
-- | Serializes a GObject instance into a JSON data stream.
--
-- If the object implements the [ifacejson.Serializable]
-- interface, it will be asked to serizalize all its properties;
-- otherwise, the default implementation will be use to translate the
-- compatible types into JSON native types.
-- | Deprecated: (Since version 0.10)Use
-- [funcjson.gobject_to_data] instead
serializeGobject :: (HasCallStack, MonadIO m, IsObject a) => a -> m (Text, Word64)
-- | Check whether a and b are equal UTF-8
-- JSON strings and return an ordering over them in strcmp()
-- style.
--
-- Since: 1.2
stringCompare :: (HasCallStack, MonadIO m) => Text -> Text -> m Int32
-- | Check whether a and b are equal UTF-8
-- JSON strings.
--
-- Since: 1.2
stringEqual :: (HasCallStack, MonadIO m) => Text -> Text -> m Bool
-- | Calculate a hash value for the given key (a UTF-8 JSON
-- string).
--
-- Note: Member names are compared byte-wise, without applying any
-- Unicode decomposition or normalisation. This is not explicitly
-- mentioned in the JSON standard (ECMA-404), but is assumed.
--
-- Since: 1.2
stringHash :: (HasCallStack, MonadIO m) => Text -> m Word32
-- | Generates a stringified JSON representation of the contents of the
-- given node.
--
-- Since: 1.2
toString :: (HasCallStack, MonadIO m) => Node -> Bool -> m Text
-- | JsonParser provides an object for parsing a JSON data stream,
-- either inside a file or inside a static buffer.
--
-- Using JsonParser
--
-- The JsonParser API is fairly simple:
--
-- ``@c gboolean parse_json (const char *filename) {
-- g_autoptr(JsonParser) parser = json_parser_new (); g_autoptr(GError)
-- error = NULL
--
-- json_parser_load_from_file (parser, filename, &error); if (error
-- != NULL) { g_critical ("Unable to parse '%s': %s", filename,
-- error->message); return FALSE; }
--
-- g_autoptr(JsonNode) root = json_parser_get_root (parser);
--
-- // manipulate the object tree from the root node
--
-- return TRUE } `
--
-- By default, the entire process of loading the data and parsing it is
-- synchronous; the [method@Json.Parser.load_from_stream_async()] API
-- will load the data asynchronously, but parse it in the main context as
-- the signals of the parser must be emitted in the same thread. If you
-- do not use signals, and you wish to also parse the JSON data without
-- blocking, you should use a GTask and the synchronous
-- @JsonParser` API inside the task itself.
module GI.Json.Objects.Parser
-- | Memory-managed wrapper type.
newtype Parser
Parser :: ManagedPtr Parser -> Parser
-- | Type class for types which can be safely cast to Parser, for
-- instance with toParser.
class (GObject o, IsDescendantOf Parser o) => IsParser o
-- | Cast to Parser, for types for which this is known to be safe.
-- For general casts, use castTo.
toParser :: (MonadIO m, IsParser o) => o -> m Parser
-- | Retrieves the line currently parsed, starting from 1.
--
-- This function has defined behaviour only while parsing; calling this
-- function from outside the signal handlers emitted by the parser will
-- yield 0.
parserGetCurrentLine :: (HasCallStack, MonadIO m, IsParser a) => a -> m Word32
-- | Retrieves the current position inside the current line, starting from
-- 0.
--
-- This function has defined behaviour only while parsing; calling this
-- function from outside the signal handlers emitted by the parser will
-- yield 0.
parserGetCurrentPos :: (HasCallStack, MonadIO m, IsParser a) => a -> m Word32
-- | Retrieves the top level node from the parsed JSON stream.
--
-- If the parser input was an empty string, or if parsing failed, the
-- root will be NULL. It will also be NULL if it has
-- been stolen using [methodjson.Parser.steal_root].
parserGetRoot :: (HasCallStack, MonadIO m, IsParser a) => a -> m (Maybe Node)
-- | A JSON data stream might sometimes contain an assignment, like:
--
-- `` var _json_data = { "member_name" : [ ... `@
--
-- even though it would technically constitute a violation of the RFC.
--
-- JsonParser will ignore the left hand identifier and parse the
-- right hand value of the assignment. @JsonParser` will record, though,
-- the existence of the assignment in the data stream and the variable
-- name used.
--
-- Since: 0.4
parserHasAssignment :: (HasCallStack, MonadIO m, IsParser a) => a -> m (Bool, Text)
-- | Loads a JSON stream from a buffer and parses it.
--
-- You can call this function multiple times with the same parser, but
-- the contents of the parser will be destroyed each time.
parserLoadFromData :: (HasCallStack, MonadIO m, IsParser a) => a -> Text -> Int64 -> m ()
-- | Loads a JSON stream from the content of filename and parses
-- it.
--
-- If the file is large or shared between processes,
-- [methodjson.Parser.load_from_mapped_file] may be a
-- more efficient way to load it.
--
-- See also: [methodjson.Parser.load_from_data]
parserLoadFromFile :: (HasCallStack, MonadIO m, IsParser a) => a -> [Char] -> m ()
-- | Loads a JSON stream from the content of filename and parses
-- it.
--
-- Unlike [methodjson.Parser.load_from_file],
-- filename will be memory mapped as read-only and parsed.
-- filename will be unmapped before this function returns.
--
-- If mapping or reading the file fails, a G_FILE_ERROR will be
-- returned.
--
-- Since: 1.6
parserLoadFromMappedFile :: (HasCallStack, MonadIO m, IsParser a) => a -> [Char] -> m ()
-- | Loads the contents of an input stream and parses them.
--
-- If cancellable is not NULL, then the operation can
-- be cancelled by triggering the cancellable object from another thread.
-- If the operation was cancelled, G_IO_ERROR_CANCELLED will be
-- set on the given error.
--
-- Since: 0.12
parserLoadFromStream :: (HasCallStack, MonadIO m, IsParser a, IsInputStream b, IsCancellable c) => a -> b -> Maybe c -> m ()
-- | Asynchronously reads the contents of a stream.
--
-- For more details, see
-- [methodjson.Parser.load_from_stream], which is the
-- synchronous version of this call.
--
-- When the operation is finished, callback will be
-- called. You should then call
-- [methodjson.Parser.load_from_stream_finish] to get the
-- result of the operation.
--
-- Since: 0.12
parserLoadFromStreamAsync :: (HasCallStack, MonadIO m, IsParser a, IsInputStream b, IsCancellable c) => a -> b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
-- | Finishes an asynchronous stream loading started with
-- [methodjson.Parser.load_from_stream_async].
--
-- Since: 0.12
parserLoadFromStreamFinish :: (HasCallStack, MonadIO m, IsParser a, IsAsyncResult b) => a -> b -> m ()
-- | Creates a new JSON parser.
--
-- You can use the JsonParser to load a JSON stream from either
-- a file or a buffer and then walk the hierarchy using the data types
-- API.
parserNew :: (HasCallStack, MonadIO m) => m Parser
-- | Creates a new parser instance with its
-- [propertyjson.Parser:immutable] property set to
-- TRUE to create immutable output trees.
--
-- Since: 1.2
parserNewImmutable :: (HasCallStack, MonadIO m) => m Parser
-- | Steals the top level node from the parsed JSON stream.
--
-- This will be NULL in the same situations as
-- [methodjson.Parser.get_root] return NULL.
--
-- Since: 1.4
parserStealRoot :: (HasCallStack, MonadIO m, IsParser a) => a -> m (Maybe Node)
-- | Construct a GValueConstruct with valid value for the
-- “immutable” property. This is rarely needed directly, but it
-- is used by new.
constructParserImmutable :: (IsParser o, MonadIO m) => Bool -> m (GValueConstruct o)
-- | Get the value of the “immutable” property. When
-- overloading is enabled, this is equivalent to
--
--
-- get parser #immutable
--
getParserImmutable :: (MonadIO m, IsParser o) => o -> m Bool
-- | The ::array-element signal is emitted each time a parser has
-- successfully parsed a single element of a JSON array.
type ParserArrayElementCallback = Array " /@array@/: a JSON array" -> Int32 " /@index_@/: the index of the newly parsed array element" -> IO ()
-- | Connect a signal handler for the arrayElement signal, to be run
-- after the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #arrayElement callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserArrayElement :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserArrayElementCallback) -> m SignalHandlerId
-- | Connect a signal handler for the arrayElement signal, to be run
-- before the default handler. When overloading is enabled, this
-- is equivalent to
--
--
-- on parser #arrayElement callback
--
onParserArrayElement :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserArrayElementCallback) -> m SignalHandlerId
-- | The ::array-end signal is emitted each time a parser has
-- successfully parsed an entire JSON array.
type ParserArrayEndCallback = Array " /@array@/: the parsed JSON array" -> IO ()
-- | Connect a signal handler for the arrayEnd signal, to be run
-- after the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #arrayEnd callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserArrayEnd :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserArrayEndCallback) -> m SignalHandlerId
-- | Connect a signal handler for the arrayEnd signal, to be run
-- before the default handler. When overloading is enabled, this
-- is equivalent to
--
--
-- on parser #arrayEnd callback
--
onParserArrayEnd :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserArrayEndCallback) -> m SignalHandlerId
-- | The ::array-start signal is emitted each time a parser starts
-- parsing a JSON array.
type ParserArrayStartCallback = IO ()
-- | Connect a signal handler for the arrayStart signal, to be run
-- after the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #arrayStart callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserArrayStart :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserArrayStartCallback) -> m SignalHandlerId
-- | Connect a signal handler for the arrayStart signal, to be run
-- before the default handler. When overloading is enabled, this
-- is equivalent to
--
--
-- on parser #arrayStart callback
--
onParserArrayStart :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserArrayStartCallback) -> m SignalHandlerId
-- | The ::error signal is emitted each time a parser encounters
-- an error in a JSON stream.
type ParserErrorCallback = Ptr () " /@error@/: the error" -> IO ()
-- | Connect a signal handler for the error signal, to be run after
-- the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #error callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserError :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserErrorCallback) -> m SignalHandlerId
-- | Connect a signal handler for the error signal, to be run before
-- the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- on parser #error callback
--
onParserError :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserErrorCallback) -> m SignalHandlerId
-- | The ::object-end signal is emitted each time a parser has
-- successfully parsed an entire JSON object.
type ParserObjectEndCallback = Object " /@object@/: the parsed JSON object" -> IO ()
-- | Connect a signal handler for the objectEnd signal, to be run
-- after the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #objectEnd callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserObjectEnd :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserObjectEndCallback) -> m SignalHandlerId
-- | Connect a signal handler for the objectEnd signal, to be run
-- before the default handler. When overloading is enabled, this
-- is equivalent to
--
--
-- on parser #objectEnd callback
--
onParserObjectEnd :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserObjectEndCallback) -> m SignalHandlerId
-- | The ::object-member signal is emitted each time a parser has
-- successfully parsed a single member of a JSON object
type ParserObjectMemberCallback = Object " /@object@/: the JSON object being parsed" -> Text " /@memberName@/: the name of the newly parsed member" -> IO ()
-- | Connect a signal handler for the objectMember signal, to be run
-- after the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #objectMember callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserObjectMember :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserObjectMemberCallback) -> m SignalHandlerId
-- | Connect a signal handler for the objectMember signal, to be run
-- before the default handler. When overloading is enabled, this
-- is equivalent to
--
--
-- on parser #objectMember callback
--
onParserObjectMember :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserObjectMemberCallback) -> m SignalHandlerId
-- | This signal is emitted each time a parser starts parsing a JSON
-- object.
type ParserObjectStartCallback = IO ()
-- | Connect a signal handler for the objectStart signal, to be run
-- after the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #objectStart callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserObjectStart :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserObjectStartCallback) -> m SignalHandlerId
-- | Connect a signal handler for the objectStart signal, to be run
-- before the default handler. When overloading is enabled, this
-- is equivalent to
--
--
-- on parser #objectStart callback
--
onParserObjectStart :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserObjectStartCallback) -> m SignalHandlerId
-- | This signal is emitted when a parser successfully finished parsing a
-- JSON data stream
type ParserParseEndCallback = IO ()
-- | Connect a signal handler for the parseEnd signal, to be run
-- after the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #parseEnd callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserParseEnd :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserParseEndCallback) -> m SignalHandlerId
-- | Connect a signal handler for the parseEnd signal, to be run
-- before the default handler. When overloading is enabled, this
-- is equivalent to
--
--
-- on parser #parseEnd callback
--
onParserParseEnd :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserParseEndCallback) -> m SignalHandlerId
-- | This signal is emitted when a parser starts parsing a JSON data
-- stream.
type ParserParseStartCallback = IO ()
-- | Connect a signal handler for the parseStart signal, to be run
-- after the default handler. When overloading is enabled, this is
-- equivalent to
--
--
-- after parser #parseStart callback
--
--
-- By default the object invoking the signal is not passed to the
-- callback. If you need to access it, you can use the implit
-- ?self parameter. Note that this requires activating the
-- ImplicitParams GHC extension.
afterParserParseStart :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserParseStartCallback) -> m SignalHandlerId
-- | Connect a signal handler for the parseStart signal, to be run
-- before the default handler. When overloading is enabled, this
-- is equivalent to
--
--
-- on parser #parseStart callback
--
onParserParseStart :: (IsParser a, MonadIO m) => a -> ((?self :: a) => ParserParseStartCallback) -> m SignalHandlerId
instance GHC.Classes.Eq GI.Json.Objects.Parser.Parser
instance (Data.GI.Base.BasicTypes.GObject o, Data.GI.Base.Overloading.IsDescendantOf GI.Json.Objects.Parser.Parser o) => GI.Json.Objects.Parser.IsParser o
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Objects.Parser.Parser
instance Data.GI.Base.BasicTypes.TypedObject GI.Json.Objects.Parser.Parser
instance Data.GI.Base.BasicTypes.GObject GI.Json.Objects.Parser.Parser
instance Data.GI.Base.Overloading.HasParentTypes GI.Json.Objects.Parser.Parser
instance Data.GI.Base.GValue.IsGValue (GHC.Maybe.Maybe GI.Json.Objects.Parser.Parser)
module GI.Json.Objects
-- | An iterator object used to iterate over the members of a JSON object.
--
-- JsonObjectIter must be allocated on the stack and initialised
-- using [methodjson.ObjectIter.init] or
-- [methodjson.ObjectIter.init_ordered].
--
-- The iterator is invalidated if the object is modified during
-- iteration.
--
-- All the fields in the JsonObjectIter structure are private
-- and should never be accessed directly.
--
-- Since: 1.2
module GI.Json.Structs.ObjectIter
-- | Memory-managed wrapper type.
newtype ObjectIter
ObjectIter :: ManagedPtr ObjectIter -> ObjectIter
-- | Construct a ObjectIter struct initialized to zero.
newZeroObjectIter :: MonadIO m => m ObjectIter
-- | Initialises the iter and associate it with
-- object.
--
-- ``@c JsonObjectIter iter; const gchar *member_name; JsonNode
-- *member_node;
--
-- json_object_iter_init (&iter, some_object); while
-- (json_object_iter_next (&iter, &member_name,
-- &member_node)) { // Do something with @member_name and
-- @member_node. } @``
--
-- The iterator initialized with this function will iterate the members
-- of the object in an undefined order.
--
-- See also: [methodjson.ObjectIter.init_ordered]
--
-- Since: 1.2
objectIterInit :: (HasCallStack, MonadIO m) => ObjectIter -> Object -> m ()
-- | Initialises the iter and associate it with
-- object.
--
-- ``@c JsonObjectIter iter; const gchar *member_name; JsonNode
-- *member_node;
--
-- json_object_iter_init_ordered (&iter, some_object); while
-- (json_object_iter_next_ordered (&iter, &member_name,
-- &member_node)) { // Do something with @member_name and
-- @member_node. } @``
--
-- See also: [methodjson.ObjectIter.init]
--
-- Since: 1.6
objectIterInitOrdered :: (HasCallStack, MonadIO m) => ObjectIter -> Object -> m ()
-- | Advances the iterator and retrieves the next member in the object.
--
-- If the end of the object is reached, FALSE is returned and
-- memberName and memberNode are set to
-- invalid values. After that point, the iter is invalid.
--
-- The order in which members are returned by the iterator is undefined.
-- The iterator is invalidated if the object is modified during
-- iteration.
--
-- You must use this function with an iterator initialized with
-- [methodjson.ObjectIter.init]; using this function with
-- an iterator initialized with
-- [methodjson.ObjectIter.init_ordered] yields undefined
-- behavior.
--
-- See also: [methodjson.ObjectIter.next_ordered]
--
-- Since: 1.2
objectIterNext :: (HasCallStack, MonadIO m) => ObjectIter -> m (Bool, Text, Node)
-- | Advances the iterator and retrieves the next member in the object.
--
-- If the end of the object is reached, FALSE is returned and
-- memberName and memberNode are set to
-- invalid values. After that point, the iter is invalid.
--
-- The order in which members are returned by the iterator is the same
-- order in which the members were added to the JsonObject. The
-- iterator is invalidated if its JsonObject is modified during
-- iteration.
--
-- You must use this function with an iterator initialized with
-- [methodjson.ObjectIter.init_ordered]; using this
-- function with an iterator initialized with
-- [methodjson.ObjectIter.init] yields undefined
-- behavior.
--
-- See also: [methodjson.ObjectIter.next]
--
-- Since: 1.6
objectIterNextOrdered :: (HasCallStack, MonadIO m) => ObjectIter -> m (Bool, Text, Node)
instance GHC.Classes.Eq GI.Json.Structs.ObjectIter.ObjectIter
instance Data.GI.Base.BasicTypes.ManagedPtrNewtype GI.Json.Structs.ObjectIter.ObjectIter
instance Data.GI.Base.BasicTypes.BoxedPtr GI.Json.Structs.ObjectIter.ObjectIter
instance Data.GI.Base.BasicTypes.CallocPtr GI.Json.Structs.ObjectIter.ObjectIter
instance (tag GHC.Types.~ 'Data.GI.Base.Attributes.AttrSet) => Data.GI.Base.Constructible.Constructible GI.Json.Structs.ObjectIter.ObjectIter tag
module GI.Json.Structs
module GI.Json