Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
Classes | Defines | Enumerations | Functions | Variables
tuple.h File Reference

Basic Tuple handling API. More...

#include <glib.h>
#include <mowgli.h>

Go to the source code of this file.

Classes

struct  TupleBasicType
struct  TupleValue
struct  Tuple
 Structure for holding and passing around miscellaneous track metadata. More...

Defines

#define tuple_free(x)   mowgli_object_unref(x);

Enumerations

enum  {
  FIELD_ARTIST = 0, FIELD_TITLE, FIELD_ALBUM, FIELD_COMMENT,
  FIELD_GENRE, FIELD_TRACK, FIELD_TRACK_NUMBER, FIELD_LENGTH,
  FIELD_YEAR, FIELD_QUALITY, FIELD_CODEC, FIELD_FILE_NAME,
  FIELD_FILE_PATH, FIELD_FILE_EXT, FIELD_SONG_ARTIST, FIELD_MTIME,
  FIELD_FORMATTER, FIELD_PERFORMER, FIELD_COPYRIGHT, FIELD_DATE,
  FIELD_SUBSONG_ID, FIELD_SUBSONG_NUM, FIELD_MIMETYPE, FIELD_BITRATE,
  FIELD_SEGMENT_START, FIELD_SEGMENT_END, FIELD_GAIN_ALBUM_GAIN, FIELD_GAIN_ALBUM_PEAK,
  FIELD_GAIN_TRACK_GAIN, FIELD_GAIN_TRACK_PEAK, FIELD_GAIN_GAIN_UNIT, FIELD_GAIN_PEAK_UNIT,
  FIELD_COMPOSER, FIELD_LAST
}
 Ordered enum for basic Tuple fields. More...
enum  TupleValueType { TUPLE_STRING, TUPLE_INT, TUPLE_UNKNOWN }

Functions

Tupletuple_new (void)
 Allocates a new empty Tuple structure.
Tupletuple_copy (const Tuple *)
 Creates a copy of given Tuple structure, with copied data.
void tuple_set_filename (Tuple *tuple, const gchar *filename)
 Sets filename/URI related fields of a Tuple structure, based on the given filename argument.
Tupletuple_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.
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_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_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 nfield, const gchar *field)
 Disassociates given field from specified Tuple structure.
void tuple_disassociate_now (TupleValue *value)
TupleValueType tuple_get_value_type (const Tuple *tuple, gint nfield, const gchar *field)
 Returns TupleValueType of given Tuple field.
const gchar * tuple_get_string (const Tuple *tuple, gint nfield, const gchar *field)
 Returns pointer to a string associated to Tuple field.
gint tuple_get_int (const Tuple *tuple, gint nfield, const gchar *field)
 Returns integer associated to Tuple field.

Variables

const TupleBasicType tuple_fields [FIELD_LAST]
 Ordered table of basic Tuple field names and their TupleValueType.

Detailed Description

Basic Tuple handling API.

Definition in file tuple.h.


Define Documentation

#define tuple_free (   x)    mowgli_object_unref(x);

Definition at line 141 of file tuple.h.

Referenced by cancel_set_tuple(), entry_free(), entry_set_tuple_real(), and make_entries().


Enumeration Type Documentation

anonymous enum

Ordered enum for basic Tuple fields.

See also:
TupleBasicType
Enumerator:
FIELD_ARTIST 
FIELD_TITLE 

Song title.

FIELD_ALBUM 

Album name.

FIELD_COMMENT 

Freeform comment.

FIELD_GENRE 

Song's genre.

FIELD_TRACK 
FIELD_TRACK_NUMBER 
FIELD_LENGTH 

Track length in seconds.

FIELD_YEAR 

Year of production/performance/etc.

FIELD_QUALITY 

String representing quality, such as "lossy", "lossless", "sequenced".

FIELD_CODEC 

Codec name or similar.

FIELD_FILE_NAME 

File name part of the location URI.

FIELD_FILE_PATH 

Path part of the location URI.

FIELD_FILE_EXT 

Filename extension part of the location URI.

FIELD_SONG_ARTIST 
FIELD_MTIME 

Playlist entry modification time for internal use.

FIELD_FORMATTER 

