libvdo
vdo-map.h File Reference

A class representing a dictionary mapping keys to values. More...

#include <glib-object.h>
#include "vdo-types.h"
Include dependency graph for vdo-map.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define vdo_map_get_printf(self, type, def, len, format, ...)
 Returns a value using a printf-style format string to specify a key. More...
 
#define vdo_map_set_printf(self, type, value, len, format, ...)
 Sets a value using a printf-style format string to specify a key. More...
 
#define vdo_map_remove_printf(self, len, format, ...)
 Removes an entry using a printf-style format string to specify a key. More...
 

Functions

VdoMapvdo_map_new (void)
 Constructs an new empty VdoMap. More...
 
VdoMapvdo_map_clone (const VdoMap *other)
 Creates a deep copy of the specified VdoMap. More...
 
gsize vdo_map_size (const VdoMap *self)
 Returns the number of entries in this map. More...
 
void vdo_map_swap (VdoMap *lhs, VdoMap *rhs)
 Swaps the contents of two maps. More...
 
gboolean vdo_map_contains (const VdoMap *self, const gchar *name)
 Checks if this map contains the specified key. More...
 
gboolean vdo_map_contains_va (const VdoMap *self,...)
 Checks if this map contains the specified set of keys. More...
 
gboolean vdo_map_contains_strv (const VdoMap *self, const gchar *const *names)
 Checks if this map contains the specified set of keys. More...
 
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. More...
 
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 this map. More...
 
gboolean vdo_map_equals (const VdoMap *self, const VdoMap *map)
 Checks if all entries in this map and the specified map are equal. More...
 
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. More...
 
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. More...
 
void vdo_map_remove (VdoMap *self, const gchar *name)
 Removes the entry with the specified key from this map. More...
 
void vdo_map_remove_va (VdoMap *self,...)
 Removes all entries with the specified keys from this map. More...
 
void vdo_map_remove_strv (VdoMap *self, const gchar *const *names)
 Removes all entries with the specified keys from this map. More...
 
void vdo_map_clear (VdoMap *self)
 Removes all of the entries from this map. More...
 
VdoMapvdo_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. More...
 
VdoMapvdo_map_filter_va (const VdoMap *self,...)
 Returns a new map containing all entries from this map with the specified keys. More...
 
VdoMapvdo_map_filter_strv (const VdoMap *self, const gchar *const *names)
 Returns a new map containing all entries from this map with the specified keys. More...
 
void vdo_map_merge (VdoMap *self, const VdoMap *map)
 Merges the specified map into this map. More...
 
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. More...
 
gint32 vdo_map_get_int32 (const VdoMap *self, const gchar *name, gint32 def)
 Returns the value which the key name is associated with. More...
 
guint32 vdo_map_get_uint32 (const VdoMap *self, const gchar *name, guint32 def)
 Returns the value which the key name is associated with. More...
 
gint64 vdo_map_get_int64 (const VdoMap *self, const gchar *name, gint64 def)
 Returns the value which the key name is associated with. More...
 
guint64 vdo_map_get_uint64 (const VdoMap *self, const gchar *name, guint64 def)
 Returns the value which the key name is associated with. More...
 
gdouble vdo_map_get_double (const VdoMap *self, const gchar *name, gdouble def)
 Returns the value which the key name is associated with. More...
 
const gchar * vdo_map_get_string (const VdoMap *self, const gchar *name, gsize *size, const gchar *def)
 Returns the value which the key name is associated with. More...
 
gchar * vdo_map_dup_string (const VdoMap *self, const gchar *name, const gchar *def)
 Returns the value which the key name is associated with. More...
 
VdoPair32i vdo_map_get_pair32i (const VdoMap *self, const gchar *name, VdoPair32i def)
 Returns the value which the key name is associated with. More...
 
VdoPair32u vdo_map_get_pair32u (const VdoMap *self, const gchar *name, VdoPair32u def)
 Returns the value which the key name is associated with. More...
 
VdoQuad32i vdo_map_get_quad32i (const VdoMap *self, const gchar *name, VdoQuad32i def)
 Returns the value which the key name is associated with. More...
 
