diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2012-03-12 16:24:46 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2012-03-13 16:29:41 +0000 |
commit | 8beb04e8b2e261c97292c8f9f0485978e9b33d0a (patch) | |
tree | f92a92f0eee84e7338daa9b0450c2227a49531d9 /osinfo/osinfo_entity.c | |
parent | d74fd3c13054332e17f7889f35d37fcc54924f9a (diff) | |
download | libosinfo-8beb04e8b2e261c97292c8f9f0485978e9b33d0a.tar.gz |
Add a dummy "ID" property for entities
When querying/processing entities, it is useful if the 'id' field
appears just like other properties. Add a special case to handle
this
Diffstat (limited to 'osinfo/osinfo_entity.c')
-rw-r--r-- | osinfo/osinfo_entity.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c index 48d475d..4fd340d 100644 --- a/osinfo/osinfo_entity.c +++ b/osinfo/osinfo_entity.c @@ -271,8 +271,10 @@ const gchar *osinfo_entity_get_id(OsinfoEntity *entity) GList *osinfo_entity_get_param_keys(OsinfoEntity *entity) { g_return_val_if_fail(OSINFO_IS_ENTITY(entity), NULL); + GList *keys = g_hash_table_get_keys(entity->priv->params); + keys = g_list_append(keys, g_strdup("id")); - return g_hash_table_get_keys(entity->priv->params); + return keys; } @@ -294,6 +296,9 @@ const gchar *osinfo_entity_get_param_value(OsinfoEntity *entity, const gchar *ke GList *values; + if (g_str_equal(key, OSINFO_ENTITY_PROP_ID)) + return entity->priv->id; + values = g_hash_table_lookup(entity->priv->params, key); if (values) @@ -317,6 +322,9 @@ GList *osinfo_entity_get_param_value_list(OsinfoEntity *entity, const gchar *key g_return_val_if_fail(OSINFO_IS_ENTITY(entity), NULL); g_return_val_if_fail(key != NULL, NULL); + if (g_str_equal(key, OSINFO_ENTITY_PROP_ID)) + return g_list_append(NULL, entity->priv->id); + GList *values = g_hash_table_lookup(entity->priv->params, key); return g_list_copy(values); |