Audacious $Id:Doxyfile42802007-03-2104:39:00Znenolod$
|
Basic Tuple handling API. More...
#include <glib.h>
#include <mowgli.h>
#include <audacious/i18n.h>
#include "config.h"
#include "tuple.h"
#include "audstrings.h"
#include "stringpool.h"
Go to the source code of this file.
Defines | |
#define | APPEND(b,...) |
#define | TUPLE_LOCK_WRITE(X) g_static_mutex_lock (& tuple_mutex) |
Convenience macros to lock the globally used internal Tuple system structures. | |
#define | TUPLE_UNLOCK_WRITE(X) g_static_mutex_unlock (& tuple_mutex) |
Convenience macros to lock the globally used internal Tuple system structures. | |
#define | TUPLE_LOCK_READ(X) g_static_mutex_lock (& tuple_mutex) |
Convenience macros to lock the globally used internal Tuple system structures. | |
#define | TUPLE_UNLOCK_READ(X) g_static_mutex_unlock (& tuple_mutex) |
Convenience macros to lock the globally used internal Tuple system structures. | |
Functions | |
static gboolean | set_string (Tuple *tuple, const gint nfield, const gchar *field, gchar *string, gboolean take) |
static void | tuple_value_destroy (TupleValue *value) |
static void | tuple_value_destroy_cb (const gchar *key, void *data, void *priv) |
static void | tuple_destroy (gpointer data) |
static Tuple * | tuple_new_unlocked (void) |
Tuple * | tuple_new (void) |
Allocates a new empty Tuple structure. | |
static TupleValue * | tuple_associate_data (Tuple *tuple, const gint cnfield, const gchar *field, TupleValueType ftype) |
(Re)associates data into given Tuple field. | |
void | tuple_set_filename (Tuple *tuple, const gchar *name) |
Sets filename/URI related fields of a Tuple structure, based on the given filename argument. | |
static TupleValue * | tuple_copy_value (TupleValue *src) |
Creates a copy of given TupleValue structure, with copied data. | |
Tuple * | tuple_copy (const Tuple *src) |
Creates a copy of given Tuple structure, with copied data. | |
Tuple * | tuple_new_from_filename (const gchar *filename) |
Allocates a new Tuple structure, setting filename/URI related fields based on the given filename argument by calling tuple_set_filename. | |
static gint | tuple_get_nfield (const gchar *field) |
gboolean | tuple_associate_string (Tuple *tuple, const gint nfield, const gchar *field, const gchar *string) |
Associates copy of given string to a field in specified Tuple. | |
gboolean | tuple_associate_string_rel (Tuple *tuple, const gint nfield, const gchar *field, gchar *string) |
Associates given string to a field in specified Tuple. | |
gboolean | tuple_associate_int (Tuple *tuple, const gint nfield, const gchar *field, gint integer) |
Associates given integer to a field in specified Tuple. | |
void | tuple_disassociate (Tuple *tuple, const gint cnfield, const gchar *field) |
Disassociates given field from specified Tuple structure. | |
TupleValueType | tuple_get_value_type (const Tuple *tuple, gint cnfield, const gchar *field) |
Returns TupleValueType of given Tuple field. | |
const gchar * | tuple_get_string (const Tuple *tuple, gint cnfield, const gchar *field) |
Returns pointer to a string associated to Tuple field. | |
gint | tuple_get_int (const Tuple *tuple, gint cnfield, const gchar *field) |
Returns integer associated to Tuple field. | |
void | tuple_set_format (Tuple *t, const gchar *format, gint chans, gint rate, gint brate) |
Variables | |
const TupleBasicType | tuple_fields [FIELD_LAST] |
Ordered table of basic Tuple field names and their TupleValueType. | |
static mowgli_heap_t * | tuple_heap = NULL |
A mowgli heap containing all the allocated tuples. | |
static mowgli_heap_t * | tuple_value_heap = NULL |
A mowgli heap containing values contained by tuples. | |
static mowgli_object_class_t | tuple_klass |
static GStaticMutex | tuple_mutex = G_STATIC_MUTEX_INIT |
Global lock to preserve data consistency of heaps. |
#define APPEND | ( | b, | |
... | |||
) |
#define TUPLE_LOCK_READ | ( | X | ) | g_static_mutex_lock (& tuple_mutex) |
Convenience macros to lock the globally used internal Tuple system structures.
Definition at line 101 of file tuple.c.
Referenced by tuple_get_int(), tuple_get_string(), and tuple_get_value_type().
#define TUPLE_LOCK_WRITE | ( | X | ) | g_static_mutex_lock (& tuple_mutex) |
Convenience macros to lock the globally used internal Tuple system structures.
Definition at line 99 of file tuple.c.
Referenced by set_string(), tuple_associate_int(), tuple_copy(), tuple_destroy(), tuple_disassociate(), and tuple_new().
#define TUPLE_UNLOCK_READ | ( | X | ) | g_static_mutex_unlock (& tuple_mutex) |
Convenience macros to lock the globally used internal Tuple system structures.
Definition at line 102 of file tuple.c.
Referenced by tuple_get_int(), tuple_get_string(), and tuple_get_value_type().
#define TUPLE_UNLOCK_WRITE | ( | X | ) | g_static_mutex_unlock (& tuple_mutex) |
Convenience macros to lock the globally used internal Tuple system structures.
Definition at line 100 of file tuple.c.
Referenced by set_string(), tuple_associate_data(), tuple_associate_int(), tuple_copy(), tuple_destroy(), tuple_disassociate(), and tuple_new().
static gboolean set_string | ( | Tuple * | tuple, |
const gint | nfield, | ||
const gchar * | field, | ||
gchar * | string, | ||
gboolean | take | ||
) | [static] |
Definition at line 409 of file tuple.c.
Referenced by tuple_associate_string(), tuple_associate_string_rel(), and tuple_set_filename().
static TupleValue * tuple_associate_data | ( | Tuple * | tuple, |
const gint | cnfield, | ||
const gchar * | field, | ||
TupleValueType | ftype | ||
) | [static] |
(Re)associates data into given Tuple field.
If specified field already exists in the Tuple, any data from it is freed and this current TupleValue struct is returned.
If field does NOT exist, a new structure is allocated from global heap, added to Tuple and returned.
[in] | tuple | Tuple structure to be manipulated. |
[in] | cnfield | TupleBasicType index or -1 if key name is to be used instead. |
[in] | field | String acting as key name or NULL if nfield is used. |
[in] | ftype | Type of the field to be associated. |
Definition at line 351 of file tuple.c.
Referenced by set_string(), and tuple_associate_int().
gboolean tuple_associate_int | ( | Tuple * | tuple, |
const gint | nfield, | ||
const gchar * | field, | ||
gint | integer | ||
) |
Associates given integer to a field in specified Tuple.
If field already exists, old value is freed and replaced.
Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.
[in] | tuple | Tuple structure pointer. |
[in] | nfield | TupleBasicType index or -1 if key name is to be used instead. |
[in] | field | String acting as key name or NULL if nfield is used. |
[in] | integer | Integer to be associated to given field in Tuple. |
Definition at line 502 of file tuple.c.
Referenced by tuple_set_filename(), and tuple_set_format().
gboolean tuple_associate_string | ( | Tuple * | tuple, |
const gint | nfield, | ||
const gchar * | field, | ||
const gchar * | string | ||
) |
Associates copy of given string to a field in specified Tuple.
If field already exists, old value is freed and replaced.
Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.
[in] | tuple | Tuple structure pointer. |
[in] | nfield | TupleBasicType index or -1 if key name is to be used instead. |
[in] | field | String acting as key name or NULL if nfield is used. |
[in] | string | String to be associated to given field in Tuple. |
Definition at line 446 of file tuple.c.
Referenced by tuple_set_format().
gboolean tuple_associate_string_rel | ( | Tuple * | tuple, |
const gint | nfield, | ||
const gchar * | field, | ||
gchar * | string | ||
) |
Associates given string to a field in specified Tuple.
The caller gives up ownership of the string. If field already exists, old value is freed and replaced.
Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.
[in] | tuple | Tuple structure pointer. |
[in] | nfield | TupleBasicType index or -1 if key name is to be used instead. |
[in] | field | String acting as key name or NULL if nfield is used. |
[in] | string | String to be associated to given field in Tuple. |
static TupleValue* tuple_copy_value | ( | TupleValue * | src | ) | [static] |
Creates a copy of given TupleValue structure, with copied data.
[in] | src | TupleValue structure to be made a copy of. |
Definition at line 237 of file tuple.c.
Referenced by tuple_copy().
static void tuple_destroy | ( | gpointer | data | ) | [static] |
Definition at line 121 of file tuple.c.
Referenced by tuple_new_unlocked().
Disassociates given field from specified Tuple structure.
Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.
[in] | tuple | Tuple structure pointer. |
[in] | cnfield | TupleBasicType index or -1 if key name is to be used instead. |
[in] | field | String acting as key name or NULL if nfield is used. |
Returns integer associated to Tuple field.
Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.
[in] | tuple | Tuple structure pointer. |
[in] | cnfield | TupleBasicType index or -1 if key name is to be used instead. |
[in] | field | String acting as key name or NULL if nfield is used. |
Definition at line 641 of file tuple.c.
Referenced by entry_set_tuple_real(), read_gain_from_tuple(), tuple_compare_int(), tuple_formatter_expression_empty(), tuple_formatter_expression_match(), tuple_formatter_process_expr(), and tuple_value_to_gvalue().
static gint tuple_get_nfield | ( | const gchar * | field | ) | [static] |
Definition at line 322 of file tuple.c.
Referenced by tuple_associate_data(), tuple_disassociate(), tuple_get_int(), tuple_get_string(), and tuple_get_value_type().
Returns pointer to a string associated to Tuple field.
Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.
[in] | tuple | Tuple structure pointer. |
[in] | cnfield | TupleBasicType index or -1 if key name is to be used instead. |
[in] | field | String acting as key name or NULL if nfield is used. |
Definition at line 599 of file tuple.c.
Referenced by describe_song(), playlist_select_by_patterns(), title_from_tuple(), tuple_compare_string(), tuple_formatter_expression_empty(), tuple_formatter_expression_match(), tuple_formatter_make_title_string(), tuple_formatter_process_expr(), and tuple_value_to_gvalue().
TupleValueType tuple_get_value_type | ( | const Tuple * | tuple, |
gint | cnfield, | ||
const gchar * | field | ||
) |
Returns TupleValueType of given Tuple field.
Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.
[in] | tuple | Tuple structure pointer. |
[in] | cnfield | TupleBasicType index or -1 if key name is to be used instead. |
[in] | field | String acting as key name or NULL if nfield is used. |
Definition at line 562 of file tuple.c.
Referenced by entry_set_tuple_real(), tuple_compare_int(), tuple_formatter_expression_empty(), tuple_formatter_expression_match(), tuple_formatter_process_expr(), and tuple_value_to_gvalue().
Tuple* tuple_new | ( | void | ) |
Allocates a new empty Tuple structure.
Must be freed via tuple_free().
Definition at line 171 of file tuple.c.
Referenced by tuple_new_from_filename().
Tuple* tuple_new_from_filename | ( | const gchar * | filename | ) |
Allocates a new Tuple structure, setting filename/URI related fields based on the given filename argument by calling tuple_set_filename.
[in] | filename | Filename URI. |
Definition at line 312 of file tuple.c.
Referenced by entry_set_failed().
static Tuple* tuple_new_unlocked | ( | void | ) | [static] |
Definition at line 143 of file tuple.c.
Referenced by tuple_copy(), and tuple_new().
void tuple_set_filename | ( | Tuple * | tuple, |
const gchar * | name | ||
) |
Sets filename/URI related fields of a Tuple structure, based on the given filename argument.
The fields set are: FIELD_FILE_PATH, FIELD_FILE_NAME and FIELD_FILE_EXT.
[in] | filename | Filename URI. |
[in,out] | tuple | Tuple structure to manipulate. |
Definition at line 195 of file tuple.c.
Referenced by tuple_new_from_filename().
static void tuple_value_destroy | ( | TupleValue * | value | ) | [static] |
Definition at line 105 of file tuple.c.
Referenced by tuple_destroy(), tuple_disassociate(), and tuple_value_destroy_cb().
static void tuple_value_destroy_cb | ( | const gchar * | key, |
void * | data, | ||
void * | priv | ||
) | [static] |
Definition at line 115 of file tuple.c.
Referenced by tuple_destroy().
const TupleBasicType tuple_fields[FIELD_LAST] |
Ordered table of basic Tuple field names and their TupleValueType.
Definition at line 40 of file tuple.c.
Referenced by audacious_rc_get_tuple_fields(), and tuple_evalctx_add_var().
mowgli_heap_t* tuple_heap = NULL [static] |
A mowgli heap containing all the allocated tuples.
Definition at line 85 of file tuple.c.
Referenced by tuple_destroy(), and tuple_new_unlocked().
mowgli_object_class_t tuple_klass [static] |
Definition at line 89 of file tuple.c.
Referenced by tuple_new_unlocked().
GStaticMutex tuple_mutex = G_STATIC_MUTEX_INIT [static] |
mowgli_heap_t* tuple_value_heap = NULL [static] |
A mowgli heap containing values contained by tuples.
Definition at line 88 of file tuple.c.
Referenced by tuple_associate_data(), tuple_copy_value(), tuple_new_unlocked(), and tuple_value_destroy().