VdoQuad32u vdo_map_get_quad32u (const VdoMap *self, const gchar *name, VdoQuad32u def)
 Returns the value which the key name is associated with. More...
 
void vdo_map_set_boolean (VdoMap *self, const gchar *name, gboolean value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_int32 (VdoMap *self, const gchar *name, gint32 value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_uint32 (VdoMap *self, const gchar *name, guint32 value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_int64 (VdoMap *self, const gchar *name, gint64 value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_uint64 (VdoMap *self, const gchar *name, guint64 value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_double (VdoMap *self, const gchar *name, gdouble value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_string (VdoMap *self, const gchar *name, const gchar *value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_pair32i (VdoMap *self, const gchar *name, VdoPair32i value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_pair32u (VdoMap *self, const gchar *name, VdoPair32u value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_quad32i (VdoMap *self, const gchar *name, VdoQuad32i value)
 Sets the value associated with the specified key. More...
 
void vdo_map_set_quad32u (VdoMap *self, const gchar *name, VdoQuad32u value)
 Sets the value associated with the specified key. More...
 

Detailed Description

A class representing a dictionary mapping keys to values.

Copyright (C) 2016-2019, Axis Communications AB, Lund

Macro Definition Documentation

◆ vdo_map_get_printf

#define vdo_map_get_printf (   self,
  type,
  def,
  len,
  format,
  ... 
)
Value:
__extension__ ({\
gchar name[len];\
g_snprintf(name, len, format, __VA_ARGS__);\
vdo_map_get_##type(self, name, def);\
})

Returns a value using a printf-style format string to specify a key.

These macros work due to a GCC extension: parentheses around a compound statement implicitly make the value of the last expression inside the block the return value of the whole block.

Parameters
selfA VdoMap.
typeThe type of the value to retrieve.
defDefault return value.
lenMaximum string length.
formatA printf-style format string to use as a key.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_remove_printf

#define vdo_map_remove_printf (   self,
  len,
  format,
  ... 
)
Value:
{\
gchar name[len];\
g_snprintf(name, len, format, __VA_ARGS__);\
vdo_map_remove(self, name);\
}

Removes an entry using a printf-style format string to specify a key.

Parameters
selfA VdoMap.
lenMaximum string length.
formatA printf-style format string to use as a key.

◆ vdo_map_set_printf

#define vdo_map_set_printf (   self,
  type,
  value,
  len,
  format,
  ... 
)
Value:
{\
gchar name[len];\
g_snprintf(name, len, format, __VA_ARGS__);\
vdo_map_set_##type(self, name, value);\
}

Sets a value using a printf-style format string to specify a key.

Parameters
selfA VdoMap.
typeThe type of the value to set.
valueThe value to set.
lenMaximum string length.
formatA printf-style format string to use as a key.

Function Documentation

◆ vdo_map_clear()

void vdo_map_clear ( VdoMap self)

Removes all of the entries from this map.

Parameters
selfA VdoMap.

◆ vdo_map_clone()

VdoMap* vdo_map_clone ( const VdoMap other)

Creates a deep copy of the specified VdoMap.

Parameters
otherA VdoMap.
Returns
A VdoMap. Free with g_object_unref().

◆ vdo_map_contains()

gboolean vdo_map_contains ( const VdoMap self,
const gchar *  name 
)

Checks if this map contains the specified key.

Parameters
selfA VdoMap.
nameThe key to check for.
Returns
TRUE if this map contains the specified key, otherwise FALSE.

◆ vdo_map_contains_strv()

gboolean vdo_map_contains_strv ( const VdoMap self,
const gchar *const *  names 
)

Checks if this map contains the specified set of keys.

Note
This function takes a string array which must be terminated with the value NULL.
Parameters
selfA VdoMap.
namesA NULL terminated string array containing the keys to be checked for containment in this map.
Returns
TRUE if this map contains all the specified keys, otherwise FALSE.

◆ vdo_map_contains_va()

gboolean vdo_map_contains_va ( const VdoMap self,
  ... 
)

Checks if this map contains the specified set of keys.

Note
This function takes a variable length argument list which must be terminated with the value NULL.
Parameters
selfA VdoMap.
...A NULL terminated variable argument list containing the keys to be checked for containment in this map.
Returns
TRUE if this map contains all the specified keys, otherwise FALSE.

◆ vdo_map_copy_value()

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.

If an entry with the key dst does not already exist, a new one is created. The value of the existing entry is modified otherwise.

Parameters
selfA VdoMap.
srcThe key associated with the value to copy.
dstThe key for the entry to be created/modified.

◆ vdo_map_dup_string()

gchar* vdo_map_dup_string ( const VdoMap self,
const gchar *  name,
const gchar *  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_entry_equals()

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.

Parameters
selfA VdoMap.
mapA map to be checked for equality with this map.
nameThe key specifying the entry to be checked for equality.
Returns
TRUE if the values mapped to the specified key in both maps are equal, otherwise FALSE

◆ vdo_map_entry_updates()

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 this map.

Parameters
selfA VdoMap.
mapA map to be checked for an updating entry.
namethe name of the map entry to check.
Returns
TRUE if map contains an updating entry for this map.

◆ vdo_map_equals()

gboolean vdo_map_equals ( const VdoMap self,
const VdoMap map 
)

Checks if all entries in this map and the specified map are equal.

Parameters
selfA VdoMap.
mapA VdoMap to compare for equality.
Returns
TRUE if all entries are equal, otherwise FALSE.

◆ vdo_map_equals_strv()

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.

This function takes a string array which must be terminated with the value NULL.

Parameters
selfA VdoMap.
mapA map to be checked for equality with this map.
namesA NULL terminated string array containing keys to be checked for equality.
Returns
TRUE if all entries are equal, otherwise FALSE.

◆ vdo_map_equals_va()

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.

This function takes a variable length argument list which must be terminated with the value NULL.

Parameters
selfA VdoMap.
mapA map to be checked for equality with this map.
...A NULL terminated variable argument list containing keys to be checked for equality.
Returns
TRUE if all the specified entries are equal, otherwise FALSE

◆ vdo_map_filter_prefix()

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.

Parameters
selfA VdoMap.
prefixA prefix string to use as filter.
Returns
A new map containing matching entries from self. Free with g_object_unref().

◆ vdo_map_filter_strv()

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.

This function takes a string array which must be terminated with the value NULL.

Parameters
selfA VdoMap.
namesA NULL terminated array of strings containing keys for entries to be copied to the new map.
Returns
A new map containing matching entries from self. Free with g_object_unref().

◆ vdo_map_filter_va()

VdoMap* vdo_map_filter_va ( const VdoMap self,
  ... 
)

Returns a new map containing all entries from this map with the specified keys.

This function takes a variable length argument list which must be terminated with the value NULL.

Parameters
selfA VdoMap.
...A NULL terminated variable argument list containing keys for entries to be copied to the new map.
Returns
A new map containing matching entries from self. Free with g_object_unref().

◆ vdo_map_get_double()

gdouble vdo_map_get_double ( const VdoMap self,
const gchar *  name,
gdouble  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_get_int32()

gint32 vdo_map_get_int32 ( const VdoMap self,
const gchar *  name,
gint32  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_get_int64()

gint64 vdo_map_get_int64 ( const VdoMap self,
const gchar *  name,
gint64  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_get_pair32i()

VdoPair32i vdo_map_get_pair32i ( const VdoMap self,
const gchar *  name,
VdoPair32i  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_get_pair32u()

VdoPair32u vdo_map_get_pair32u ( const VdoMap self,
const gchar *  name,
VdoPair32u  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_get_quad32i()

VdoQuad32i vdo_map_get_quad32i ( const VdoMap self,
const gchar *  name,
VdoQuad32i  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_get_quad32u()

VdoQuad32u vdo_map_get_quad32u ( const VdoMap self,
const gchar *  name,
VdoQuad32u  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_get_string()

const gchar* vdo_map_get_string ( const VdoMap self,
const gchar *  name,
gsize *  size,
const gchar *  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
[out]sizeA location to store the string length.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_get_uint32()

guint32 vdo_map_get_uint32 ( const VdoMap self,
const gchar *  name,
guint32  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.
Examples
vdo-example-blocking.cc, vdo-example-channel-filter.cc, and vdo-example.cc.

◆ vdo_map_get_uint64()

guint64 vdo_map_get_uint64 ( const VdoMap self,
const gchar *  name,
guint64  def 
)

Returns the value which the key name is associated with.

The specified default value def is returned if the specified key does not exists in this map.

Parameters
selfA VdoMap.
nameThe key associated with the value to be returned.
defDefault return value.
Returns
The value associated with the specified key, or default value.

◆ vdo_map_merge()

void vdo_map_merge ( VdoMap self,
const VdoMap map 
)

Merges the specified map into this map.

Parameters
selfA VdoMap.
mapA map to be merged into this map.

◆ vdo_map_new()

VdoMap* vdo_map_new ( void  )

Constructs an new empty VdoMap.

Returns
A VdoMap. Free with g_object_unref().
Examples
vdo-example-blocking.cc, vdo-example-channel-filter.cc, and vdo-example.cc.

◆ vdo_map_remove()

void vdo_map_remove ( VdoMap self,
const gchar *  name 
)

Removes the entry with the specified key from this map.

Parameters
selfA VdoMap.
nameThe key to remove.

◆ vdo_map_remove_strv()

void vdo_map_remove_strv ( VdoMap self,
const gchar *const *  names 
)

Removes all entries with the specified keys from this map.

This function takes a string array which must be terminated with the value NULL.

Parameters
selfA VdoMap.
namesA NULL terminated array of strings containing keys to be removed

◆ vdo_map_remove_va()

void vdo_map_remove_va ( VdoMap self,
  ... 
)

Removes all entries with the specified keys from this map.

This function takes a variable length argument list which must be terminated with the value NULL.

Parameters
selfA VdoMap.
...A NULL terminated variable argument list containing keys to be removed.

◆ vdo_map_set_boolean()

void vdo_map_set_boolean ( VdoMap self,
const gchar *  name,
gboolean  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.
Examples
vdo-example.cc.

◆ vdo_map_set_double()

void vdo_map_set_double ( VdoMap self,
const gchar *  name,
gdouble  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.

◆ vdo_map_set_int32()

void vdo_map_set_int32 ( VdoMap self,
const gchar *  name,
gint32  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.

◆ vdo_map_set_int64()

void vdo_map_set_int64 ( VdoMap self,
const gchar *  name,
gint64  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.

◆ vdo_map_set_pair32i()

void vdo_map_set_pair32i ( VdoMap self,
const gchar *  name,
VdoPair32i  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.

◆ vdo_map_set_pair32u()

void vdo_map_set_pair32u ( VdoMap self,
const gchar *  name,
VdoPair32u  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.

◆ vdo_map_set_quad32i()

void vdo_map_set_quad32i ( VdoMap self,
const gchar *  name,
VdoQuad32i  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.

◆ vdo_map_set_quad32u()

void vdo_map_set_quad32u ( VdoMap self,
const gchar *  name,
VdoQuad32u  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.

◆ vdo_map_set_string()

void vdo_map_set_string ( VdoMap self,
const gchar *  name,
const gchar *  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.
Examples
vdo-example-channel-filter.cc.

◆ vdo_map_set_uint32()

void vdo_map_set_uint32 ( VdoMap self,
const gchar *  name,
guint32  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.
Examples
vdo-example-blocking.cc, and vdo-example.cc.

◆ vdo_map_set_uint64()

void vdo_map_set_uint64 ( VdoMap self,
const gchar *  name,
guint64  value 
)

Sets the value associated with the specified key.

If an entry with the key name does not exist in this map. a new entry will be created.

Parameters
selfA VdoMap.
nameThe key associated with the value to be set.
valueThe value to set.

◆ vdo_map_size()

gsize vdo_map_size ( const VdoMap self)

Returns the number of entries in this map.

Parameters
selfA VdoMap.
Returns
The number of entries in this map.

◆ vdo_map_swap()

void vdo_map_swap ( VdoMap lhs,
VdoMap rhs 
)

Swaps the contents of two maps.

Parameters
lhsA VdoMap to swap with rhs.
rhsA VdoMap to swap with lhs.