Package: glib

Function g-variant-parse

Lambda List

g-variant-parse (vtype text)

Arguments

vtype -- a g-variant-type instance, or a valid type string
text -- a string containing a g-variant in text form

Return Value

A g-variant instance.

Details

Parses a g-variant instance from a text representation.

If vtype is non-nil then the value will be parsed to have that type. This may result in additional parse errors, in the case that the parsed value does not fit the type, but may also result in fewer errors, in the case that the type would have been ambiguous, such as with empty arrays.

In the event that the parsing is successful, the resulting g-variant instance is returned. In case of any error, nil will be returned.

Officially, the language understood by the parser is any string produced by the function g-variant-print.

Examples

(g-variant-parse (g-variant-type-new "b") "true")
=> #.(SB-SYS:INT-SAP #X7F99C4012440)
(g-variant-print *) => "true"
(g-variant-parse "b" "false")
=> #.(SB-SYS:INT-SAP #X564C855E8690)
(g-variant-print *) => "false"
(g-variant-parse (g-variant-type-new "i") "100")
=> #.(SB-SYS:INT-SAP #X7F99C4012CF0)
(g-variant-print * nil) => "100"
(g-variant-parse "d" "100")
=> #.(SB-SYS:INT-SAP #X564C855F9900)
(g-variant-print *) => "100.0"    
 

See also

2021-8-15