libvdo
vdo-map.h
Go to the documentation of this file.
1 
9 #ifndef __VDO_MAP_H__
10 #define __VDO_MAP_H__
11 
12 #include <glib-object.h>
13 
14 G_BEGIN_DECLS
15 
57 #define VDO_TYPE_MAP (vdo_map_get_type())
58 G_DECLARE_FINAL_TYPE(VdoMap, vdo_map, VDO, MAP, GObject)
59 
60 
75 #define vdo_map_get_printf(self, type, def, len, format, ...) __extension__ ({\
76  gchar name[len];\
77  g_snprintf(name, len, format, __VA_ARGS__);\
78  vdo_map_get_##type(self, name, def);\
79 })
80 
81 #define vdo_map_get_string_printf(self, def, len, format, ...) __extension__ ({\
82  gchar name[len];\
83  g_snprintf(name, len, format, __VA_ARGS__);\
84  vdo_map_get_string(self, name, NULL, def);\
85 })
86 
87 #define vdo_map_dup_string_printf(self, def, len, format, ...) __extension__ ({\
88  gchar name[len];\
89  g_snprintf(name, len, format, __VA_ARGS__);\
90  vdo_map_dup_string(self, name, def);\
91 })
92 
102 #define vdo_map_set_printf(self, type, value, len, format, ...) {\
103  gchar name[len];\
104  g_snprintf(name, len, format, __VA_ARGS__);\
105  vdo_map_set_##type(self, name, value);\
106 }
107 
113 VdoMap *vdo_map_new(void);
114 
123 VdoMap *vdo_map_new_from_variant(GVariant *dictionary);
124 
132 gboolean vdo_map_empty(const VdoMap *self);
133 
141 gsize vdo_map_size(const VdoMap *self);
142 
149 void vdo_map_swap(VdoMap *lhs, VdoMap *rhs);
150 
159 gboolean vdo_map_contains(const VdoMap *self, const gchar *name);
160 
173 gboolean vdo_map_contains_va(const VdoMap *self, ...);
174 
187 gboolean vdo_map_contains_strv(const VdoMap *self, const gchar * const *names);
188 
199 gboolean vdo_map_entry_equals(const VdoMap *self, const VdoMap *map, const gchar *name);
200 
211 gboolean vdo_map_entry_updates(const VdoMap *self, const VdoMap *map, const gchar *name);
212 
221 gboolean vdo_map_equals(const VdoMap *self, const VdoMap *map);
222 
237 gboolean vdo_map_equals_va(const VdoMap *self, const VdoMap *map, ...);
238 
253 gboolean vdo_map_equals_strv(const VdoMap *self, const VdoMap *map, const gchar * const *names);
254 
261 void vdo_map_remove(VdoMap *self, const gchar *name);
262 
273 void vdo_map_remove_va(VdoMap *self, ...);
274 
285 void vdo_map_remove_strv(VdoMap *self, const gchar * const *names);
286 
292 void vdo_map_clear(VdoMap *self);
293 
304 VdoMap *vdo_map_filter_prefix(const VdoMap *self, const gchar *prefix);
305 
320 VdoMap *vdo_map_filter_va(const VdoMap *self, ...);
321 
336 VdoMap *vdo_map_filter_strv(const VdoMap *self, const gchar * const *names);
337 
344 void vdo_map_merge(VdoMap *self, const VdoMap *map);
345 
356 void vdo_map_copy_value(VdoMap *self, const gchar *src, const gchar *dst);
357 
365 GVariant *vdo_map_to_variant(const VdoMap *self);
366 
372 void vdo_map_dump(const VdoMap *self);
373 
386 GVariant *vdo_map_get_variant(const VdoMap *self, const gchar *name, GVariant *def);
387 gboolean vdo_map_get_boolean(const VdoMap *self, const gchar *name, gboolean def);
388 guchar vdo_map_get_byte(const VdoMap *self, const gchar *name, guchar def);
389 gint16 vdo_map_get_int16(const VdoMap *self, const gchar *name, gint16 def);
390 guint16 vdo_map_get_uint16(const VdoMap *self, const gchar *name, guint16 def);
391 gint32 vdo_map_get_int32(const VdoMap *self, const gchar *name, gint32 def);
392 guint32 vdo_map_get_uint32(const VdoMap *self, const gchar *name, guint32 def);
393 gint64 vdo_map_get_int64(const VdoMap *self, const gchar *name, gint64 def);
394 guint64 vdo_map_get_uint64(const VdoMap *self, const gchar *name, guint64 def);
395 gdouble vdo_map_get_double(const VdoMap *self, const gchar *name, gdouble def);
396 const gchar *vdo_map_get_string(const VdoMap *self, const gchar *name, gsize *size,
397  const gchar *def);
398 gchar *vdo_map_dup_string(const VdoMap *self, const gchar *name, const gchar *def);
399 guint32 *vdo_map_get_uint32x2(const VdoMap *self, const gchar *name, guint32 def[2]);
400 guint32 *vdo_map_get_uint32x4(const VdoMap *self, const gchar *name, guint32 def[4]);
401 gdouble *vdo_map_get_doublex4(const VdoMap *self, const gchar *name, gdouble def[4]);
402 
413 void vdo_map_set_boolean(VdoMap *self, const gchar *name, gboolean value);
414 void vdo_map_set_byte(VdoMap *self, const gchar *name, guchar value);
415 void vdo_map_set_int16(VdoMap *self, const gchar *name, gint16 value);
416 void vdo_map_set_uint16(VdoMap *self, const gchar *name, guint16 value);
417 void vdo_map_set_int32(VdoMap *self, const gchar *name, gint32 value);
418 void vdo_map_set_uint32(VdoMap *self, const gchar *name, guint32 value);
419 void vdo_map_set_int64(VdoMap *self, const gchar *name, gint64 value);
420 void vdo_map_set_uint64(VdoMap *self, const gchar *name, guint64 value);
421 void vdo_map_set_double(VdoMap *self, const gchar *name, gdouble value);
422 void vdo_map_set_string(VdoMap *self, const gchar *name, const gchar *value);
423 void vdo_map_set_uint32x2(VdoMap *self, const gchar *name, const guint32 value[2]);
424 void vdo_map_set_uint32x4(VdoMap *self, const gchar *name, const guint32 value[4]);
425 void vdo_map_set_doublex4(VdoMap *self, const gchar *name, const gdouble value[4]);
426 
427 G_END_DECLS
428 
429 #endif
void vdo_map_remove(VdoMap *self, const gchar *name)
Removes the entry with the specified key from this map.
gboolean vdo_map_contains_va(const VdoMap *self,...)
Checks if this map contains the specified set of keys.
gboolean vdo_map_contains_strv(const VdoMap *self, const gchar *const *names)
Checks if this map contains the specified set of keys.
GVariant * vdo_map_get_variant(const VdoMap *self, const gchar *name, GVariant *def)
Returns the value which the key name is associated with.
void vdo_map_clear(VdoMap *self)
Removes all of the entries from this map.
void vdo_map_swap(VdoMap *lhs, VdoMap *rhs)
Swaps the contents of two maps.
gboolean vdo_map_empty(const VdoMap *self)
Checks if this map is empty.
GVariant * vdo_map_to_variant(const VdoMap *self)
Create a GVariant dictionary containing all entries from this map.
A class representing a dictionary mapping keys to values.
gboolean vdo_map_equals_strv(const VdoMap *self, const VdoMap *map, const gchar *const *names)
Checks if all of the specified entries in this map and the specified map are equal.
void vdo_map_remove_strv(VdoMap *self, const gchar *const *names)
Removes all entries with the specified keys from this map.
VdoMap * vdo_map_filter_strv(const VdoMap *self, const gchar *const *names)
Returns a new map containing all entries from this map with the specified keys.
void vdo_map_merge(VdoMap *self, const VdoMap *map)
Merges the specified map into this map.
VdoMap * vdo_map_new_from_variant(GVariant *dictionary)
Constructs a new VdoMap with the same entries as the specified GVariant dictionary.
void vdo_map_copy_value(VdoMap *self, const gchar *src, const gchar *dst)
Copies the value associated with the key src to an entry with the key dst.
gboolean vdo_map_entry_equals(const VdoMap *self, const VdoMap *map, const gchar *name)
Checks if the specified entry in this map and the specified map are equal.
void vdo_map_dump(const VdoMap *self)
Print a string representation of this map to stdout.
gboolean vdo_map_equals(const VdoMap *self, const VdoMap *map)
Checks if all entries in this map and the specified map are equal.
VdoMap * vdo_map_filter_va(const VdoMap *self,...)
Returns a new map containing all entries from this map with the specified keys.
gsize vdo_map_size(const VdoMap *self)
Returns the number of entries in this map.
void vdo_map_set_boolean(VdoMap *self, const gchar *name, gboolean value)
Sets the value associated with the specified key.
gboolean vdo_map_equals_va(const VdoMap *self, const VdoMap *map,...)
Checks if all of the specified entries in this map and the specified map are equal.
VdoMap * vdo_map_filter_prefix(const VdoMap *self, const gchar *prefix)
Returns a new map containing all entries from this map with a key that matches the specified prefix...
VdoMap * vdo_map_new(void)
Constructs an new empty VdoMap.
gboolean vdo_map_contains(const VdoMap *self, const gchar *name)
Checks if this map contains the specified key.
gboolean vdo_map_entry_updates(const VdoMap *self, const VdoMap *map, const gchar *name)
Checks if the specified key in the specified map is mapped to a value that differs from the one in th...
void vdo_map_remove_va(VdoMap *self,...)
Removes all entries with the specified keys from this map.