Grl.Data

g GObject.Object GObject.Object Grl.Data Grl.Data GObject.Object->Grl.Data

Subclasses:

Grl.Media

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_binary (key, buf, size)

add_boxed (key, boxed)

add_float (key, floatvalue)

add_for_id (key_name, value)

add_int (key, intvalue)

add_int64 (key, intvalue)

add_related_keys (relkeys)

add_string (key, strvalue)

dup ()

get (key)

get_binary (key)

get_boolean (key)

get_boxed (key)

get_float (key)

get_int (key)

get_int64 (key)

get_keys ()

get_related_keys (key, index)

get_single_values_for_key (key)

get_single_values_for_key_string (key)

get_string (key)

has_key (key)

length (key)

remove (key)

remove_nth (key, index)

set (key, value)

set_binary (key, buf, size)

set_boolean (key, boolvalue)

set_boxed (key, boxed)

set_float (key, floatvalue)

set_for_id (key_name, value)

set_int (key, intvalue)

set_int64 (key, intvalue)

set_related_keys (relkeys, index)

set_string (key, strvalue)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class Grl.Data(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Grl.DataClass

classmethod new()
Returns:

a new data object.

Return type:

Grl.Data

Creates a new data object.

New in version 0.1.4.

add_binary(key, buf, size)
Parameters:
  • key (int) – key to append

  • buf (int) – the buffer containing the new value

  • size (int) – size of buffer

Appends a new binary value for key in self.

New in version 0.1.10.

add_boxed(key, boxed)
Parameters:
  • key (int) – key to append

  • boxed (object or None) – the new value

Appends a new boxed value for key in self.

New in version 0.2.0.

add_float(key, floatvalue)
Parameters:
  • key (int) – key to append

  • floatvalue (float) – the new value

Appends a new float value for key in self.

New in version 0.1.10.

add_for_id(key_name, value)
Parameters:
  • key_name (str) – name of the key to change or add

  • value (GObject.Value) – the new value

Returns:

True if value was added to key_name, False otherwise.

Return type:

bool

Appends the value associated with key_name to self. This key_name is used to create a new GObject.ParamSpec instance, which is further used to create and register a key using Grl.Registry.register_metadata_key().

A property key_name consists of segments consisting of ASCII letters and digits, separated by either the ‘-’ or ‘_’ character. The first character of a property key_name must be a letter. Key_names which violate these rules lead to undefined behaviour.

New in version 0.3.6.

add_int(key, intvalue)
Parameters:
  • key (int) – key to append

  • intvalue (int) – the new value

Appends a new int value for key in self.

New in version 0.1.10.

add_int64(key, intvalue)
Parameters:
  • key (int) – key to append

  • intvalue (int) – the new value

Appends a new int64 value for key in self.

New in version 0.2.12.

Parameters:

relkeys (Grl.RelatedKeys) – a set of related properties with their values

Adds a new set of values into self.

All keys in prop must be related among them.

self will take the ownership of relkeys, so do not modify it.

New in version 0.1.10.

add_string(key, strvalue)
Parameters:
  • key (int) – key to append

  • strvalue (str) – the new value

Appends a new string value for key in self.

New in version 0.1.10.

dup()
Returns:

a new Grl.Data. Free it with GObject.Object.unref.

Return type:

Grl.Data

Makes a deep copy of self and all its contents.

New in version 0.1.10.

get(key)
Parameters:

key (int) – key to look up.

Returns:

a GObject.Value. This value should not be modified nor freed by user.

Return type:

GObject.Value

Get the first value from self associated with key.

New in version 0.1.4.

get_binary(key)
Parameters:

key (int) – key to use

Returns:

buffer location associated with the key, or None in other case. If successful size will be set the to the buffer size.

size:

location to store the buffer size

Return type:

(int, size: int)

Returns the first binary value associated with key from self. If key has no first value, or value is not a float, or key is not in data, then None is returned.

New in version 0.1.9.

get_boolean(key)
Parameters:

key (int) – key to use

Returns:

the first boolean value associated with key from self. If key has no first value, or value is not a bool, or key is not in the data, then False is returned

Return type:

bool

New in version 0.2.3.

get_boxed(key)
Parameters:

key (int) – key to use

Returns:

the boxed instance associated with key if possible, or None in other cases. The caller should not change nor free the value.

Return type:

object or None

Returns the first boxed value associated with key from self. If key has no first value, that value is not of a boxed type, or key is not in self, then None is returned.

New in version 0.2.0.

get_float(key)
Parameters:

key (int) – key to use

Returns:

float value associated with key, or 0 in other case.

Return type:

float

Returns the first float value associated with key from self. If key has no first value, or value is not a float, or key is not in data, then 0 is returned.

New in version 0.1.5.

get_int(key)
Parameters:

key (int) – key to use

Returns:

int value associated with key, or 0 in other case.

Return type:

int

Returns the first int value associated with key from self. If key has no first value, or value is not a int, or key is not in data, then 0 is returned.

New in version 0.1.4.

get_int64(key)
Parameters:

key (int) – key to use

Returns:

int value associated with key, or 0 in other case.

Return type:

int

Returns the first int64 value associated with key from self. If key has no first value, or value is not a int, or key is not in data, then 0 is returned.

New in version 0.2.12.

get_keys()
Returns:

an array with the keys. The content of the list should not be modified or freed. Use g_list_free() when done using the list.

Return type:

[int]

Returns a list with keys contained in self.

New in version 0.1.4.

Parameters:
  • key (int) – a metadata key

  • index (int) – element to retrieve, starting at 0

Returns:

a Grl.RelatedKeys. Do not free it.

Return type:

Grl.RelatedKeys

Returns a set containing the values for key and related keys at position index from self.

If user changes any of the values in the related keys, the changes will become permanent.

New in version 0.1.10.

get_single_values_for_key(key)
Parameters:

key (int) – a metadata key

Returns:

a GLib.List with values. Do not change or free the values. Free the list with #g_list_free.

Return type:

[GObject.Value]

Returns all non-None values for key from self. This ignores related keys.

New in version 0.1.13.

get_single_values_for_key_string(key)
Parameters:

key (int) – a metadata key

Returns:

a GLib.List with values. Do not change or free the strings. Free the list with #g_list_free.

Return type:

[str]

Returns all non-None values for key from self. key must have been registered as a string-type key. This ignores related keys.

New in version 0.1.13.

get_string(key)
Parameters:

key (int) – key to use

Returns:

string associated with key, or None in other case. Caller should not change nor free the value.

Return type:

str

Returns the first string value associated with key from self. If key has no first value, or value is not string, or key is not in self, then None is returned.

New in version 0.1.4.

has_key(key)
Parameters:

key (int) – key to search

Returns:

True if key is in self, False in other case.

Return type:

bool

Checks if key is in self.

New in version 0.1.4.

length(key)
Parameters:

key (int) – a metadata key

Returns:

number of values

Return type:

int

Returns how many values key or related keys have in self: if key has no value, but a related key has, then it is counted as positive.

As example, let’s think in three related keys, K1, K2 and K3, and then thinks we have added several values for those keys, as:

(V10, V20, V30), (V11, None, V31), (V12, None, V32)

Therefore, when invoking Grl.Data.length (data, K2) it will return 3: considering K2 and the related keys (K1 and K3), there are 3 values.

New in version 0.1.10.

remove(key)
Parameters:

key (int) – key to remove

Removes the first value for key from self. If there are other keys related to key their values will also be removed from self.

New in version 0.1.4.

remove_nth(key, index)
Parameters:
  • key (int) – a metadata key

  • index (int) – index of key to be removed, starting at 0

Removes the value at position index for key from self. If there are other keys related to key, their values at position index will also be removed from self.

New in version 0.1.10.

set(key, value)
Parameters:

Sets the first value associated with key in self. If key already has a value old value is freed and the new one is set.

Also, checks that value is compliant with key specification, modifying it accordingly. For instance, if key requires a number between 0 and 10, but value is outside this range, it will be adapted accordingly.

New in version 0.1.4.

set_binary(key, buf, size)
Parameters:
  • key (int) – key to change or add

  • buf (int) – buffer holding the data

  • size (int) – size of the buffer

Sets the first binary value associated with key in self. If key already has a first value old value is replaced by the new one.

New in version 0.1.9.

set_boolean(key, boolvalue)
Parameters:
  • key (int) – key to change or add

  • boolvalue (bool) – the new value

Sets the first boolean value associated with key in self. If key already has a first value, old value is replaced by the new one.

New in version 0.2.3.

set_boxed(key, boxed)
Parameters:
  • key (int) – key to change or add

  • boxed (object or None) – the new value

Sets the first boxed value associated with key in self. If key already has a value, the old value is freed and the new one is set.

New in version 0.2.0.

set_float(key, floatvalue)
Parameters:
  • key (int) – key to change or add

  • floatvalue (float) – the new value

Sets the first float value associated with key in self. If key already has a first value old value is replaced by the new one.

New in version 0.1.5.

set_for_id(key_name, value)
Parameters:
  • key_name (str) – name of the key to change or add

  • value (GObject.Value) – the new value

Returns:

True if value was set to key_name, False otherwise.

Return type:

bool

Sets the first value associated with key_name in self. This key_name is used to create a new GObject.ParamSpec instance, which is further used to create and register a key using Grl.Registry.register_metadata_key(). If key_name already has a first value, old value is replaced by the new one.

A property key_name consists of segments consisting of ASCII letters and digits, separated by either the ‘-’ or ‘_’ character. The first character of a property key_name must be a letter. Key_names which violate these rules lead to undefined behaviour.

New in version 0.3.6.

set_int(key, intvalue)
Parameters:
  • key (int) – key to change or add

  • intvalue (int) – the new value

Sets the first int value associated with key in self. If key already has a first value old value is replaced by the new one.

New in version 0.1.4.

set_int64(key, intvalue)
Parameters:
  • key (int) – key to change or add

  • intvalue (int) – the new value

Sets the first int64 value associated with key in self. If key already has a first value old value is replaced by the new one.

New in version 0.2.12.

Parameters:
  • relkeys (Grl.RelatedKeys) – a set of related keys

  • index (int) – position to be updated, starting at 0

Updates the values at position index in self with values in relkeys.

self will take ownership of relkeys, so do not free it after invoking this function.

New in version 0.1.10.

set_string(key, strvalue)
Parameters:
  • key (int) – key to change or add

  • strvalue (str) – the new value

Sets the first string value associated with key in self. If key already has a value old value is freed and the new one is set.

New in version 0.1.4.