Playlist entry Tuplez formatting string.

FIELD_PERFORMER 
FIELD_COPYRIGHT 
FIELD_DATE 
FIELD_SUBSONG_ID 

Index number of subsong/tune.

FIELD_SUBSONG_NUM 

Total number of subsongs in the file.

FIELD_MIMETYPE 
FIELD_BITRATE 

Bitrate in kbps.

FIELD_SEGMENT_START 
FIELD_SEGMENT_END 
FIELD_GAIN_ALBUM_GAIN 
FIELD_GAIN_ALBUM_PEAK 
FIELD_GAIN_TRACK_GAIN 
FIELD_GAIN_TRACK_PEAK 
FIELD_GAIN_GAIN_UNIT 
FIELD_GAIN_PEAK_UNIT 
FIELD_COMPOSER 

Composer of song, if different than artist.

FIELD_LAST 

Definition at line 36 of file tuple.h.

Enumerator:
TUPLE_STRING 
TUPLE_INT 
TUPLE_UNKNOWN 

Definition at line 89 of file tuple.h.


Function Documentation

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.

Parameters:
[in]tupleTuple structure pointer.
[in]nfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.
[in]integerInteger to be associated to given field in Tuple.
Returns:
TRUE if operation was succesful, FALSE if not.

Definition at line 486 of file tuple.c.

Referenced by tuple_set_filename().

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.

Parameters:
[in]tupleTuple structure pointer.
[in]nfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.
[in]stringString to be associated to given field in Tuple.
Returns:
TRUE if operation was succesful, FALSE if not.

Definition at line 425 of file tuple.c.

Referenced by tuple_associate_string_rel(), and tuple_set_filename().

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.

Parameters:
[in]tupleTuple structure pointer.
[in]nfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.
[in]stringString to be associated to given field in Tuple.
Returns:
TRUE if operation was succesful, FALSE if not.

Definition at line 464 of file tuple.c.

Tuple* tuple_copy ( const Tuple src)

Creates a copy of given Tuple structure, with copied data.

Parameters:
[in]srcTuple structure to be made a copy of.
Returns:
Pointer to newly allocated Tuple.

Definition at line 277 of file tuple.c.

void tuple_disassociate ( Tuple tuple,
const gint  cnfield,
const gchar *  field 
)

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.

Parameters:
[in]tupleTuple structure pointer.
[in]cnfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.

Definition at line 510 of file tuple.c.

void tuple_disassociate_now ( TupleValue value)
gint tuple_get_int ( const Tuple tuple,
gint  cnfield,
const gchar *  field 
)

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.

Parameters:
[in]tupleTuple structure pointer.
[in]cnfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.
Returns:
Integer value or 0 if the field/key did not exist.
Bug:
There is no way to distinguish error situations if the associated value is zero.

Definition at line 634 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().

const gchar* tuple_get_string ( const Tuple tuple,
gint  cnfield,
const gchar *  field 
)

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.

Parameters:
[in]tupleTuple structure pointer.
[in]cnfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.
Returns:
Pointer to string or NULL if the field/key did not exist. The returned string is const, and must not be freed or modified.

Definition at line 592 of file tuple.c.

Referenced by 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.

Parameters:
[in]tupleTuple structure pointer.
[in]cnfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.
Returns:
TupleValueType of the field or TUPLE_UNKNOWN if there was an error.

Definition at line 555 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().

Returns:
Pointer to newly allocated Tuple.

Definition at line 169 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.

Parameters:
[in]filenameFilename URI.
Returns:
Pointer to newly allocated Tuple.

Definition at line 321 of file tuple.c.

Referenced by entry_set_failed().

void tuple_set_filename ( Tuple tuple,
const gchar *  filename 
)

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.

Parameters:
[in]filenameFilename URI.
[in,out]tupleTuple structure to manipulate.

Definition at line 194 of file tuple.c.

Referenced by tuple_new_from_filename().


Variable Documentation

const TupleBasicType tuple_fields[FIELD_LAST]

Ordered table of basic Tuple field names and their TupleValueType.

Definition at line 34 of file tuple.c.

Referenced by audacious_rc_get_tuple_fields(), and tuple_evalctx_add_var().