# Glib::VariantType Class Reference
[Variant Datatype]

TODO. More...

`#include <glibmm/varianttype.h>`

List of all members.

## Public Member Functions

| VariantType ()
| VariantType (GVariantType* castitem, bool make_a_copy=false)
| VariantType (const VariantType& src)
VariantType& | operator= (const VariantType& src)
| ~VariantType ()
GVariantType* | gobj ()
const GVariantType* | gobj () const
GVariantType* | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
| VariantType (const GVariantType* castitem)
| Copy the C item into a new VariantType instance.
| VariantType (const std::string& type_string)
VariantType& | operator= (const GVariantType* castitem)
std::string | get_string () const
| Returns the type string corresponding to the given type.
bool | is_definite () const
| Determines if the given type is definite (ie: not indefinite).
bool | is_container () const
| Determines if the given type is a container type.
bool | is_basic () const
| Determines if the given type is a basic type.
bool | is_maybe () const
| Determines if the given type is a maybe type.
bool | is_array () const
| Determines if the given type is an array type.
bool | is_tuple () const
| Determines if the given type is a tuple type.
bool | is_dict_entry () const
| Determines if the given type is a dictionary entry type.
bool | is_variant () const
| Determines if the given type is the variant type.
guint | hash () const
| Hashes type.
bool | equal (const VariantType& other) const
| Compares type1 and type2 for equality.
bool | is_subtype_of (const VariantType& supertype) const
| Checks if type is a subtype of supertype.
VariantType | element () const
| Determines the element type of an array or maybe type.
VariantType | first () const
| Determines the first item type of a tuple or dictionary entry type.
VariantType | next () const
| Determines the next item type of a tuple or dictionary entry type.
gsize | n_items () const
| Determines the number of items contained in a tuple or dictionary entry type.
VariantType | key () const
| Determines the key type of a dictionary entry type.
VariantType | value () const
| Determines the value type of a dictionary entry type.

## Static Public Member Functions

static VariantType | create_array (const VariantType& element)
| Constructs the type corresponding to an array of elements of the type type.
static VariantType | create_maybe (const VariantType& element)
| Constructs the type corresponding to a maybe instance containing type type or Nothing.
static VariantType | create_dict_entry (const VariantType& key, const VariantType& value)
| Constructs the type corresponding to a dictionary entry with a key of type key and a value of type value.

## Protected Attributes

GVariantType* | gobject_

## Related Functions

