-static inline GVariantSerialised
-gvs_variant_get_child (GVariantSerialised value,
- gsize index_)
-{
- GVariantSerialised child = { 0, };
-
- /* NOTE: not O(1) and impossible for it to be... */
- if (value.size)
- {
- /* find '\0' character */
- for (child.size = value.size - 1; child.size; child.size--)
- if (value.data[child.size] == '\0')
- break;
-
- /* ensure we didn't just hit the start of the string */
- if (value.data[child.size] == '\0')
- {
- const gchar *type_string = (gchar *) &value.data[child.size + 1];
- const gchar *limit = (gchar *) &value.data[value.size];
- const gchar *end;
-
- if (g_variant_type_string_scan (type_string, limit, &end) &&
- end == limit)
- {
- const GVariantType *type = (GVariantType *) type_string;
-
- if (g_variant_type_is_definite (type))
- {
- gsize fixed_size;
-
- child.type_info = g_variant_type_info_get (type);
-
- if (child.size != 0)
- /* only set to non-%NULL if size > 0 */
- child.data = value.data;
-
- g_variant_type_info_query (child.type_info,
- NULL, &fixed_size);
-
- if (!fixed_size || fixed_size == child.size)
- return child;
-
- g_variant_type_info_unref (child.type_info);
- }
- }
- }
- }
-
- child.type_info = g_variant_type_info_get (G_VARIANT_TYPE_UNIT);
- child.data = NULL;
- child.size = 1;
-
- return child;
-}
-