GrlData

GrlData — Low-level class to store data

Synopsis

#include <grilo.h>

struct              GrlDataClass;
GrlData *           grl_data_new                        (void);
void                grl_data_set                        (GrlData *data,
                                                         GrlKeyID key,
                                                         const GValue *value);
void                grl_data_set_string                 (GrlData *data,
                                                         GrlKeyID key,
                                                         const gchar *strvalue);
void                grl_data_set_int                    (GrlData *data,
                                                         GrlKeyID key,
                                                         gint intvalue);
void                grl_data_set_float                  (GrlData *data,
                                                         GrlKeyID key,
                                                         gfloat floatvalue);
const GValue *      grl_data_get                        (GrlData *data,
                                                         GrlKeyID key);
const gchar *       grl_data_get_string                 (GrlData *data,
                                                         GrlKeyID key);
gint                grl_data_get_int                    (GrlData *data,
                                                         GrlKeyID key);
gfloat              grl_data_get_float                  (GrlData *data,
                                                         GrlKeyID key);
void                grl_data_add                        (GrlData *data,
                                                         GrlKeyID key);
void                grl_data_remove                     (GrlData *data,
                                                         GrlKeyID key);
gboolean            grl_data_has_key                    (GrlData *data,
                                                         GrlKeyID key);
GList *             grl_data_get_keys                   (GrlData *data);
gboolean            grl_data_key_is_known               (GrlData *data,
                                                         GrlKeyID key);
void                grl_data_set_overwrite              (GrlData *data,
                                                         gboolean overwrite);
gboolean            grl_data_get_overwrite              (GrlData *data);

Description

This class acts as dictionary where keys and their values can be stored. It is suggested to better high level classes, like GrlMedia, which provides functions to access known properties.

Details

struct GrlDataClass

struct GrlDataClass {
  GObjectClass parent_class;
};

Grilo Data class

GObjectClass parent_class;

the parent class structure

grl_data_new ()

GrlData *           grl_data_new                        (void);

Creates a new data object.

Returns :

a new data object.

Since 0.1.4


grl_data_set ()

void                grl_data_set                        (GrlData *data,
                                                         GrlKeyID key,
                                                         const GValue *value);

Sets the value associated with the key. If key already has a value and overwrite is TRUE, old value is freed and the new one is set.

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

data :

data to modify

key :

key to change or add. [type GObject.ParamSpec]

value :

the new value

Since 0.1.4


grl_data_set_string ()

void                grl_data_set_string                 (GrlData *data,
                                                         GrlKeyID key,
                                                         const gchar *strvalue);

Sets the value associated with the key. If key already has a value and overwrite is TRUE, old value is freed and the new one is set.

data :

data to modify

key :

key to change or add. [type GObject.ParamSpec]

strvalue :

the new value

Since 0.1.4


grl_data_set_int ()

void                grl_data_set_int                    (GrlData *data,
                                                         GrlKeyID key,
                                                         gint intvalue);

Sets the value associated with the key. If key already has a value and overwrite is TRUE, old value is replaced by the new one.

data :

data to change

key :

key to change or add. [type GObject.ParamSpec]

intvalue :

the new value

Since 0.1.4


grl_data_set_float ()

void                grl_data_set_float                  (GrlData *data,
                                                         GrlKeyID key,
                                                         gfloat floatvalue);

Sets the value associated with the key. If key already has a value and overwrite is TRUE, old value is replaced by the new one.

data :

data to change

key :

key to change or add. [type GObject.ParamSpec]

floatvalue :

the new value

Since 0.1.5


grl_data_get ()

const GValue *      grl_data_get                        (GrlData *data,
                                                         GrlKeyID key);

Get the value associated with the key. If it does not contain any value, NULL will be returned.

data :

data to retrieve value

key :

key to look up. [type GObject.ParamSpec]

Returns :

a GValue. This value should not be modified nor freed by user. [transfer none]

Since 0.1.4


grl_data_get_string ()

const gchar *       grl_data_get_string                 (GrlData *data,
                                                         GrlKeyID key);

Returns the value associated with the key. If key has no value, or value is not string, or key is not in data, then NULL is returned.

data :

data to inspect

key :

key to use. [type GObject.ParamSpec]

Returns :

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

Since 0.1.4


grl_data_get_int ()

gint                grl_data_get_int                    (GrlData *data,
                                                         GrlKeyID key);

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

data :

data to inspect

key :

key to use. [type GObject.ParamSpec]

Returns :

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

Since 0.1.4


grl_data_get_float ()

gfloat              grl_data_get_float                  (GrlData *data,
                                                         GrlKeyID key);

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

data :

data to inspect

key :

key to use. [type GObject.ParamSpec]

Returns :

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

Since 0.1.5


grl_data_add ()

void                grl_data_add                        (GrlData *data,
                                                         GrlKeyID key);

Adds a new key to data, with no value. If key already exists, it does nothing.

data :

data to change

key :

key to add. [type GObject.ParamSpec]

Since 0.1.4


grl_data_remove ()

void                grl_data_remove                     (GrlData *data,
                                                         GrlKeyID key);

Removes key from data, freeing its value. If key is not in data, then it does nothing.

data :

data to change

key :

key to remove. [type GObject.ParamSpec]

Since 0.1.4


grl_data_has_key ()

gboolean            grl_data_has_key                    (GrlData *data,
                                                         GrlKeyID key);

Checks if key is in data.

data :

data to inspect

key :

key to search. [type GObject.ParamSpec]

Returns :

TRUE if key is in data, FALSE in other case.

Since 0.1.4


grl_data_get_keys ()

GList *             grl_data_get_keys                   (GrlData *data);

Returns a list with keys contained in data.

data :

data to inspect

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. [transfer container][element-type GObject.ParamSpec]

Since 0.1.4


grl_data_key_is_known ()

gboolean            grl_data_key_is_known               (GrlData *data,
                                                         GrlKeyID key);

Checks if the key has a value.

data :

data to inspect

key :

key to search. [type GObject.ParamSpec]

Returns :

TRUE if key has a value.

Since 0.1.4


grl_data_set_overwrite ()

void                grl_data_set_overwrite              (GrlData *data,
                                                         gboolean overwrite);

This controls if grl_data_set will overwrite current value of a property with the new one.

Set it to TRUE so old values are overwritten, or FALSE in other case (default is FALSE).

data :

data to change

overwrite :

if data can be overwritten

Since 0.1.4


grl_data_get_overwrite ()

gboolean            grl_data_get_overwrite              (GrlData *data);

Checks if old values are replaced when calling grl_data_set.

data :

data to inspect

Returns :

TRUE if values will be overwritten.

Since 0.1.4

See Also

GrlMedia, GrlMediaBox, GrlMediaVideo, GrlMediaAudio, GrlMediaImage