(Note that these are not member functions.)
Glib::VariantType | wrap (GVariantType* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

TODO.

Since glibmm 2.26:

## Constructor & Destructor Documentation

Glib::VariantType::VariantType | ( |  | ) |

Glib::VariantType::VariantType | ( | GVariantType * | castitem,
|  | bool | make_a_copy = `false` |
| ) |  |  | `[explicit]`

Glib::VariantType::VariantType | ( | const VariantType& | src | ) |

Glib::VariantType::~VariantType | ( |  | ) |

Glib::VariantType::VariantType | ( | const GVariantType * | castitem | ) | `[explicit]`

Copy the C item into a new VariantType instance.

Glib::VariantType::VariantType | ( | const std::string & | type_string | ) | `[explicit]`

## Member Function Documentation

static VariantType Glib::VariantType::create_array | ( | const VariantType& | element | ) | `[static]`

Constructs the type corresponding to an array of elements of the type type.

It is appropriate to call g_variant_type_free() on the return value.

Since 2.24

Returns:
  A new array VariantType.

static VariantType Glib::VariantType::create_dict_entry | ( | const VariantType& | key,
|  | const VariantType& | value |
| ) |  |  | `[static]`

Constructs the type corresponding to a dictionary entry with a key of type key and a value of type value.

It is appropriate to call g_variant_type_free() on the return value.

Since 2.24

Parameters:

  | value | A VariantType.

Returns:
  A new dictionary entry VariantType.

static VariantType Glib::VariantType::create_maybe | ( | const VariantType& | element | ) | `[static]`

Constructs the type corresponding to a maybe instance containing type type or Nothing.

It is appropriate to call g_variant_type_free() on the return value.

Since 2.24

Returns:
  A new maybe VariantType.

VariantType Glib::VariantType::element | ( |  | ) | const

Determines the element type of an array or maybe type.

This function may only be used with array or maybe types.

Since 2.24

Returns:
  The element type of type.

bool Glib::VariantType::equal | ( | const VariantType& | other | ) | const

Compares type1 and type2 for equality.

Only returns `true` if the types are exactly equal. Even if one type is an indefinite type and the other is a subtype of it, `false` will be returned if they are not exactly equal. If you want to check for subtypes, use g_variant_type_is_subtype_of().

The argument types of type1 and type2 are only gconstpointer to allow use with HashTable without function pointer casting. For both arguments, a valid VariantType must be provided.

Since 2.24

Parameters:

  | type1 | A VariantType.
  | type2 | A VariantType.

Returns:
  `true` if type1 and type2 are exactly equal.

VariantType Glib::VariantType::first | ( |  | ) | const

Determines the first item type of a tuple or dictionary entry type.

This function may only be used with tuple or dictionary entry types, but must not be used with the generic tuple type VARIANT_TYPE_TUPLE.

In the case of a dictionary entry type, this returns the type of the key.

`0` is returned in case of type being VARIANT_TYPE_UNIT.

This call, together with g_variant_type_next() provides an iterator interface over tuple and dictionary entry types.

Since 2.24

Returns:
  The first item type of type, or `0`.

std::string Glib::VariantType::get_string | ( |  | ) | const

Returns the type string corresponding to the given type.

The result is not nul-terminated; in order to determine its length you must call g_variant_type_get_string_length().

To get a nul-terminated string, see g_variant_type_dup_string().

Since 2.24

Returns:
  The corresponding type string (not nul-terminated).

const GVariantType* Glib::VariantType::gobj | ( |  | ) | const`[inline]`

GVariantType* Glib::VariantType::gobj | ( |  | ) | `[inline]`

GVariantType* Glib::VariantType::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.

guint Glib::VariantType::hash | ( |  | ) | const

Hashes type.

The argument type of type is only gconstpointer to allow use with HashTable without function pointer casting. A valid VariantType must be provided.

Since 2.24

Parameters:

  | type | A VariantType.

Returns:
  The hash value.

bool Glib::VariantType::is_array | ( |  | ) | const

Determines if the given type is an array type.

This is true if the type string for type starts with an 'a'.

This function returns `true` for any indefinite type for which every definite subtype is an array type -- VARIANT_TYPE_ARRAY, for example.

Since 2.24

Returns:
  `true` if type is an array type.

bool Glib::VariantType::is_basic | ( |  | ) | const

Determines if the given type is a basic type.

Basic types are booleans, bytes, integers, doubles, strings, object paths and signatures.

Only a basic type may be used as the key of a dictionary entry.

This function returns `false` for all indefinite types except VARIANT_TYPE_BASIC.

Since 2.24

Returns:
  `true` if type is a basic type.

bool Glib::VariantType::is_container | ( |  | ) | const

Determines if the given type is a container type.

Container types are any array, maybe, tuple, or dictionary entry types plus the variant type.

This function returns `true` for any indefinite type for which every definite subtype is a container -- VARIANT_TYPE_ARRAY, for example.

Since 2.24

Returns:
  `true` if type is a container type.

bool Glib::VariantType::is_definite | ( |  | ) | const

Determines if the given type is definite (ie: not indefinite).

A type is definite if its type string does not contain any indefinite type characters ('*', '?', or 'r').

A Variant instance may not have an indefinite type, so calling this function on the result of g_variant_get_type() will always result in `true` being returned. Calling this function on an indefinite type like VARIANT_TYPE_ARRAY, however, will result in `false` being returned.

Since 2.24

Returns:
  `true` if type is definite.

bool Glib::VariantType::is_dict_entry | ( |  | ) | const

Determines if the given type is a dictionary entry type.

This is true if the type string for type starts with a '{'.

This function returns `true` for any indefinite type for which every definite subtype is a dictionary entry type -- VARIANT_TYPE_DICT_ENTRY, for example.

Since 2.24

Returns:
  `true` if type is a dictionary entry type.

bool Glib::VariantType::is_maybe | ( |  | ) | const

Determines if the given type is a maybe type.

This is true if the type string for type starts with an 'm'.

This function returns `true` for any indefinite type for which every definite subtype is a maybe type -- VARIANT_TYPE_MAYBE, for example.

Since 2.24

Returns:
  `true` if type is a maybe type.

bool Glib::VariantType::is_subtype_of | ( | const VariantType& | supertype | ) | const

Checks if type is a subtype of supertype.

This function returns `true` if type is a subtype of supertype. All types are considered to be subtypes of themselves. Aside from that, only indefinite types can have subtypes.

Since 2.24

Parameters:

  | supertype | A VariantType.

Returns:
  `true` if type is a subtype of supertype.

bool Glib::VariantType::is_tuple | ( |  | ) | const

Determines if the given type is a tuple type.

This is true if the type string for type starts with a '(' or if type is VARIANT_TYPE_TUPLE.

This function returns `true` for any indefinite type for which every definite subtype is a tuple type -- VARIANT_TYPE_TUPLE, for example.

Since 2.24

Returns:
  `true` if type is a tuple type.

bool Glib::VariantType::is_variant | ( |  | ) | const

Determines if the given type is the variant type.

Since 2.24

Returns:
  `true` if type is the variant type.

VariantType Glib::VariantType::key | ( |  | ) | const

Determines the key type of a dictionary entry type.

This function may only be used with a dictionary entry type. Other than the additional restriction, this call is equivalent to g_variant_type_first().

Since 2.24

Returns:
  The key type of the dictionary entry.

gsize Glib::VariantType::n_items | ( |  | ) | const

Determines the number of items contained in a tuple or dictionary entry type.

This function may only be used with tuple or dictionary entry types, but must not be used with the generic tuple type VARIANT_TYPE_TUPLE.

In the case of a dictionary entry type, this function will always return 2.

Since 2.24

Returns:
  The number of items in type.

VariantType Glib::VariantType::next | ( |  | ) | const

Determines the next item type of a tuple or dictionary entry type.

type must be the result of a previous call to g_variant_type_first() or g_variant_type_next().

If called on the key type of a dictionary entry then this call returns the value type. If called on the value type of a dictionary entry then this call returns `0`.

For tuples, `0` is returned when type is the last item in a tuple.

Since 2.24

Returns:
  The next VariantType after type, or `0`.

VariantType& Glib::VariantType::operator= | ( | const GVariantType * | castitem | ) |

VariantType& Glib::VariantType::operator= | ( | const VariantType& | src | ) |

VariantType Glib::VariantType::value | ( |  | ) | const

Determines the value type of a dictionary entry type.

This function may only be used with a dictionary entry type.

Since 2.24

Returns:
  The value type of the dictionary entry.

## Friends And Related Function Documentation

Glib::VariantType wrap | ( | GVariantType * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

## Member Data Documentation

GVariantType* Glib::VariantType::gobject_ `[protected]`