T-variant
Gnome::Glib::T-variant
#------------------------------------------------------------------------------- #--[Class Initialization]------------------------------------------------------- #-------------------------------------------------------------------------------
Class initialization
new
Initialization of a type class is simple and only needed when the standalone functions are used.
method new ( )
#------------------------------------------------------------------------------- #--[Record Structure]----------------------------------------------------------- #-------------------------------------------------------------------------------
Record N-Variant
This is an opaque type of which fields are not available.
class N-Variant:auth<github:MARTIMM>:api<2> is export is repr('CStruct') { }
#------------------------------------------------------------------------------- #--[Record Structure Documentation]--------------------------------------------- #-------------------------------------------------------------------------------
Record N-VariantIter
class N-VariantIter:auth<github:MARTIMM>:api<2> is export is repr('CStruct') {
has gchar-pptr $.x;
}
x;
#------------------------------------------------------------------------------- #--[Record Structure]----------------------------------------------------------- #-------------------------------------------------------------------------------
Record N-VariantBuilder
This is an opaque type of which fields are not available.
class N-VariantBuilder:auth<github:MARTIMM>:api<2> is export is repr('CStruct') { }
#------------------------------------------------------------------------------- #--[Record Structure]----------------------------------------------------------- #-------------------------------------------------------------------------------
Record N-VariantDict
This is an opaque type of which fields are not available.
class N-VariantDict:auth<github:MARTIMM>:api<2> is export is repr('CStruct') { }
#------------------------------------------------------------------------------- #--[Enumerations]--------------------------------------------------------------- #-------------------------------------------------------------------------------
Enumerations
GVariantParseError
Error codes returned by parsing text-format GVariants.
G_VARIANT_PARSE_ERROR_FAILED; generic error (unused)G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED; a non-basic Gnome::Glib::N-VariantType was given where a basic type was expectedG_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE; cannot infer the Gnome::Glib::N-VariantTypeG_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED; an indefinite Gnome::Glib::N-VariantType was given where a definite type was expectedG_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END; extra data after parsing finishedG_VARIANT_PARSE_ERROR_INVALID_CHARACTER; invalid character in number or unicode escapeG_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING; not a valid Gnome::Glib::T-variant format stringG_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH; not a valid object pathG_VARIANT_PARSE_ERROR_INVALID_SIGNATURE; not a valid type signatureG_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING; not a valid Gnome::Glib::T-variant type stringG_VARIANT_PARSE_ERROR_NO_COMMON_TYPE; could not find a common type for array entriesG_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE; the numerical value is out of range of the given typeG_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG; the numerical value is out of range for any typeG_VARIANT_PARSE_ERROR_TYPE_ERROR; cannot parse as variant of the specified typeG_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN; an unexpected token was encounteredG_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD; an unknown keyword was encounteredG_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT; unterminated string constantG_VARIANT_PARSE_ERROR_VALUE_EXPECTED; no value givenG_VARIANT_PARSE_ERROR_RECURSION; variant was too deeply nested; Gnome::Glib::T-variant is only guaranteed to handle nesting up to 64 levels (Since: 2.64)
#------------------------------------------------------------------------------- #--[Standalone Functions]------------------------------------------------------- #-------------------------------------------------------------------------------
Standalone Functions
#-------------------------------------------------------------------------------
variant-is-object-path
Determines if a given string is a valid D-Bus object path. You
should ensure that a string is a valid D-Bus object path before
passing it to .new-object-path().
A valid object path starts with / followed by zero or more sequences of characters separated by / characters. Each sequence must contain only the characters [A-Z][a-z][0-9]_. No sequence (including the one following the final / character) may be empty.
method variant-is-object-path ( Str $string --> Bool )
$string; a normal C nul-terminated string.
Return value; True if $string is a D-Bus object path.
#-------------------------------------------------------------------------------
variant-is-signature
Determines if a given string is a valid D-Bus type signature. You
should ensure that a string is a valid D-Bus type signature before
passing it to .new-signature().
D-Bus type signatures consist of zero or more definite Gnome::Glib::N-VariantType strings in sequence.
method variant-is-signature ( Str $string --> Bool )
$string; a normal C nul-terminated string.
Return value; True if $string is a D-Bus type signature.
#-------------------------------------------------------------------------------
variant-parse
Parses a Gnome::Glib::T-variant from a text representation.
A single Gnome::Glib::T-variant is parsed from the content of $text.
The format is described here.
The memory at $limit will never be accessed and the parser behaves as
if the character at $limit is the nul terminator. This has the
effect of bounding $text.
If $endptr is non-undefined then $text is permitted to contain data
following the value that this function parses and $endptr will be
updated to point to the first character past the end of the text
parsed by this function. If $endptr is undefined and there is extra data
then an error is returned.
If $type is non-undefined then the value will be parsed to have that
type. This may result in additional parse errors (in the case that
the parsed value doesn't 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 Gnome::Glib::T-variant
is returned. It is never floating, and must be freed with
.unref().
In case of any error, undefined will be returned. If $error is non-undefined
then it will be set to reflect the error that occurred.
Officially, the language understood by the parser is "any string
produced by .print()".
There may be implementation specific restrictions on deeply nested values,
which would result in a G_VARIANT_PARSE_ERROR_RECURSION error. Gnome::Glib::T-variant is
guaranteed to handle nesting up to at least 64 levels.
method variant-parse ( N-Object $type, Str $text, Str $limit, Array[Str] $endptr, CArray[N-Error] $err --> N-Object )
$type; a Gnome::Glib::N-VariantType, or undefined
$text; a string containing a GVariant in text form.
$limit; a pointer to the end of
$text, or undefined.$endptr; a location to store the end pointer, or undefined.
$err; Error object. When defined, an error can be returned when there is one. Use
Pointerwhen you want to ignore the error. .
Return value; a non-floating reference to a Gnome::Glib::T-variant, or undefined.
#-------------------------------------------------------------------------------
variant-parse-error-print-context
Pretty-prints a message showing the context of a Gnome::Glib::T-variant parse error within the string for which parsing was attempted.
The resulting string is suitable for output to the console or other monospace media where newlines are treated in the usual way.
The message will typically look something like one of the following:
or
The format of the message may change in a future version.
$error must have come from a failed attempt to .parse() and $source-str must be exactly the same string that caused the error.
If $source-str was not nul-terminated when you passed it to
.parse() then you must add nul termination before using this
function.
method variant-parse-error-print-context ( N-Object $error, Str $source-str --> Str )
$error; a Gnome::Glib::N-Error from the Gnome::Glib::T-variant domain
$source-str; the string that was given to the parser.
Return value; the printed message.