Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- canIntersect
- copy
- filterAndMapInPlace
- fixate
- fixateField
- fixateFieldBoolean
- fixateFieldNearestDouble
- fixateFieldNearestFraction
- fixateFieldNearestInt
- fixateFieldString
- foreach
- free
- fromString
- getArray
- getBoolean
- getClockTime
- getDate
- getDateTime
- getDouble
- getEnum
- getFieldType
- getFlagset
- getFraction
- getInt
- getInt64
- getList
- getName
- getNameId
- getString
- getUint
- getUint64
- getValue
- hasField
- hasFieldTyped
- hasName
- idGetValue
- idHasField
- idHasFieldTyped
- idSetValue
- idTakeValue
- intersect
- isEqual
- isSubset
- mapInPlace
- nFields
- newEmpty
- newFromString
- newIdEmpty
- nthFieldName
- removeAllFields
- removeField
- setArray
- setList
- setName
- setParentRefcount
- setValue
- takeValue
- toString
- Properties
A Structure
is a collection of key/value pairs. The keys are expressed
as GQuarks and the values can be of any GType.
In addition to the key/value pairs, a Structure
also has a name. The name
starts with a letter and can be filled by letters, numbers and any of "/-_.:".
Structure
is used by various GStreamer subsystems to store information
in a flexible and extensible way. A Structure
does not have a refcount
because it usually is part of a higher level object such as Caps
,
Message
, Event
, Query
. It provides a means to enforce mutability
using the refcount of the parent with the structureSetParentRefcount
method.
A Structure
can be created with structureNewEmpty
or
gst_structure_new()
, which both take a name and an optional set of
key/value pairs along with the types of the values.
Field values can be changed with structureSetValue
or
gst_structure_set()
.
Field values can be retrieved with structureGetValue
or the more
convenient gst_structure_get_*() functions.
Fields can be removed with structureRemoveField
or
gst_structure_remove_fields()
.
Strings in structures must be ASCII or UTF-8 encoded. Other encodings are
not allowed. Strings may be Nothing
however.
Be aware that the current Caps
/ Structure
serialization into string
has limited support for nested Caps
/ Structure
fields. It can only
support one level of nesting. Using more levels will lead to unexpected
behavior when using serialization features, such as capsToString
or
valueSerialize
and their counterparts.
Synopsis
- newtype Structure = Structure (ManagedPtr Structure)
- newZeroStructure :: MonadIO m => m Structure
- noStructure :: Maybe Structure
- structureCanIntersect :: (HasCallStack, MonadIO m) => Structure -> Structure -> m Bool
- structureCopy :: (HasCallStack, MonadIO m) => Structure -> m Structure
- structureFilterAndMapInPlace :: (HasCallStack, MonadIO m) => Structure -> StructureFilterMapFunc -> m ()
- structureFixate :: (HasCallStack, MonadIO m) => Structure -> m ()
- structureFixateField :: (HasCallStack, MonadIO m) => Structure -> Text -> m Bool
- structureFixateFieldBoolean :: (HasCallStack, MonadIO m) => Structure -> Text -> Bool -> m Bool
- structureFixateFieldNearestDouble :: (HasCallStack, MonadIO m) => Structure -> Text -> Double -> m Bool
- structureFixateFieldNearestFraction :: (HasCallStack, MonadIO m) => Structure -> Text -> Int32 -> Int32 -> m Bool
- structureFixateFieldNearestInt :: (HasCallStack, MonadIO m) => Structure -> Text -> Int32 -> m Bool
- structureFixateFieldString :: (HasCallStack, MonadIO m) => Structure -> Text -> Text -> m Bool
- structureForeach :: (HasCallStack, MonadIO m) => Structure -> StructureForeachFunc -> m Bool
- structureFree :: (HasCallStack, MonadIO m) => Structure -> m ()
- structureFromString :: (HasCallStack, MonadIO m) => Text -> m (Maybe Structure, Text)
- structureGetArray :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, ValueArray)
- structureGetBoolean :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Bool)
- structureGetClockTime :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Word64)
- structureGetDate :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Date)
- structureGetDateTime :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, DateTime)
- structureGetDouble :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Double)
- structureGetEnum :: (HasCallStack, MonadIO m) => Structure -> Text -> GType -> m (Bool, Int32)
- structureGetFieldType :: (HasCallStack, MonadIO m) => Structure -> Text -> m GType
- structureGetFlagset :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Word32, Word32)
- structureGetFraction :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Int32, Int32)
- structureGetInt :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Int32)
- structureGetInt64 :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Int64)
- structureGetList :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, ValueArray)
- structureGetName :: (HasCallStack, MonadIO m) => Structure -> m Text
- structureGetNameId :: (HasCallStack, MonadIO m) => Structure -> m Word32
- structureGetString :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Maybe Text)
- structureGetUint :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Word32)
- structureGetUint64 :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Bool, Word64)
- structureGetValue :: (HasCallStack, MonadIO m) => Structure -> Text -> m (Maybe GValue)
- structureHasField :: (HasCallStack, MonadIO m) => Structure -> Text -> m Bool
- structureHasFieldTyped :: (HasCallStack, MonadIO m) => Structure -> Text -> GType -> m Bool
- structureHasName :: (HasCallStack, MonadIO m) => Structure -> Text -> m Bool
- structureIdGetValue :: (HasCallStack, MonadIO m) => Structure -> Word32 -> m (Maybe GValue)
- structureIdHasField :: (HasCallStack, MonadIO m) => Structure -> Word32 -> m Bool
- structureIdHasFieldTyped :: (HasCallStack, MonadIO m) => Structure -> Word32 -> GType -> m Bool
- structureIdSetValue :: (HasCallStack, MonadIO m) => Structure -> Word32 -> GValue -> m ()
- structureIdTakeValue :: (HasCallStack, MonadIO m) => Structure -> Word32 -> GValue -> m ()
- structureIntersect :: (HasCallStack, MonadIO m) => Structure -> Structure -> m (Maybe Structure)
- structureIsEqual :: (HasCallStack, MonadIO m) => Structure -> Structure -> m Bool
- structureIsSubset :: (HasCallStack, MonadIO m) => Structure -> Structure -> m Bool
- structureMapInPlace :: (HasCallStack, MonadIO m) => Structure -> StructureMapFunc -> m Bool
- structureNFields :: (HasCallStack, MonadIO m) => Structure -> m Int32
- structureNewEmpty :: (HasCallStack, MonadIO m) => Text -> m Structure
- structureNewFromString :: (HasCallStack, MonadIO m) => Text -> m (Maybe Structure)
- structureNewIdEmpty :: (HasCallStack, MonadIO m) => Word32 -> m Structure
- structureNthFieldName :: (HasCallStack, MonadIO m) => Structure -> Word32 -> m Text
- structureRemoveAllFields :: (HasCallStack, MonadIO m) => Structure -> m ()
- structureRemoveField :: (HasCallStack, MonadIO m) => Structure -> Text -> m ()
- structureSetArray :: (HasCallStack, MonadIO m) => Structure -> Text -> ValueArray -> m ()
- structureSetList :: (HasCallStack, MonadIO m) => Structure -> Text -> ValueArray -> m ()
- structureSetName :: (HasCallStack, MonadIO m) => Structure -> Text -> m ()
- structureSetParentRefcount :: (HasCallStack, MonadIO m) => Structure -> Int32 -> m Bool
- structureSetValue :: (HasCallStack, MonadIO m) => Structure -> Text -> GValue -> m ()
- structureTakeValue :: (HasCallStack, MonadIO m) => Structure -> Text -> GValue -> m ()
- structureToString :: (HasCallStack, MonadIO m) => Structure -> m Text
- getStructureType :: MonadIO m => Structure -> m GType
- setStructureType :: MonadIO m => Structure -> GType -> m ()
Exported types
Memory-managed wrapper type.
newZeroStructure :: MonadIO m => m Structure Source #
Construct a Structure
struct initialized to zero.
Methods
canIntersect
structureCanIntersect Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Structure |
|
-> m Bool | Returns: |
Tries intersecting struct1
and struct2
and reports whether the result
would not be empty.
copy
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> m Structure | Returns: a new |
Duplicates a Structure
and all its fields and values.
Free-function: gst_structure_free
filterAndMapInPlace
structureFilterAndMapInPlace Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> StructureFilterMapFunc |
|
-> m () |
Calls the provided function once for each field in the Structure
. In
contrast to structureForeach
, the function may modify the fields.
In contrast to structureMapInPlace
, the field is removed from
the structure if False
is returned from the function.
The structure must be mutable.
Since: 1.6
fixate
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> m () |
Fixate all values in structure
using valueFixate
.
structure
will be modified in-place and should be writable.
fixateField
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m Bool | Returns: |
Fixates a Structure
by changing the given field with its fixated value.
fixateFieldBoolean
structureFixateFieldBoolean Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> Bool |
|
-> m Bool | Returns: |
Fixates a Structure
by changing the given fieldName
field to the given
target
boolean if that field is not fixed yet.
fixateFieldNearestDouble
structureFixateFieldNearestDouble Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> Double |
|
-> m Bool | Returns: |
Fixates a Structure
by changing the given field to the nearest
double to target
that is a subset of the existing field.
fixateFieldNearestFraction
structureFixateFieldNearestFraction Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> Int32 |
|
-> Int32 |
|
-> m Bool | Returns: |
Fixates a Structure
by changing the given field to the nearest
fraction to targetNumerator
/targetDenominator
that is a subset
of the existing field.
fixateFieldNearestInt
structureFixateFieldNearestInt Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> Int32 |
|
-> m Bool | Returns: |
Fixates a Structure
by changing the given field to the nearest
integer to target
that is a subset of the existing field.
fixateFieldString
structureFixateFieldString Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> Text |
|
-> m Bool | Returns: |
Fixates a Structure
by changing the given fieldName
field to the given
target
string if that field is not fixed yet.
foreach
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> StructureForeachFunc |
|
-> m Bool | Returns: |
Calls the provided function once for each field in the Structure
. The
function must not modify the fields. Also see structureMapInPlace
and structureFilterAndMapInPlace
.
free
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> m () |
Frees a Structure
and all its fields and values. The structure must not
have a parent when this function is called.
fromString
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Maybe Structure, Text) | Returns: a new |
getArray
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, ValueArray) | Returns: |
This is useful in language bindings where unknown Value
types are not
supported. This function will convert the GST_TYPE_ARRAY
into a newly
allocated ValueArray
and return it through array
. Be aware that this is
slower then getting the Value
directly.
getBoolean
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Bool) | Returns: |
Sets the boolean pointed to by value
corresponding to the value of the
given field. Caller is responsible for making sure the field exists
and has the correct type.
getClockTime
structureGetClockTime Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Word64) | Returns: |
Sets the clock time pointed to by value
corresponding to the clock time
of the given field. Caller is responsible for making sure the field exists
and has the correct type.
getDate
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Date) | Returns: |
Sets the date pointed to by value
corresponding to the date of the
given field. Caller is responsible for making sure the field exists
and has the correct type.
On success value
will point to a newly-allocated copy of the date which
should be freed with dateFree
when no longer needed (note: this is
inconsistent with e.g. structureGetString
which doesn't return a
copy of the string).
getDateTime
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, DateTime) | Returns: |
Sets the datetime pointed to by value
corresponding to the datetime of the
given field. Caller is responsible for making sure the field exists
and has the correct type.
On success value
will point to a reference of the datetime which
should be unreffed with dateTimeUnref
when no longer needed
(note: this is inconsistent with e.g. structureGetString
which doesn't return a copy of the string).
getDouble
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Double) | Returns: |
Sets the double pointed to by value
corresponding to the value of the
given field. Caller is responsible for making sure the field exists
and has the correct type.
getEnum
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> GType |
|
-> m (Bool, Int32) | Returns: |
Sets the int pointed to by value
corresponding to the value of the
given field. Caller is responsible for making sure the field exists,
has the correct type and that the enumtype is correct.
getFieldType
structureGetFieldType Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m GType | Returns: the |
Finds the field with the given name, and returns the type of the value it contains. If the field is not found, G_TYPE_INVALID is returned.
getFlagset
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Word32, Word32) | Returns: |
Read the GstFlagSet flags and mask out of the structure into the provided pointers.
Since: 1.6
getFraction
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Int32, Int32) | Returns: |
Sets the integers pointed to by valueNumerator
and valueDenominator
corresponding to the value of the given field. Caller is responsible
for making sure the field exists and has the correct type.
getInt
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Int32) | Returns: |
Sets the int pointed to by value
corresponding to the value of the
given field. Caller is responsible for making sure the field exists
and has the correct type.
getInt64
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Int64) | Returns: |
Sets the gint64
pointed to by value
corresponding to the value of the
given field. Caller is responsible for making sure the field exists
and has the correct type.
Since: 1.4
getList
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, ValueArray) | Returns: Since 1.12 |
getName
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> m Text | Returns: the name of the structure. |
Get the name of structure
as a string.
getNameId
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> m Word32 | Returns: the quark representing the name of the structure. |
Get the name of structure
as a GQuark.
getString
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Maybe Text) | Returns: a pointer to the string or |
Finds the field corresponding to fieldname
, and returns the string
contained in the field's value. Caller is responsible for making
sure the field exists and has the correct type.
The string should not be modified, and remains valid until the next call to a gst_structure_*() function with the given structure.
getUint
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Word32) | Returns: |
Sets the uint pointed to by value
corresponding to the value of the
given field. Caller is responsible for making sure the field exists
and has the correct type.
getUint64
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Bool, Word64) | Returns: |
Sets the guint64
pointed to by value
corresponding to the value of the
given field. Caller is responsible for making sure the field exists
and has the correct type.
Since: 1.4
getValue
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m (Maybe GValue) | Returns: the |
Get the value of the field with name fieldname
.
hasField
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m Bool | Returns: |
Check if structure
contains a field named fieldname
.
hasFieldTyped
structureHasFieldTyped Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> GType |
|
-> m Bool | Returns: |
Check if structure
contains a field named fieldname
and with GType type
.
hasName
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m Bool | Returns: |
Checks if the structure has the given name
idGetValue
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Word32 |
|
-> m (Maybe GValue) | Returns: the |
Get the value of the field with GQuark field
.
idHasField
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Word32 |
|
-> m Bool | Returns: |
Check if structure
contains a field named field
.
idHasFieldTyped
structureIdHasFieldTyped Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Word32 |
|
-> GType |
|
-> m Bool | Returns: |
Check if structure
contains a field named field
and with GType type
.
idSetValue
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Word32 |
|
-> GValue |
|
-> m () |
Sets the field with the given GQuark field
to value
. If the field
does not exist, it is created. If the field exists, the previous
value is replaced and freed.
idTakeValue
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Word32 |
|
-> GValue |
|
-> m () |
Sets the field with the given GQuark field
to value
. If the field
does not exist, it is created. If the field exists, the previous
value is replaced and freed.
intersect
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Structure |
|
-> m (Maybe Structure) | Returns: Intersection of |
Intersects struct1
and struct2
and returns the intersection.
isEqual
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Structure |
|
-> m Bool | Returns: |
Tests if the two Structure
are equal.
isSubset
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Structure |
|
-> m Bool | Returns: |
Checks if subset
is a subset of superset
, i.e. has the same
structure name and for all fields that are existing in superset
,
subset
has a value that is a subset of the value in superset
.
mapInPlace
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> StructureMapFunc |
|
-> m Bool | Returns: |
Calls the provided function once for each field in the Structure
. In
contrast to structureForeach
, the function may modify but not delete the
fields. The structure must be mutable.
nFields
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> m Int32 | Returns: the number of fields in the structure |
Get the number of fields in the structure.
newEmpty
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Structure | Returns: a new, empty |
Creates a new, empty Structure
with the given name
.
See structureSetName
for constraints on the name
parameter.
Free-function: gst_structure_free
newFromString
structureNewFromString Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Maybe Structure) | Returns: a new |
Creates a Structure
from a string representation.
If end is not Nothing
, a pointer to the place inside the given string
where parsing ended will be returned.
The current implementation of serialization will lead to unexpected results
when there are nested Caps
/ Structure
deeper than one level.
Free-function: gst_structure_free
Since: 1.2
newIdEmpty
:: (HasCallStack, MonadIO m) | |
=> Word32 |
|
-> m Structure | Returns: a new, empty |
Creates a new, empty Structure
with the given name as a GQuark.
Free-function: gst_structure_free
nthFieldName
structureNthFieldName Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Word32 |
|
-> m Text | Returns: the name of the given field number |
Get the name of the given field number, counting from 0 onwards.
removeAllFields
structureRemoveAllFields Source #
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> m () |
Removes all fields in a GstStructure.
removeField
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m () |
Removes the field with the given name. If the field with the given name does not exist, the structure is unchanged.
setArray
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> ValueArray |
|
-> m () |
This is useful in language bindings where unknown GValue types are not
supported. This function will convert a array
to GST_TYPE_ARRAY
and set
the field specified by fieldname
. Be aware that this is slower then using
GST_TYPE_ARRAY
in a Value
directly.
Since 1.12
setList
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> ValueArray |
|
-> m () |
This is useful in language bindings where unknown GValue types are not
supported. This function will convert a array
to GST_TYPE_LIST
and set
the field specified by fieldname
. Be aware that this is slower then using
GST_TYPE_LIST
in a Value
directly.
Since 1.12
setName
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> m () |
Sets the name of the structure to the given name
. The string
provided is copied before being used. It must not be empty, start with a
letter and can be followed by letters, numbers and any of "/-_.:".
setParentRefcount
setValue
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> GValue |
|
-> m () |
Sets the field with the given name field
to value
. If the field
does not exist, it is created. If the field exists, the previous
value is replaced and freed.
takeValue
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> Text |
|
-> GValue |
|
-> m () |
Sets the field with the given name field
to value
. If the field
does not exist, it is created. If the field exists, the previous
value is replaced and freed. The function will take ownership of value
.
toString
:: (HasCallStack, MonadIO m) | |
=> Structure |
|
-> m Text | Returns: a pointer to string allocated by |
Converts structure
to a human-readable string representation.
For debugging purposes its easier to do something like this:
C code
GST_LOG ("structure is %" GST_PTR_FORMAT, structure);
This prints the structure in human readable form.
The current implementation of serialization will lead to unexpected results
when there are nested Caps
/ Structure
deeper than one level.
Free-function: g_free
Properties
type
the GType of a structure
getStructureType :: MonadIO m => Structure -> m GType Source #
Get the value of the “type
” field.
When overloading is enabled, this is equivalent to
get
structure #type
setStructureType :: MonadIO m => Structure -> GType -> m () Source #
Set the value of the “type
” field.
When overloading is enabled, this is equivalent to
set
structure [ #type:=
value ]