package ocgtk
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054
doc/ocgtk.common/Gvariant/index.html
Module GvariantSource
GVariant - GLib's variant type for structured data serialization
GVariant is a variant data type used for:
- GSettings value storage and retrieval
- GAction parameters and state
- GDBus structured data
- GtkActionable action targets
Type Codes:
- b: boolean
- y: byte (uint8)
- n: int16
- q: uint16
- i: int32
- u: uint32
- x: int64
- t: uint64
- d: double
- s: string
- o: object_path
- g: signature
- h: handle (file descriptor)
- v: variant
- m*: maybe (nullable)
- a*: array
- () : tuple
- {
}
: dictionary entry
Unsigned Integer Types
Signed 16-bit integer - stored as OCaml int
Opaque GVariant Type
Opaque GVariant type - backed by GVariant* with g_variant_unref finalizer
Type Introspection
Get the type string of the variant (e.g., "i" for int32, "s" for string)
Boolean
Byte (uint8)
Signed Integers
Unsigned Integers
Floating Point
Text Types
Handle (File Descriptor)
Variant (Boxed Value)
Maybe (Nullable)
Create a maybe type variant. of_maybe ty None creates a null variant, of_maybe ty (Some v) wraps the value.
Unwrap a maybe type variant. Returns None for null, Some v for wrapped value.
Arrays
Dictionary Lookups (asv pattern)
These functions look up values in asv (string->variant) dictionaries. They return None if the key is not found or if the value is not of the expected type.
For dictionaries with different value types, use get_child_value with the appropriate index.
Lookup a string value in a dictionary. Returns None if the key is not found or the value is not a string.
Lookup an int32 value in a dictionary. Returns None if the key is not found or the value is not an int32.
Lookup a boolean value in a dictionary. Returns None if the key is not found or the value is not a boolean.
Lookup a byte (uint8) value in a dictionary. Returns None if the key is not found or the value is not a byte.
Lookup an int16 value in a dictionary. Returns None if the key is not found or the value is not an int16.
Lookup a uint16 value in a dictionary. Returns None if the key is not found or the value is not a uint16.
Lookup a uint32 value in a dictionary. Returns None if the key is not found or the value is not a uint32.
Lookup an int64 value in a dictionary. Returns None if the key is not found or the value is not an int64.
Lookup a uint64 value in a dictionary. Returns None if the key is not found or the value is not a uint64.
Lookup a double value in a dictionary. Returns None if the key is not found or the value is not a double.
Lookup an object path value in a dictionary. Returns None if the key is not found or the value is not an object path.
Lookup a signature value in a dictionary. Returns None if the key is not found or the value is not a signature.
Lookup a handle (file descriptor) value in a dictionary. Returns None if the key is not found or the value is not a handle.
Child Access
Get the nth child value. The returned value is a new reference and must be unreferenced by the caller (handled by GC).
Serialization
Print the variant in GVariant text format. First arg is the variant, second is whether to annotate types.