Glib::Variant< std::map< K, V > > Class Template Reference
Variant Data Types

Specialization of Variant containing a dictionary (a map of (key, value) elements). More...

`#include <glibmm/variant.h>`

Inheritance diagram for Glib::Variant< std::map< K, V > >:
[legend]

List of all members.

## Public Types

typedef std::pair< K, V > | CppType
typedef std::map< K, V > | CppContainerType

## Public Member Functions

| Variant ()
| Default constructor.
| Variant (GVariant* castitem, bool take_a_reference=false)
| GVariant constructor.
std::pair< K, V > | get_child (gsize index) const
| Gets a specific dictionary entry from the string array.
bool | lookup (const K& key, V&value) const
| Looks up a value in a dictionary Variant.
std::map< K, V > | get () const
| Gets the map (the dictionary) of the Variant.
VariantIter | get_iter () const
| Gets a VariantIter of the Variant.

## Static Public Member Functions

static const VariantType& | variant_type ()
| Gets the VariantType.
static Variant< std::map< K, V > > | create (const std::map< K, V >& data)
| Creates a new Variant containing a dictionary from a map.

## Detailed Description

### template<class K, class V>
class Glib::Variant< std::map< K, V > >

Specialization of Variant containing a dictionary (a map of (key, value) elements).

Since glibmm 2.28:

## Member Typedef Documentation

template <class K , class V >

typedef std::map<K, V> Glib::Variant< std::map< K, V > >::CppContainerType

template <class K , class V >

typedef std::pair<K, V> Glib::Variant< std::map< K, V > >::CppType

Reimplemented from Glib::VariantContainerBase.

## Constructor & Destructor Documentation

template <class K , class V >

Glib::Variant< std::map< K, V > >::Variant | ( |  | ) | `[inline]`

Default constructor.

template <class K , class V >

Glib::Variant< std::map< K, V > >::Variant | ( | GVariant< std::map< K, V > > * | castitem,
|  | bool | take_a_reference = `false`
| ) |  | `[inline, explicit]`

GVariant constructor.

Parameters:

  castitem | The GVariant to wrap.
  take_a_reference | Whether to take an extra reference of the GVariant or not (not taking one could destroy the GVariant with the wrapper).

## Member Function Documentation

template <class K , class V >

Variant< std::map< K, V > > Glib::Variant< std::map< K, V > >::create | ( | const std::map< K, V > & | data | ) | `[static]`

Creates a new Variant containing a dictionary from a map.

Parameters:

  data | The map to use for creation.

Returns:
  The new Variant holding a dictionary.

Since glibmm 2.28:

template <class K , class V >

std::map< K, V > Glib::Variant< std::map< K, V > >::get | ( |  | ) | const

Gets the map (the dictionary) of the Variant.

Returns:
  The vector.

Since glibmm 2.28:

template <class K , class V >

std::pair< K, V > Glib::Variant< std::map< K, V > >::get_child | ( | gsize | index | ) | const

Gets a specific dictionary entry from the string array.

It is an error if index is greater than the number of child items in the container. See VariantContainerBase::get_n_children().

This function is O(1).

Parameters:

  index | The index of the element.

Returns:
  The dictionary entry at index .

Exceptions:

  std::out_of_range |

Since glibmm 2.28:

template <class K , class V >

VariantIter Glib::Variant< std::map< K, V > >::get_iter | ( |  | ) | const

Gets a VariantIter of the Variant.

Returns:
  the VaraintIter.

Since glibmm 2.28:

template <class K , class V >

bool Glib::Variant< std::map< K, V > >::lookup | ( | const K & | key,
|  | V & | value
| ) |  | const

Looks up a value in a dictionary Variant.

Parameters:

  key | The key to look up.
  value | A location in which to store the value if found.

Returns:
  `true` if the key is found, `false` otherwise.

template <class K , class V >

const VariantType& Glib::Variant< std::map< K, V > >::variant_type | ( |  | ) | `[static]`

Gets the VariantType.

Returns:
  The VariantType.

Since glibmm 2.28: