[Bug 20942] New: tp_asv_new() and tp_asv_set_*
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Mon Mar 30 11:22:50 CEST 2009
http://bugs.freedesktop.org/show_bug.cgi?id=20942
Summary: tp_asv_new() and tp_asv_set_*
Product: Telepathy
Version: unspecified
Platform: Other
OS/Version: All
Status: NEW
Severity: normal
Priority: medium
Component: telepathy-glib
AssignedTo: telepathy-bugs at lists.freedesktop.org
ReportedBy: davyd at madeley.id.au
As a compliment to tp_asv_get_*(), I'd like to propose the addition of a:
GHashTable *tp_asv_new (const char *first_key, ...)
Which calls:
GHashTable *asv = g_hash_table_new_full (
g_str_hash, g_str_equal,
NULL, (GDestroyNotify) tp_g_value_slice_free);
And then takes a NULL-terminated vararg list, as follows:
tp_asv_new ("answer", G_TYPE_INT, 42,
"question", G_TYPE_STR, "we just don't know",
NULL);
Plus a full set of `void tp_asv_set_TYPE(GHashTable *asv, const char *key, TYPE
v)` functions to complement the existing tp_asv_get_TYPE functions e.g.
void
tp_asv_set_string (GHashTable *asv, const char *key, char *value)
{
g_hash_table_insert (asv, key,
tp_g_value_slice_new_string (value));
}
This is effectively a rehash of bug #18220, but I think it would significantly
help to improve the readability of a{sv} maps and thus is worth having.
e.g. it drops this map setup for RequestConnection:
GHashTable *parameters = g_hash_table_new_full (
g_str_hash, g_str_equal,
NULL, (GDestroyNotify) tp_g_value_slice_free);
g_hash_table_insert (parameters, "account",
tp_g_value_slice_new_string ("davyd"));
g_hash_table_insert (parameters, "password",
tp_g_value_slice_new_string ("sup"));
Down to 3-4 nicely wrapped lines:
GHashTable *parameters = tp_asv_new (
"account", G_TYPE_STRING, "davyd",
"password", G_TYPE_STRING, "sup",
NULL);
--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the telepathy-bugs
mailing list