glibmm 2.80.0
|
VariantDict is a mutable interface to Variant dictionaries. More...
#include <glibmm/variantdict.h>
Public Member Functions | |
void | reference () const |
Increment the reference count for this object. | |
void | unreference () const |
Decrement the reference count for this object. | |
GVariantDict * | gobj () |
Provides access to the underlying C instance. | |
const GVariantDict * | gobj () const |
Provides access to the underlying C instance. | |
GVariantDict * | gobj_copy () const |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
VariantDict ()=delete | |
VariantDict (const VariantDict &)=delete | |
VariantDict & | operator= (const VariantDict &)=delete |
bool | lookup_value_variant (const Glib::ustring & key, const VariantType &expected_type, VariantBase & value) const |
Looks up a value in the VariantDict. | |
template<typename T_Value > | |
bool | lookup_value (const Glib::ustring & key, T_Value & value) const |
Looks up a value in the VariantDict. | |
bool | contains (const Glib::ustring & key) const |
Checks if key exists in dict. | |
void | insert_value_variant (const Glib::ustring & key, const VariantBase & value) |
Inserts (or replaces) a key in a VariantDict. | |
template<typename T_Value > | |
void | insert_value (const Glib::ustring & key, const T_Value & value) |
Inserts (or replaces) a key in a VariantDict. | |
bool | remove (const Glib::ustring & key) |
Removes a key and its associated value from a VariantDict. | |
void | clear () |
Releases all memory associated with a VariantDict without freeing the VariantDict structure itself. | |
Static Public Member Functions | |
static Glib::RefPtr< VariantDict > | create (const VariantBase &from_asv) |
Allocates and initialises a new VariantDict. | |
static Glib::RefPtr< VariantDict > | create () |
A create() convenience overload. | |
Protected Member Functions | |
void | operator delete (void *, std::size_t) |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Glib::VariantDict > | wrap (GVariantDict *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
VariantDict is a mutable interface to Variant dictionaries.
It can be used for doing a sequence of dictionary lookups in an efficient way on an existing Variant dictionary or it can be used to construct new dictionaries with a hashtable-like interface. It can also be used for taking existing dictionaries and modifying them in order to create new ones.
newin{2,40}
|
delete |
|
delete |
void Glib::VariantDict::clear | ( | ) |
Releases all memory associated with a VariantDict without freeing the VariantDict structure itself.
It typically only makes sense to do this on a stack-allocated VariantDict if you want to abort building the value part-way through. This function need not be called if you call g_variant_dict_end() and it also doesn't need to be called on dicts allocated with g_variant_dict_new (see g_variant_dict_unref() for that).
It is valid to call this function on either an initialised VariantDict or one that was previously cleared by an earlier call to g_variant_dict_clear() but it is not valid to call this function on uninitialised memory.
bool Glib::VariantDict::contains | ( | const Glib::ustring & | key | ) | const |
Checks if key exists in dict.
key | The key to look up in the dictionary. |
true
if key is in dict.
|
static |
A create() convenience overload.
|
static |
Allocates and initialises a new VariantDict.
You should call g_variant_dict_unref() on the return value when it is no longer needed. The memory will not be automatically freed by any other call.
In some cases it may be easier to place a VariantDict directly on the stack of the calling function and initialise it with g_variant_dict_init(). This is particularly useful when you are using VariantDict to construct a Variant.
from_asv | The Variant with which to initialise the dictionary. |
GVariantDict * Glib::VariantDict::gobj | ( | ) |
Provides access to the underlying C instance.
const GVariantDict * Glib::VariantDict::gobj | ( | ) | const |
Provides access to the underlying C instance.
GVariantDict * Glib::VariantDict::gobj_copy | ( | ) | const |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void Glib::VariantDict::insert_value | ( | const Glib::ustring & | key, |
const T_Value & | value | ||
) |
Inserts (or replaces) a key in a VariantDict.
key | The key to insert a value for. |
value | The value to insert. |
void Glib::VariantDict::insert_value_variant | ( | const Glib::ustring & | key, |
const VariantBase & | value | ||
) |
Inserts (or replaces) a key in a VariantDict.
value is consumed if it is floating.
key | The key to insert a value for. |
value | The value to insert. |
bool Glib::VariantDict::lookup_value | ( | const Glib::ustring & | key, |
T_Value & | value | ||
) | const |
Looks up a value in the VariantDict.
If the key is not found the false is returned.
If the value associated with key has a different type than expected then false is returned.
If the key is found and the value has the correct type, it is returned in the value output variable.
bool Glib::VariantDict::lookup_value_variant | ( | const Glib::ustring & | key, |
const VariantType & | expected_type, | ||
VariantBase & | value | ||
) | const |
Looks up a value in the VariantDict.
See also lookup_value().
If the key is not found the false is returned.
The expected_type string specifies what type of value is expected. If the value associated with key has a different type then false is returned.
If the key is found and the value has the correct type, it is returned in the value output variable.
|
delete |
void Glib::VariantDict::reference | ( | ) | const |
Increment the reference count for this object.
You should never need to do this manually - use the object via a RefPtr instead.
bool Glib::VariantDict::remove | ( | const Glib::ustring & | key | ) |
Removes a key and its associated value from a VariantDict.
key | The key to remove. |
true
if the key was found and removed. void Glib::VariantDict::unreference | ( | ) | const |
Decrement the reference count for this object.
You should never need to do this manually - use the object via a RefPtr instead.
|
related |
A Glib::wrap() method for this object.
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. |