GvdbItem *parent;
GvdbItem *sibling;
GvdbItem *next;
- GVariant *options;
/* one of:
* this:
if (item->value)
g_variant_unref (item->value);
- if (item->options)
- g_variant_unref (item->options);
-
if (item->table)
g_hash_table_unref (item->table);
}
void
-gvdb_item_set_options (GvdbItem *item,
- GVariant *options)
-{
- g_return_if_fail (!item->options);
-
- item->options = g_variant_ref_sink (options);
-}
-
-void
gvdb_item_set_hash_table (GvdbItem *item,
GHashTable *table)
{
}
static void
-file_builder_add_options (FileBuilder *fb,
- GVariant *options,
- struct gvdb_pointer *pointer)
-{
- GVariant *normal;
- gpointer data;
- gsize size;
-
- if (options)
- {
- if (fb->byteswap)
- {
- options = g_variant_byteswap (options);
- normal = g_variant_get_normal_form (options);
- g_variant_unref (options);
- }
- else
- normal = g_variant_get_normal_form (options);
-
- size = g_variant_get_size (normal);
- data = file_builder_allocate (fb, 8, size, pointer);
- g_variant_store (normal, data);
- g_variant_unref (normal);
- }
-}
-
-static void
file_builder_add_string (FileBuilder *fb,
const gchar *string,
guint32_le *start,
g_assert (item->child == NULL && item->table == NULL);
file_builder_add_value (fb, item->value, &entry->value.pointer);
- file_builder_add_options (fb, item->options, &entry->options);
entry->type = 'v';
}
void gvdb_item_set_value (GvdbItem *item,
GVariant *value);
G_GNUC_INTERNAL
-void gvdb_item_set_options (GvdbItem *item,
- GVariant *options);
-G_GNUC_INTERNAL
void gvdb_item_set_hash_table (GvdbItem *item,
GHashTable *table);
G_GNUC_INTERNAL
struct gvdb_pointer pointer;
gchar direct[8];
} value;
-
- struct gvdb_pointer options;
};
struct gvdb_header {
* gvdb_table_get_value:
* @file: a #GvdbTable
* @key: a string
- * @options: a pointer to a #GVariant, or %NULL
* @returns: a #GVariant, or %NULL
*
* Looks up a value named @key in @file.
* #GVariant instance is returned. The #GVariant does not depend on the
* continued existence of @file.
*
- * If @options is non-%NULL then it will be set either to %NULL in the
- * case of no options or a #GVariant containing a dictionary mapping
- * strings to variants.
- *
* You should call g_variant_unref() on the return result when you no
* longer require it.
**/
GVariant *
gvdb_table_get_value (GvdbTable *file,
- const gchar *key,
- GVariant **options)
+ const gchar *key)
{
const struct gvdb_hash_item *item;
- GVariant *value;
if ((item = gvdb_table_lookup (file, key, 'v')) == NULL)
return NULL;
- value = gvdb_table_value_from_item (file, item);
-
- if (options != NULL)
- {
- gconstpointer data;
- gsize size;
-
- data = gvdb_table_dereference (file, &item->options, 8, &size);
-
- if (data != NULL && size > 0)
- {
- *options = g_variant_new_from_data (G_VARIANT_TYPE ("a{sv}"),
- data, size, file->trusted,
- (GDestroyNotify) g_mapped_file_unref,
- g_mapped_file_ref (file->mapped));
- g_variant_ref_sink (*options);
- }
- else
- *options = NULL;
- }
-
- return value;
+ return gvdb_table_value_from_item (file, item);
}
/**
const gchar *key);
G_GNUC_INTERNAL
GVariant * gvdb_table_get_value (GvdbTable *table,
- const gchar *key,
- GVariant **options);
+ const gchar *key);
G_GNUC_INTERNAL
gboolean gvdb_table_has_value (GvdbTable *table,